patrickjohncyh/fashion-clip (commit 7e3ba62ce16b379a1ab479346b66f192e76f51b7)openai/clip-vit-base-patch32 在时尚领域微调CLIPModel (model_type: clip, vision_config: ViT-B/32 hidden 768 layers 12 patch 32 image_size 224, text_config: hidden 512 layers 12 vocab 49408, projection_dim 512, logit_scale_init 2.6592)image_embeds [1,512], text_embeds [6,512], logits_per_image [1,6] 与 softmax 概率及排序,用于时尚商品分类(dress/t-shirt/jeans/handbag/sneakers/jacket)inference.py 直接 CLIPModel.from_pretrained(local, torch_dtype=float32).to(npu:0) + CLIPProcessor,无隐式联网,从本地 /opt/atomgit/.cache/huggingface/hub/models--patrickjohncyh--fashion-clip/snapshots/7e3ba62ce16b379a1ab479346b66f192e76f51b7 加载npu:0 (HBM free 62313 MB total 62740 MB, npu-smi 25.5.5 Phy 4 Bus 0000:0B:00.0, Health OK)/usr/local/Ascend/cann-8.5.1)CLIPProcessor + CLIPModel 本地权重 605 MB, torch_dtype float32, device npu:0, 首参 npu:0 float32create_fashion_image) + 6 候选文本, batch 1pip install -r requirements.txt
# 需预装 CANN Toolkit 8.5.1 使 torch_npu 可用
# 权重已缓存于 /opt/atomgit/.cache/huggingface/hub/models--patrickjohncyh--fashion-clip/snapshots/7e3ba62ce16b379a1ab479346b66f192e76f51b7/model.safetensors
# 首次离线可通过 HF_ENDPOINT=https://hf-mirror.com 自动镜像python inference.py
# 或显式
python inference.py --device npu:0 --dtype float32
python inference.py --device cpu --dtype float32 # CPU 对比
python inference.py --mode validate # 触发 CPU-NPU 一致性校验
python inference.py --mode benchmark # 性能分项脚本自动: 检测 NPU、加载本地权重至 npu:0 float32、打印 device/dtype、输入设备、输出设备、同步计时 (torch.npu.synchronize())、logits/概率/排序、CPU-NPU 对比与性能。
param npu:0 float32, image_embeds npu:0 [1,512], text_embeds npu:0 [6,512], logits npu:0 [1,6][22.6447, 22.7313, 21.3270, 22.9695, 21.2625, 22.0584][0.2198, 0.2397, 0.0589, 0.3042, 0.0552, 0.1223]image_embeds[0][:5] [0.0150, 0.0511, -0.00978, -0.0183, 0.0488], text_embeds[0][:5] [0.00363, 0.00132, 0.0152, -0.0576, -0.0234]完整日志见
assets/model_result.png
a photo of a handbag vs CPU a photo of a handbag → True (必须一致 PASS)['handbag','t-shirt','dress','jacket','jeans','sneakers'] vs CPU 相同 → full_match True, top3_overlap 1.00 (候选6 <10 要求全量一致 PASS)torch.npu.synchronize(),预热 3 次、正式 10 次,batch 1, image 224x224, texts 6, dtype float32, device npu:0assets/agent_workflow.png — 下载、侦察、加载、NPU 推理、验证、性能全流程日志assets/npu_device_call.png — npu-smi info, torch.npu.is_available(), device_name Ascend910_9362, param device npu:0 float32, inputs npu:0, logits npu:0assets/model_result.png — python inference.py 真实输出、logits/概率/排序、一致性与性能及 PASS/FAIL--dtypeuse_fast=False 与 fast 版有微小输出差异,已记录torch_dtype deprecated 警告不影响功能,未来可改为 dtypeHardware: NPU, NPU, Ascend, Ascend910, CLIP, fashion-clip, dual-encoder, vision, zero-shot