可用于 CIFAR-100 数据集的图像分类任务,该项目是在 GuangxiAICC/swin-small-patch4-window7-224 基础上微调的模型,评估集准确率达 0.8938,支持 NPU 和 CPU 设备运行。【此简介由AI生成】
以下内容由 AI 翻译,如有问题请 点此提交 issue 反馈
license: apache-2.0 tags:
- generated_from_trainer datasets:
- cifar100 metrics:
- accuracy model-index:
- name: swin-small-finetuned-cifar100
results:
- task:
name: Image Classification
type: image-classification
dataset:
name: cifar100
type: cifar100
args: cifar100
metrics:
- name: Accuracy type: accuracy value: 0.8938 pipeline_tag: image-classification frameworks:
- task:
name: Image Classification
type: image-classification
dataset:
name: cifar100
type: cifar100
args: cifar100
metrics:
- PyTorch library_name: openmind hardwares:
- NPU language:
- zh
swin-small-finetuned-cifar100
该模型是 GuangxiAICC/swin-small-patch4-window7-224 在 cifar100 数据集上的微调版本。 它在评估集上取得了以下结果:
- 损失:0.6281
- 准确率:0.8938
模型描述
需要更多信息
预期用途与局限性
需要更多信息
训练和评估数据
需要更多信息
训练过程
训练超参数
训练过程中使用了以下超参数:
- 学习率:4e-05
- 训练批次大小:16
- 评估批次大小:16
- 随机种子:42
- 梯度累积步数:4
- 总训练批次大小:64
- 优化器:Adam,betas=(0.9,0.999),epsilon=1e-08
- 学习率调度器类型:线性
- 学习率调度器预热比例:0.1
- 训练轮数:20
训练结果
| 训练损失 | 轮次 | 步数 | 验证损失 | 准确率 |
|---|---|---|---|---|
| 0.72 | 1.0 | 781 | 0.6691 | 0.8077 |
| 0.6944 | 2.0 | 1562 | 0.4797 | 0.8495 |
| 0.2794 | 3.0 | 2343 | 0.4338 | 0.869 |
| 0.2569 | 4.0 | 3124 | 0.4263 | 0.879 |
| 0.1417 | 5.0 | 3905 | 0.4385 | 0.8819 |
| 0.0961 | 6.0 | 4686 | 0.4720 | 0.8854 |
| 0.0584 | 7.0 | 5467 | 0.4941 | 0.885 |
| 0.0351 | 8.0 | 6248 | 0.5253 | 0.885 |
| 0.0107 | 9.0 | 7029 | 0.5598 | 0.8887 |
| 0.0118 | 10.0 | 7810 | 0.5998 | 0.8858 |
| 0.0097 | 11.0 | 8591 | 0.5957 | 0.8941 |
| 0.0044 | 12.0 | 9372 | 0.6237 | 0.8912 |
| 0.0013 | 13.0 | 10153 | 0.6286 | 0.8929 |
| 0.0102 | 14.0 | 10934 | 0.6281 | 0.8938 |
推理
import torch
import torch_npu
import argparse
from openmind import pipeline, is_torch_npu_available
from openmind import AutoImageProcessor
from openmind import AutoModel
from PIL import Image
import requests
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument(
"--model_name_or_path",
type=str,
help="Path to model",
default=None,
)
args = parser.parse_args()
return args
def main():
args = parse_args()
if args.model_name_or_path:
model_path = args.model_name_or_path
else:
model_path = snapshot_download(
"GuangxiAICC/swin-small-finetuned-cifar100",
revision="main",
ignore_patterns=["*.h5", "*.ot", "*.msgpack"],
)
if is_torch_npu_available():
device = "npu:0"
else:
device = "cpu"
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)
processor = AutoImageProcessor.from_pretrained(model_path)
model = AutoModel.from_pretrained(model_path).to(device)
inputs = processor(images=image, return_tensors="pt").to(device)
outputs = model(**inputs)
print("Predicted class:", outputs)
if __name__=="__main__":
main()
框架版本
- Transformers 4.20.1
- Pytorch 2.1.0-npu
- Datasets 2.1.0
- Tokenizers 0.12.1