🚀 时尚目标检测模型
本项目是一个用于时尚目标检测的模型,基于hustvl/yolos - tiny微调而来,可对时尚相关的物品进行检测,如包、上衣、裙子等,同时还能与时尚图像特征提取模型结合使用,在时尚搜索等领域有一定应用价值。
🚀 快速开始
本模型是hustvl/yolos - tiny的微调版本。
你可以在这个GitHub仓库中找到模型的详细信息 -> fashion - visual - search
你还能找到时尚图像特征提取模型 -> yainage90/fashion - image - feature - extractor
📦 安装指南
文档未提供具体安装步骤,暂不展示。
💻 使用示例
基础用法
from PIL import Image
import torch
from transformers import YolosImageProcessor, YolosForObjectDetection
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-yolos-tiny'
image_processor = YolosImageProcessor.from_pretrained(ckpt)
model = YolosForObjectDetection.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.85, 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))
示例图片

📚 详细文档
本模型使用两个数据集的组合进行训练:modanet 和 fashionpedia
标签为 ['bag', 'bottom', 'dress', 'hat', 'shoes', 'outer', 'top']
在总共100个训练轮次中的第96个轮次,取得了最佳分数,平均精度均值(mAP)为0.697400。
📄 许可证
本项目采用MIT许可证。