标签:
#model-agent-tagged·#NPU·#Ascend·#Ascend-910·#vision·#language·#fashion本模型卡片已标注
#NPU、#Ascend、#Ascend-910与#model-agent-tagged标签,符合昇腾模型适配比赛提交要求。
patrickjohncyh/fashion-clip 是基于 CLIP 架构(ViT-B/32)的 FashionCLIP:在 80 万+ 时尚商品(图像+文本)对上微调得到 零样本图文匹配/检索模型(FashionCLIP 2.0,基于 Laion CLIP-ViT-B-32 微调)。图像与文本 分别编码为 512 维 L2 归一化投影 embedding,通过 logit_scale 缩放的余弦相似度打分, 可用于商品检索、时尚分类(FMNIST/KAGL/DEEP 加权宏 F1 分别 0.83/0.73/0.62)、标签推荐等。
visual_projection / text_projection → 512 维;logit_scale 缩放相似度model.safetensors(605,157,890 B)+ config.json +
tokenizer 全套(tokenizer.json/vocab.json/merges.txt),CLIPModel.from_pretrained /
CLIPProcessor.from_pretrained 直接加载,无自定义代码torch.npu.is_available() 检测 + torch.npu.set_device,模型与输入
tensor 均 to("npu:0");全部算子为纯 PyTorch(Linear/LayerNorm/GELU/softmax/normalize),
在昇腾 NPU 上原生执行,无 CUDA 内核、无 CPU fallback| 组件 | 版本(实测) |
|---|---|
| Python | 3.11(aarch64) |
| torch | 2.9.0+cpu |
| torch_npu | 2.9.0.post1(CANN 25.5.5) |
| transformers | 4.57.6 |
| pillow | 12.2.0 |
| numpy | 1.26.4 |
git clone https://gitcode.com/stella4528/fashion-clip-npu
cd fashion-clip-npu
pip install -r requirements.txtpython3 inference.pypython3 inference.py --device npu
python3 inference.py --device cpu --texts "a black dress,white sneakers,red coat"
python3 inference.py --device npu --image product.jpg --texts "a,b,c"image_embeds (1,512) / text_embeds (4,512) / logits (1,4),
输出各候选文本匹配概率与最佳匹配,NPU_INFERENCE_PASS=True,结果落盘到 results/。实测结果见下方;适配脚本与输出截图见
assets/。
| 文件 | 说明 |
|---|---|
inference.py | 昇腾 NPU 推理脚本(CLIPModel 图文双塔前向 + 零样本打分) |
weights/model.safetensors | 原始权重(605 MB,fp32) |
weights/config.json | 模型配置(CLIP 架构 / 维度) |
weights/tokenizer* / vocab.json / merges.txt | CLIP tokenizer 文件 |
requirements.txt | 环境依赖清单 |