该存储库旨在跨七个公共基准数据集评估 Marqo-FashionCLIP 和 Marqo-FashionSigLIP。在我们的博客上了解有关模型的更多信息。
我们对数据集中三个常见任务的性能进行了平均:文本到图像、类别到产品和子类别到产品。如下所示,Marqo-FashionCLIP 和 Marqo-FashionSigLIP 的性能优于预训练的 OpenCLIP 模型和最先进的时尚 CLIP 模型。如需更全面的性能比较,请参阅排行榜。
文本到图像(6 个数据集的平均值)
模型 | 平均召回率 | 召回@1 | 召回@10 | MRR |
---|---|---|---|---|
Marqo-时尚SigLIP | 0.231 | 0.121 | 0.340 | 0.239 |
Marqo-FashionCLIP | 0.192 | 0.094 | 0.290 | 0.200 |
时尚CLIP2.0 | 0.163 | 0.077 | 0.249 | 0.165 |
OpenFashionCLIP | 0.132 | 0.060 | 0.204 | 0.135 |
ViT-B-16-laion2b_s34b_b88k | 0.174 | 0.088 | 0.261 | 0.180 |
ViT-B-16-SigLIP-webli | 0.212 | 0.111 | 0.314 | 0.214 |
类别到产品(5 个数据集的平均值)
模型 | 平均P | P@1 | P@10 | MRR |
---|---|---|---|---|
Marqo-时尚SigLIP | 0.737 | 0.758 | 0.716 | 0.812 |
Marqo-FashionCLIP | 0.705 | 0.734 | 0.676 | 0.776 |
时尚CLIP2.0 | 0.684 | 0.681 | 0.686 | 0.741 |
OpenFashionCLIP | 0.646 | 0.653 | 0.639 | 0.720 |
ViT-B-16-laion2b_s34b_b88k | 0.662 | 0.673 | 0.652 | 0.743 |
ViT-B-16-SigLIP-webli | 0.688 | 0.690 | 0.685 | 0.751 |
子类别到产品(4 个数据集的平均值)
模型 | 平均P | P@1 | P@10 | MRR |
---|---|---|---|---|
Marqo-时尚SigLIP | 0.725 | 0.767 | 0.683 | 0.811 |
Marqo-FashionCLIP | 0.707 | 0.747 | 0.667 | 0.772 |
时尚CLIP2.0 | 0.657 | 0.676 | 0.638 | 0.733 |
OpenFashionCLIP | 0.598 | 0.619 | 0.578 | 0.689 |
ViT-B-16-laion2b_s34b_b88k | 0.638 | 0.651 | 0.624 | 0.712 |
ViT-B-16-SigLIP-webli | 0.643 | 0.643 | 0.643 | 0.726 |
我们在 HuggingFace 上发布了我们的模型:Marqo-FashionCLIP 和 Marqo-FashionSigLIP。我们还有一个正在运行的模型的拥抱脸部空间演示:使用 Marqo-FashionSigLIP 进行分类。
您可以通过以下方式加载带有transformers
的模型
from transformers import AutoModel , AutoProcessor
model = AutoModel . from_pretrained ( 'Marqo/marqo-fashionCLIP' , trust_remote_code = True )
processor = AutoProcessor . from_pretrained ( 'Marqo/marqo-fashionCLIP' , trust_remote_code = True )
和
from transformers import AutoModel , AutoProcessor
model = AutoModel . from_pretrained ( 'Marqo/marqo-fashionSigLIP' , trust_remote_code = True )
processor = AutoProcessor . from_pretrained ( 'Marqo/marqo-fashionSigLIP' , trust_remote_code = True )
然后,
import torch
from PIL import Image
image = [ Image . open ( "docs/fashion-hippo.png" )]
text = [ "a hat" , "a t-shirt" , "shoes" ]
processed = processor ( text = text , images = image , padding = 'max_length' , return_tensors = "pt" )
with torch . no_grad ():
image_features = model . get_image_features ( processed [ 'pixel_values' ], normalize = True )
text_features = model . get_text_features ( processed [ 'input_ids' ], normalize = True )
text_probs = ( 100.0 * image_features @ text_features . T ). softmax ( dim = - 1 )
print ( "Label probs:" , text_probs )
如果您想查看模型的实际效果,我们发布了这篇文章,说明了使用时尚数据集进行简单的电子商务搜索。
您可以使用open_clip
加载模型
import open_clip
model , preprocess_train , preprocess_val = open_clip . create_model_and_transforms ( 'hf-hub:Marqo/marqo-fashionCLIP' )
tokenizer = open_clip . get_tokenizer ( 'hf-hub:Marqo/marqo-fashionCLIP' )
和
import open_clip
model , preprocess_train , preprocess_val = open_clip . create_model_and_transforms ( 'hf-hub:Marqo/marqo-fashionSigLIP' )
tokenizer = open_clip . get_tokenizer ( 'hf-hub:Marqo/marqo-fashionSigLIP' )
然后,
import torch
from PIL import Image
image = preprocess_val ( Image . open ( "docs/fashion-hippo.png" )). unsqueeze ( 0 )
text = tokenizer ([ "a hat" , "a t-shirt" , "shoes" ])
with torch . no_grad (), torch . cuda . amp . autocast ():
image_features = model . encode_image ( image , normalize = True )
text_features = model . encode_text ( text , normalize = True )
text_probs = ( 100.0 * image_features @ text_features . T ). softmax ( dim = - 1 )
print ( "Label probs:" , text_probs )
在 Marqo Cloud 上部署(推荐):
注册 Marqo 云。
安装 Marqo 和 Marqo python 客户端:
pip install marqo
import marqo
settings = {
"type" : "unstructured" ,
"model" : "marqo-fashion-clip" , # model name
"modelProperties" : {
"name" : "ViT-B-16" , # model architecture
"dimensions" : 512 , # embedding dimensions
"url" : "https://marqo-gcl-public.s3.us-west-2.amazonaws.com/marqo-fashionCLIP/marqo_fashionCLIP.pt" , # model weights
"type" : "open_clip" # loading library
},
}
api_key = "your_api_key" # replace with your api key (https://www.marqo.ai/blog/finding-my-marqo-api-key)
mq = marqo . Client ( "https://api.marqo.ai" , api_key = api_key )
mq . create_index ( "fashion-index" , settings_dict = settings )
# triggers model download
mq . index ( "fashion-index" ). search ( "black dress" )
有关添加文档和搜索的更多详细信息,请参阅完整文档。
首先安装PyTorch并运行
pip install -r requirements.txt
要评估 Marqo-FashionCLIP,请运行以下命令
python eval.py
--dataset-config ./configs/ ${DATASET} .json
--model-name Marqo/marqo-fashionCLIP
--run-name Marqo-FashionCLIP
DATASET
可以是 ['deepfashion_inshop'、'deepfashion_multimodal'、'fashion200k'、'KAGL'、'atlas'、'polyvore' 'iMaterialist'] 之一要评估 Marqo-FashionSigLIP,请运行以下命令
python eval.py
--dataset-config ./configs/ ${DATASET} .json
--model-name Marqo/marqo-fashionSigLIP
--run-name Marqo-FashionSigLIP
DATASET
可以是 ['deepfashion_inshop'、'deepfashion_multimodal'、'fashion200k'、'KAGL'、'atlas'、'polyvore' 'iMaterialist'] 之一用于评估其他模型(包括 FashionCLIP 2.0 和 OpenFashionCLIP)的脚本可以在脚本目录中找到。
我们收集了 7 个公共多模态时尚数据集并上传到 HuggingFace:Atlas、DeepFashion(In-shop)、DeepFashion(多模态)、Fashion200k、iMaterialist、KAGL 和 Polyvore。每个数据集都有不同的可用元数据。因此,每个数据集的任务都以 json 文件的形式存储在脚本目录中。有关每个数据集的更多信息,请参阅我们的博客。
要更新 LEADERBOARD.md 并在本地汇总不同模型的结果,请运行以下命令
python summarize_results.py
@software{Jung_Marqo-FashionCLIP_and_Marqo-FashionSigLIP_2024,
author = {Jung, Myong Chol and Clark, Jesse},
month = aug,
title = {{Marqo-FashionCLIP and Marqo-FashionSigLIP}},
url = {https://github.com/marqo-ai/marqo-FashionCLIP},
version = {1.0.0},
year = {2024}
}