🚀 微調服裝分類模型
本模型基於預訓練模型進行微調,能夠根據給定的圖像對服裝類別進行分類,在評估集上取得了良好的效果,為服裝分類任務提供了有效的解決方案。
🚀 快速開始
本模型是 google/vit-base-patch16-224-in21k 在 clothes_simplifiedv2 數據集上的微調版本。它在評估集上取得了以下結果:
✨ 主要特性
此模型能夠根據給定的圖像對服裝類別進行分類。
💻 使用示例
基礎用法
from PIL import Image
import requests
url = 'insert image url here'
image = Image.open(requests.get(url, stream=True).raw)
from transformers import AutoModelForImageClassification, AutoImageProcessor
repo_name = "samokosik/finetuned-clothes"
image_processor = AutoImageProcessor.from_pretrained(repo_name)
model = AutoModelForImageClassification.from_pretrained(repo_name)
encoding = image_processor(image.convert("RGB"), return_tensors="pt")
print(encoding.pixel_values.shape)
import torch
with torch.no_grad():
outputs = model(**encoding)
logits = outputs.logits
predicted_class_idx = logits.argmax(-1).item()
print("Predicted class:", model.config.id2label[predicted_class_idx])
🔧 技術細節
侷限性
由於可用數據有限,本模型僅支持以下類別:帽子、長袖上衣、外套、褲子、鞋子、短褲、短袖上衣。
訓練過程
訓練超參數
訓練過程中使用了以下超參數:
- 學習率:5e - 05
- 訓練批次大小:8
- 評估批次大小:8
- 隨機種子:42
- 優化器:Adam(β1 = 0.9,β2 = 0.999,ε = 1e - 08)
- 學習率調度器類型:線性
- 訓練輪數:4
- 混合精度訓練:Native AMP
訓練結果
訓練損失 |
輪數 |
步數 |
驗證損失 |
準確率 |
0.7725 |
0.2058 |
100 |
0.7008 |
0.8178 |
0.5535 |
0.4115 |
200 |
0.4494 |
0.8994 |
0.4334 |
0.6173 |
300 |
0.3649 |
0.9169 |
0.3921 |
0.8230 |
400 |
0.3085 |
0.9184 |
0.3695 |
1.0288 |
500 |
0.3091 |
0.9184 |
0.2634 |
1.2346 |
600 |
0.3339 |
0.9082 |
0.4788 |
1.4403 |
700 |
0.2827 |
0.9257 |
0.3337 |
1.6461 |
800 |
0.2499 |
0.9344 |
0.34 |
1.8519 |
900 |
0.2586 |
0.9315 |
0.2424 |
2.0576 |
1000 |
0.2248 |
0.9402 |
0.1559 |
2.2634 |
1100 |
0.2333 |
0.9344 |
0.351 |
2.4691 |
1200 |
0.2495 |
0.9359 |
0.2206 |
2.6749 |
1300 |
0.2622 |
0.9242 |
0.3814 |
2.8807 |
1400 |
0.3138 |
0.9155 |
0.2141 |
3.0864 |
1500 |
0.2613 |
0.9315 |
0.112 |
3.2922 |
1600 |
0.2266 |
0.9402 |
0.0631 |
3.4979 |
1700 |
0.2255 |
0.9402 |
0.1986 |
3.7037 |
1800 |
0.2225 |
0.9417 |
0.2345 |
3.9095 |
1900 |
0.2235 |
0.9373 |
框架版本
- Transformers 4.40.1
- Pytorch 2.2.1+cu121
- Datasets 2.19.0
- Tokenizers 0.19.1
訓練數據集
本模型在以下數據集上進行訓練:https://huggingface.co/datasets/samokosik/clothes_simplifiedv2
📄 許可證
本模型採用 Apache - 2.0 許可證。