-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
modify finetune tutorial #184
Conversation
@@ -41,20 +43,18 @@ | |||
```shell | |||
python examples/finetune_SHWD/convert_shwd2yolo.py --root_dir /path_to_shwd/SHWD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
放下你的数据集长啥样,怎么转换的,关键代码直接贴上去
@@ -48,7 +48,7 @@ def train_shwd(args): | |||
ema = EMA(network, ema_network) | |||
else: | |||
ema = None | |||
load_pretrain(network, args.weight, ema, args.ema_weight) # load pretrain | |||
load_pretrain(network, args.weight, ema, args.ema_weight, strict=False) # load pretrain |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个文件能不要吗,直接复用mindyolo的train的脚本
examples/finetune_SHWD/README.md
Outdated
|
||
由于SHWD数据集只有7000+张图片,选择yolov7-tiny进行该数据集的训练,可下载MindYOLO提供的在coco数据集上训练好的[模型文件](https://github.com/mindspore-lab/mindyolo/blob/master/MODEL_ZOO.md)作为预训练模型。由于coco数据集含有80种物体类别,SHWD数据集只有两类,模型的最后一层head层输出与类别数nc有关,因此需将预训练模型文件的最后一层去掉, 可参考[convert_yolov7-tiny_pretrain_ckpt.py](./convert_yolov7-tiny_pretrain_ckpt.py)。运行方式如下: | ||
#### 编写yaml配置文件 | ||
配置文件主要包含原数据地址、数据增强、loss、optimizer、模型结构涉及的相应参数,可参考[yolov7-tiny_shwd.yaml](./yolov7-tiny_shwd.yaml)。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不要写参考xxx,较原始的yolov7的训练文件有啥差别贴上去,最后再放个示例的链接
python examples/finetune_SHWD/convert_yolov7-tiny_pretrain_ckpt.py | ||
``` | ||
#### 下载预训练模型(建议) | ||
可选用MindYOLO提供的[MODEL_ZOO](../../MODEL_ZOO.md)作为自定义数据集的预训练模型,预训练模型在COCO数据集上已经有较好的精度表现,相比从头训练,加载预训练模型一般会拥有更快的收敛速度以及更高的最终精度,并且大概率能避免初始化不当导致的梯度消失、梯度爆炸等问题。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个不是建议,finetune的教程这步是必须的
|
||
自定义数据集类别数通常与COCO数据集不一致,MindYOLO中各模型的检测头head结构跟数据集类别数有关,直接将预训练模型导入可能会因为shape不一致而导入失败,可以在yaml配置文件中设置strict_load参数为False,MindYOLO将自动舍弃shape不一致的参数,并抛出该module参数并未导入的告警 | ||
#### 模型微调(Finetune) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这步需要注意哪些地方,学习率,batchsize啥的可能要调试的说清楚
examples/finetune_SHWD/README.md
Outdated
'../../configs/yolov7/yolov7-tiny.yaml', | ||
] | ||
|
||
per_batch_size: 16 # 16 * 8 = 128 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
per_batch_size: 16 # 单卡batchsize,总的batchsize=per_batch_size * device_num
examples/finetune_SHWD/README.md
Outdated
per_batch_size: 16 # 16 * 8 = 128 | ||
img_size: 640 # image sizes | ||
weight: ./yolov7-tiny_pretrain.ckpt | ||
strict_load: False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strict_load: False # 是否按严格加载ckpt内参数,默认True,若设成False,当分类数不一致,丢掉最后一层分类器的weight
examples/finetune_SHWD/README.md
Outdated
img_size: 640 # image sizes | ||
weight: ./yolov7-tiny_pretrain.ckpt | ||
strict_load: False | ||
log_interval: 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log_interval: 10 # 每log_interval次迭代打印一次loss结果
examples/finetune_SHWD/README.md
Outdated
|
||
data: | ||
dataset_name: shwd | ||
train_set: ./SHWD/train.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
train_set: ./SHWD/train.txt # 实际训练数据路径
examples/finetune_SHWD/README.md
Outdated
train_set: ./SHWD/train.txt | ||
val_set: ./SHWD/val.txt | ||
test_set: ./SHWD/val.txt | ||
nc: 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nc: 2 # 分类数
examples/finetune_SHWD/README.md
Outdated
test_set: ./SHWD/val.txt | ||
nc: 2 | ||
# class names | ||
names: [ 'person', 'hat' ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
names: [ 'person', 'hat' ] # 每一类的名字
Thank you for your contribution to the MindYOLO repo.
Before submitting this PR, please make sure:
Motivation
(Write your motivation for proposed changes here.)
Test Plan
(How should this PR be tested? Do you require special setup to run the test or repro the fixed bug?)
Related Issues and PRs
(Is this PR part of a group of changes? Link the other relevant PRs and Issues here. Use https://help.github.com/en/articles/closing-issues-using-keywords for help on GitHub syntax)