Repositori ini dirancang untuk mengevaluasi Marqo-FashionCLIP dan Marqo-FashionSigLIP di tujuh kumpulan data benchmark publik. Baca lebih lanjut tentang model di blog kami.
Kami menghitung rata-rata kinerja tiga tugas umum di seluruh kumpulan data: teks-ke-gambar, kategori-ke-produk, dan sub-kategori-ke-produk. Seperti yang ditunjukkan di bawah, Marqo-FashionCLIP dan Marqo-FashionSigLIP mengungguli model OpenCLIP yang telah dilatih sebelumnya dan model CLIP fesyen yang canggih. Untuk perbandingan kinerja yang lebih komprehensif, lihat LEADERBOARD.
Text-To-Image (Rata-rata di 6 kumpulan data)
Model | Ingatan Rata-Rata | Ingat@1 | Ingat@10 | MRR |
---|---|---|---|---|
Marqo-FashionSigLIP | 0,231 | 0,121 | 0,340 | 0,239 |
Marqo-FashionCLIP | 0,192 | 0,094 | 0,290 | 0,200 |
ModeKLIP2.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 |
Kategori-Ke-Produk (Rata-rata di 5 kumpulan data)
Model | Rata-rata | P@1 | P@10 | MRR |
---|---|---|---|---|
Marqo-FashionSigLIP | 0,737 | 0,758 | 0,716 | 0,812 |
Marqo-FashionCLIP | 0,705 | 0,734 | 0,676 | 0,776 |
ModeKLIP2.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 |
Sub-Kategori-Ke-Produk (Rata-rata di 4 kumpulan data)
Model | Rata-rata | P@1 | P@10 | MRR |
---|---|---|---|---|
Marqo-FashionSigLIP | 0,725 | 0,767 | 0,683 | 0,811 |
Marqo-FashionCLIP | 0,707 | 0,747 | 0,667 | 0,772 |
ModeKLIP2.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 |
Kami merilis model kami di HuggingFace: Marqo-FashionCLIP dan Marqo-FashionSigLIP. Kami juga memiliki Demo Hugging Face Space dari model kami yang sedang beraksi: Klasifikasi dengan Marqo-FashionSigLIP.
Anda dapat memuat model dengan transformers
dengan
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 )
Dan
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 )
Kemudian,
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 )
Kami merilis artikel ini yang mengilustrasikan penelusuran e-niaga sederhana dengan kumpulan data mode jika Anda ingin melihat model tersebut beraksi.
Anda dapat memuat model dengan open_clip
by
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' )
Dan
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' )
Kemudian,
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 )
Untuk menerapkan di Marqo Cloud (disarankan):
Daftar ke Marqo Cloud.
Instal Marqo dan klien python Marqo:
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" )
Lihat dokumentasi lengkap untuk detail selengkapnya tentang menambahkan dokumen dan mencari.
Instal PyTorch terlebih dahulu dan jalankan
pip install -r requirements.txt
Untuk mengevaluasi Marqo-FashionCLIP, jalankan perintah ini
python eval.py
--dataset-config ./configs/ ${DATASET} .json
--model-name Marqo/marqo-fashionCLIP
--run-name Marqo-FashionCLIP
DATASET
dapat berupa salah satu dari ['deepfashion_inshop', 'deepfashion_multimodal', 'fashion200k', 'KAGL', 'atlas', 'polyvore' 'iMaterialist']Untuk mengevaluasi Marqo-FashionSigLIP, jalankan perintah ini
python eval.py
--dataset-config ./configs/ ${DATASET} .json
--model-name Marqo/marqo-fashionSigLIP
--run-name Marqo-FashionSigLIP
DATASET
dapat berupa salah satu dari ['deepfashion_inshop', 'deepfashion_multimodal', 'fashion200k', 'KAGL', 'atlas', 'polyvore' 'iMaterialist']Skrip untuk mengevaluasi model lain termasuk FashionCLIP 2.0 dan OpenFashionCLIP dapat ditemukan di direktori skrip.
Kami mengumpulkan 7 kumpulan data mode multimodal publik dan mengunggahnya ke HuggingFace: Atlas, DeepFashion (Dalam Toko), DeepFashion (Multimodal), Fashion200k, iMaterialist, KAGL, dan Polyvore. Setiap kumpulan data memiliki metadata berbeda yang tersedia. Jadi, tugas untuk setiap kumpulan data disimpan sebagai file json di direktori skrip. Lihat blog kami untuk informasi lebih lanjut tentang setiap kumpulan data.
Untuk memperbarui LEADERBOARD.md dan merangkum hasil model yang berbeda secara lokal, jalankan perintah ini
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}
}