該儲存庫旨在跨七個公共基準資料集評估 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}
}