🚀 時尚目標檢測模型
本項目基於transformers
庫,提供了一個用於時尚目標檢測的微調模型。該模型以microsoft/conditional-detr-resnet-50
為基礎,可檢測時尚圖像中的各類物品,如包、上衣、褲子等,在時尚搜索等領域具有重要價值。
🚀 快速開始
本模型是microsoft/conditional-detr-resnet-50
的微調版本。
你可以在這個GitHub倉庫中找到模型的詳細信息 -> fashion-visual-search
同時,你還能找到時尚圖像特徵提取器模型 -> yainage90/fashion-image-feature-extractor
本模型使用兩個數據集組合進行訓練:modanet 和 fashionpedia
模型可檢測的標籤有 ['包', '下裝', '連衣裙', '帽子', '鞋子', '外套', '上衣']
在總共100個訓練輪次中的第96輪,模型取得了最佳成績,平均精度均值(mAP)為0.7542。因此,認為模型在性能上仍有一定的提升空間。
💻 使用示例
基礎用法
from PIL import Image
import torch
from transformers import AutoImageProcessor, AutoModelForObjectDetection
device = 'cpu'
if torch.cuda.is_available():
device = torch.device('cuda')
elif torch.backends.mps.is_available():
device = torch.device('mps')
ckpt = 'yainage90/fashion-object-detection'
image_processor = AutoImageProcessor.from_pretrained(ckpt)
model = AutoModelForObjectDetection.from_pretrained(ckpt).to(device)
image = Image.open('<path/to/image>').convert('RGB')
with torch.no_grad():
inputs = image_processor(images=[image], return_tensors="pt")
outputs = model(**inputs.to(device))
target_sizes = torch.tensor([[image.size[1], image.size[0]]])
results = image_processor.post_process_object_detection(outputs, threshold=0.4, target_sizes=target_sizes)[0]
items = []
for score, label, box in zip(results["scores"], results["labels"], results["boxes"]):
score = score.item()
label = label.item()
box = [i.item() for i in box]
print(f"{model.config.id2label[label]}: {round(score, 3)} at {box}")
items.append((score, label, box))

📄 許可證
本項目採用MIT許可證。