Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ViT_migraphx
Commits
ee6c50a4
Commit
ee6c50a4
authored
Jun 07, 2023
by
lijian6
Browse files
Modify README.md
Signed-off-by:
lijian
<
lijian6@sugon.com
>
parent
da529d77
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
15 deletions
+26
-15
Python/README.md
Python/README.md
+25
-14
README.md
README.md
+1
-1
No files found.
Python/README.md
View file @
ee6c50a4
...
@@ -19,14 +19,14 @@ Vision Transformer模型结构如下图所示主要包括三部分,patch embed
...
@@ -19,14 +19,14 @@ Vision Transformer模型结构如下图所示主要包括三部分,patch embed
使用ImageNet数据集做pretrain,pretrain之后的模型使用
[
flower_photos
](
https://storage.googleapis.com/download.tensorflow.org/example_images/flower_photos.tgz
)
做fine-tuning
使用ImageNet数据集做pretrain,pretrain之后的模型使用
[
flower_photos
](
https://storage.googleapis.com/download.tensorflow.org/example_images/flower_photos.tgz
)
做fine-tuning
## 训练
## 训练
和推理
### 环境配置
### 环境配置
在
[
光源
](
https://www.sourcefind.cn/#/service-details
)
可拉取训练的docker镜像,推荐的镜像如下:
在
[
光源
](
https://www.sourcefind.cn/#/service-details
)
可拉取训练的docker镜像,推荐的镜像如下:
*
训练镜像:docker pull image.sourcefind.cn:5000/dcu/admin/base/pytorch:1.10.0-centos7.6-dtk-22.10.1-py37-latest
*
训练镜像:docker pull image.sourcefind.cn:5000/dcu/admin/base/pytorch:1.10.0-centos7.6-dtk-22.10.1-py37-latest
若想使用MIGraphX做推理,可在
[
光合开发者社区
](
https://cancon.hpccube.com:65024/4/main/
)
中下载MIGraphX.
若想使用MIGraphX做推理,可在
[
光合开发者社区
](
https://cancon.hpccube.com:65024/4/main/
)
中下载MIGraphX
并安装
.
### Fine-tunning
### Fine-tunning
...
@@ -41,19 +41,30 @@ Fine-tuning时可调整epoch参数来调整模型。
...
@@ -41,19 +41,30 @@ Fine-tuning时可调整epoch参数来调整模型。
本项目使用
[
base_patch16_224_in21k
](
https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-vitjx/jx_vit_base_patch16_224_in21k-e5005f0a.pth
)
为预训练模型,需自行下载。下载完预训练模型和数据集,即可开始fine-tun。可用torch进行推理,也可转为onnx模型使用MIGraphX进行推理。
本项目使用
[
base_patch16_224_in21k
](
https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-vitjx/jx_vit_base_patch16_224_in21k-e5005f0a.pth
)
为预训练模型,需自行下载。下载完预训练模型和数据集,即可开始fine-tun。可用torch进行推理,也可转为onnx模型使用MIGraphX进行推理。
### 推理
### 推理
推理测试模型用infer_pytroch.py和infer_migraphx.py对训练出的模型进行推理,使用方法如下:
推理测试用infer_pytroch.py和infer_migraphx.py对训练出的模型进行推理,使用方法如下:
python infer_pytroch.py ./flower_photos/daisy/
python infer_pytroch.py ./flower_photos/daisy/
python infer_migraphx.py --imgpath=./flower_photos/daisy/
python infer_migraphx.py --imgpath=./flower_photos/daisy/
## 代码使用简介
## 准确率数据
1.
下载好数据集,代码中默认使用的是花分类数据集,下载地址:
[
https://storage.googleapis.com/download.tensorflow.org/example_images/flower_photos.tgz
](
https://storage.googleapis.com/download.tensorflow.org/example_images/flower_photos.tgz
)
测试数据使用的是
[
flower_photos
](
https://storage.googleapis.com/download.tensorflow.org/example_images/flower_photos.tgz
)
,使用的加速卡是DCU Z100
2.
在
`train.py`
脚本中将
`--data-path`
设置成解压后的
`flower_photos`
文件夹绝对路径
3.
下载预训练权重,在
`vit_model.py`
文件中每个模型都有提供预训练权重的下载地址,根据自己使用的模型下载对应预训练权重
| Engine | Model Path| Data | Accuracy(%) |
4.
在
`train.py`
脚本中将
`--weights`
参数设成下载好的预训练权重路径
| :------: | :------: | :------: | :------: |
5.
设置好数据集的路径
`--data-path`
以及预训练权重的路径
`--weights`
就能使用
`train.py`
脚本开始训练了(训练过程中会自动生成
`class_indices.json`
文件)
| Pythorch | models/model.onnx | daisy | 98.4 |
6.
在
`predict.py`
脚本中导入和训练脚本中同样的模型,并将
`model_weight_path`
设置成训练好的模型权重路径(默认保存在weights文件夹下)
| Pythorch | models/model.onnx | dandelion | 98.2 |
7.
在
`predict.py`
脚本中将
`img_path`
设置成你自己需要预测的图片绝对路径
| Pythorch | models/model.onnx | roses | 90.0 |
8.
设置好权重路径
`model_weight_path`
和预测的图片路径
`img_path`
就能使用
`predict.py`
脚本进行预测了
| Pythorch | models/model.onnx | sunflowers | 97.4 |
9.
如果要使用自己的数据集,请按照花分类数据集的文件结构进行摆放(即一个类别对应一个文件夹),并且将训练以及预测脚本中的
`num_classes`
设置成你自己数据的类别数
| Pythorch | models/model.onnx | tulips | 95.4 |
| MIGraphX | models/model.onnx | daisy | 98.4 |
| MIGraphX | models/model.onnx | dandelion | 98.8 |
| MIGraphX | models/model.onnx | roses | 91.3 |
| MIGraphX | models/model.onnx | sunflowers | 97.4 |
| MIGraphX | models/model.onnx | tulips | 95.0 |
## 源码仓库及问题反馈
https://developer.hpccube.com/codes/modelzoo/vit_migraphx.git
README.md
View file @
ee6c50a4
...
@@ -71,7 +71,7 @@ tar -zxvf flower_photos.tgz
...
@@ -71,7 +71,7 @@ tar -zxvf flower_photos.tgz
| MIGraphX | models/model.onnx | sunflowers | 97.4 |
| MIGraphX | models/model.onnx | sunflowers | 97.4 |
| MIGraphX | models/model.onnx | tulips | 94.1 |
| MIGraphX | models/model.onnx | tulips | 94.1 |
##
历史版本
##
源码仓库及问题反馈
https://developer.hpccube.com/codes/modelzoo/vit_migraphx.git
https://developer.hpccube.com/codes/modelzoo/vit_migraphx.git
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment