🚀 Marqo-FashionCLIPモデルカード
Marqo-FashionCLIPとMarqo-FashionSigLIPは、これまでの最先端のファッションCLIPモデルを上回る性能を発揮します(下記の結果を参照)。Marqo-FashionCLIPはGeneralised Contrastive Learning (GCL) を活用しており、これによりモデルはテキスト記述だけでなく、カテゴリ、スタイル、色、素材、キーワード、詳細な情報を用いて学習することができ、ファッション商品に関する高度に関連性の高い検索結果を提供します。このモデルはViT-B-16 (laion2b_s34b_b88k) からファインチューニングされています。
GitHubページ: Marqo-FashionCLIP
ブログ: Marqoブログ
🚀 クイックスタート
Marqo-FashionCLIPは、ファッション商品の検索に高度に関連性の高い結果を提供するために開発されたモデルです。以下に、いくつかの使用方法を紹介します。
✨ 主な機能
- Generalised Contrastive Learning (GCL) を活用し、テキスト記述だけでなく様々な情報を用いて学習することができます。
- ファッション商品に関する高度に関連性の高い検索結果を提供します。
- Hugging Face、OpenCLIP、Transformers.jsなどのライブラリと互換性があります。
💻 使用例
基本的な使用法
Hugging Face
このモデルはAutoModel
を使ってロードすることができます。
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)
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)
OpenCLIP
このモデルは OpenCLIP とシームレスに連携して使用することができます。
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 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)
Transformers.js
このモデルは Transformers.js ライブラリを使ってJavaScriptで実行することもできます。
まず、NPM からインストールします。
npm i @huggingface/transformers
次に、以下のように埋め込みを計算します。
import { CLIPTextModelWithProjection, CLIPVisionModelWithProjection, AutoTokenizer, AutoProcessor, RawImage, softmax, dot } from '@huggingface/transformers';
const model_id = 'Marqo/marqo-fashionCLIP';
const tokenizer = await AutoTokenizer.from_pretrained(model_id);
const text_model = await CLIPTextModelWithProjection.from_pretrained(model_id);
const processor = await AutoProcessor.from_pretrained(model_id);
const vision_model = await CLIPVisionModelWithProjection.from_pretrained(model_id);
const texts = ['a hat', 'a t-shirt', 'shoes'];
const text_inputs = tokenizer(texts, { padding: 'max_length', truncation: true });
const { text_embeds } = await text_model(text_inputs);
const image = await RawImage.read('https://raw.githubusercontent.com/marqo-ai/marqo-FashionCLIP/main/docs/fashion-hippo.png');
const image_inputs = await processor(image);
const { image_embeds } = await vision_model(image_inputs);
const normalized_text_embeds = text_embeds.normalize().tolist();
const normalized_image_embeds = image_embeds.normalize().tolist()[0];
const text_probs = softmax(normalized_text_embeds.map((text_embed) =>
100.0 * dot(normalized_image_embeds, text_embed)
));
console.log(text_probs);
📚 ドキュメント
ベンチマーク結果
6つの公開されているマルチモーダルファッションデータセット(Atlas、DeepFashion (In-shop)、DeepFashion (Multimodal)、Fashion200k、KAGL、Polyvore)に対する平均評価結果を以下に報告します。
テキストから画像(6つのデータセットの平均)
モデル |
平均再現率 |
再現率@1 |
再現率@10 |
MRR |
Marqo-FashionCLIP |
0.192 |
0.094 |
0.290 |
0.200 |
FashionCLIP2.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 |
カテゴリから商品(5つのデータセットの平均)
モデル |
平均精度 |
精度@1 |
精度@10 |
MRR |
Marqo-FashionCLIP |
0.705 |
0.734 |
0.676 |
0.776 |
FashionCLIP2.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 |
サブカテゴリから商品(4つのデータセットの平均)
モデル |
平均精度 |
精度@1 |
精度@10 |
MRR |
Marqo-FashionCLIP |
0.707 |
0.747 |
0.667 |
0.772 |
FashionCLIP2.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 |
📄 ライセンス
このモデルはApache-2.0ライセンスの下で提供されています。