许可证:apache-2.0
基础模型:google/vit-base-patch16-224-in21k
标签:
- 图像分类
- 训练生成
评估指标:
- 准确率
模型索引:
- 名称:finetuned-clothes
结果:[]
微调服装分类模型
该模型是基于google/vit-base-patch16-224-in21k在clothes_simplifiedv2数据集上微调的版本。
在评估集上达到以下结果:
模型描述
该模型用于根据给定图像对服装类别进行分类。
使用方式
您可以在Jupyter笔记本中使用:
from PIL import Image
import requests
url = '在此插入图片URL'
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("预测类别:", model.config.id2label[predicted_class_idx])
局限性
由于数据有限,当前仅支持以下类别:帽子、长袖衫、外套、长裤、鞋子、短裤、短袖衫。
训练过程
训练超参数
训练期间使用的超参数:
- 学习率:5e-05
- 训练批次大小:8
- 评估批次大小:8
- 随机种子:42
- 优化器:Adam(beta=(0.9,0.999),epsilon=1e-08)
- 学习率调度器类型:线性
- 训练轮次:4
- 混合精度训练:原生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