-
Notifications
You must be signed in to change notification settings - Fork 48
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
add augmentation and training process tutorial #173
Conversation
@@ -0,0 +1,74 @@ | |||
## 数据增强--工具箱自带 |
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.
数据增强就行了
@@ -0,0 +1,74 @@ | |||
## 数据增强--工具箱自带 | |||
- 以configs/yolov7/hyp.scratch.tiny.yaml中的data.train_transforms为例. |
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.
建议加个表格说明目前套件里已有的数据增强方法
@@ -0,0 +1,74 @@ | |||
## 数据增强--工具箱自带 | |||
- 以configs/yolov7/hyp.scratch.tiny.yaml中的data.train_transforms为例. | |||
它指定了一组应用于图像或标签的数据增强操作,用以生成作为模型输入或损失函数输入的数据。这些数据增强函数定义在 **mindyolo/data/dataset.py** 中。 |
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.
行文的话以
- 套件支持的数据增强方法(表格列举)
- 怎样使用(可以加一下可视化的效果)
- 自定义数据增强
docs/en/tutorials/train_process.md
Outdated
@@ -0,0 +1,175 @@ | |||
# 深度学习Train and Eval 流程解析 |
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.
流程 图示?
- 组件构建(网络,data,loss,opt)
- 训练网络、推理网络构建
- 训练、推理(callback,data sink,分布式)
怎样进行训练、推理
- 参数,介绍
- 加一下机制说明(以写config的行文逻辑加?)
# 数据准备 | ||
|
||
|
||
{% include-markdown "../../../tutorials/custom_dataset.md" %} |
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.
下载coco2017 YOLO格式 coco2017labels-segments 以及coco2017 原始图片 train2017 , val2017 ,然后将coco2017 原始图片放到coco2017 YOLO格式 images目录下:
└─ coco2017_yolo
├─ annotations
└─ instances_val2017.json
├─ images
├─ train2017 # coco2017 原始图片
└─ val2017 # coco2017 原始图片
├─ labels
├─ train2017
└─ val2017
├─ train2017.txt
├─ val2017.txt
└─ test-dev2017.txt
docs/zh/tutorials/train_process.md
Outdated
@@ -112,9 +135,14 @@ create_train_step_fn用来接收网络、损失函数、优化器等参数,定 | |||
args.callback.append({"name": "ProfilerCallback", "profiler_step_num": args.profiler_step_num}) | |||
callback_fns = create_callback(args.callback) | |||
``` | |||
创建回调函数列表。其中summary参数表示是否收集训练loss信息,profiler参数表示是否收集性能数据。 | |||
创建回调函数列表,这些回调函数可以在训练时被调用,以帮助监控和调整模型。其中summary参数表示是否收集训练loss信息,profiler参数表示是否收集性能数据。 |
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.
如果有 高阶开发者 模块,可以把yolox 的二阶段训练hook作为案例加进去
@@ -0,0 +1,74 @@ | |||
## 数据增强--工具箱自带 |
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.
这个删掉
docs/en/tutorials/train_process.md
Outdated
@@ -0,0 +1,175 @@ | |||
# 深度学习Train and Eval 流程解析 |
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.
无效的文件都先删掉
@@ -0,0 +1,3 @@ | |||
# 自定义数据增强 |
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.
不加这个章节了吧,数据增强的都放一起就行
@@ -0,0 +1,7 @@ | |||
|
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.
同上,有一个就行,不要链来链去的
| image_norm | 图像数据标准化 | | ||
| image_transpose | 通道转置和维度转置 | | ||
| albumentations | albumentations数据增强 | | ||
|
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/data/dataset.py 中。
- {func_name: image_norm, scale: 255.} | ||
- {func_name: image_transpose, bgr2rgb: True, hwc2chw: True} | ||
``` | ||
_注意:func_name表示数据增强方法名,prob,mosaic9_prob,translate,scale为该方法参数。 其中prob为所有方法均有的参数,表示该数据增强方法的执行概率,默认值为1_ |
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数据增强方法通过在yaml文件里配置。例如,训练过程添加一个数据增强,需要在配置文件train_transforms
字段下添加一个字典列表,数据增强方法自上而下依次罗列。一个典型的数据增强方法配置字典里必须有func_name
,表示应用的数据增强方法名,而后罗列该方法需要设置的参数,若没有在数据增强配置字典中配置参数项,则会选择该数据增强方法默认的数值。
数据增强通用配置字典:
- {func_name: 数据增强方法名1, args11=x11, args12=x12, ..., args1n=x1n}
- {func_name: 数据增强方法名2, args21=x21, args22=x22, ..., args2n=x2n}
......
- {func_name: 数据增强方法名n, argsn1=xn1, argsn2=xn2, ..., argsnn=xnn}
以YOLOv7训练数据增强示例:
train_transforms:
- {func_name: mosaic, prob: 1.0, mosaic9_prob: 0.2, translate: 0.1, scale: 0.5}
- {func_name: mixup, prob: 0.05, alpha: 8.0, beta: 8.0, needed_mosaic: True}
- {func_name: hsv_augment, prob: 1.0, hgain: 0.015, sgain: 0.7, vgain: 0.4}
- {func_name: pastein, prob: 0.05, num_sample: 30}
- {func_name: label_norm, xyxy2xywh_: True}
- {func_name: fliplr, prob: 0.5}
- {func_name: label_pad, padding_size: 160, padding_value: -1}
- {func_name: image_norm, scale: 255.}
- {func_name: image_transpose, bgr2rgb: True, hwc2chw: True}
|
||
- `image_transpose`:将输入的图片从BGR格式转换为RGB格式,并将图片的通道数从HWC格式转换为CHW格式。 | ||
|
||
对于测试数据增强函数 |
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.
测试数据增强需要用test_transforms
字段标注,配置方法同训练。
下面的删掉就行
- 在[mindyolo/data/dataset.py](https://github.com/mindspore-lab/mindyolo/blob/master/mindyolo/data/dataset.py)文件COCODataset类中添加自定义数据增强方法 | ||
- 数据增强方法的输入通常包含图片、标签和自定义参数。 | ||
- 编写函数体内容,自定义输出 | ||
|
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/data/dataset.py COCODataset 添加子方法
def data_trans_func(self, image, labels, args1=x1, args2=x2, ..., argsn=xn):
# 数据增强逻辑
......
return image, labels
tutorials/custom_dataset.md
Outdated
@@ -1,25 +1,22 @@ | |||
# 数据集格式介绍 | |||
|
|||
适用于MindYOLO的数据集格式具有如下形式: |
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.
语句不通
docs/zh/tutorials/train_process.md
Outdated
@@ -0,0 +1,185 @@ | |||
# 深度学习Train and Eval 流程解析 |
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.
这章本次先不合,还得再看下怎么写这个逻辑
tutorials/custom_dataset.md
Outdated
@@ -1,25 +1,22 @@ | |||
# 数据集格式介绍 |
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.
这个文件和上面的那个是啥关系?留一个就行,把文档里的链接换成新的
add augmentation and training process tutorial second verison remove train process tutorial add callback tutorial delete duplicate /custom_dataset.md reformat
``` | ||
例如以YOLOX为示例: | ||
|
||
在mindyolo/utils/callback.py文件YoloxSwitchTrain类中on_train_step_begin方法里面添加逻辑,打印“train step begin”的日志 |
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.
此处应当描述这个callback的主要功能: 切换训练阶段,而不是打印日志。这会让读者迷惑,为啥弄这么fancy单单为了打印日志
pass | ||
|
||
``` | ||
YOLOX对应的yaml文件configs/yolox/hyp.scratch.yaml的callback字段下添加该回调函数 |
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.
同上
```python | ||
#mindyolo/utils/callback.py | ||
@CALLBACK_REGISTRY.registry_module() | ||
class callback_class_name(BaseCallback): |
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.
大致说下6个挂载点分别在什么位置;
- { name: callback_class_name, args: xx } | ||
- { name: callback_class_name2, args: xx } | ||
``` | ||
例如以YOLOX为示例: |
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.
说下子类继承父类的全部挂载点,需要在那个挂载点添加自定义操作就重写哪个,不重写则不会添加任何操作
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)