diff --git a/docs/zh/how_to_guides/callback.md b/docs/zh/how_to_guides/callback.md index e69de29b..a5cb2fae 100644 --- a/docs/zh/how_to_guides/callback.md +++ b/docs/zh/how_to_guides/callback.md @@ -0,0 +1,46 @@ +# MindYOLO回调函数用法 + +**回调函数**:当程序运行到某个挂载点时,会自动调用在运行时注册到该挂载点的所有方法。 +通过回调函数的形式可以增加程序的灵活性和扩展性,因为用户可以将自定义方法注册到要调用的挂载点,而无需修改程序中的代码。 + +在MindYOLO中,回调函数具体实现在mindyolo/utils/callback.py文件中。 +```python +#mindyolo/utils/callback.py +@CALLBACK_REGISTRY.registry_module() +class callback_class_name(BaseCallback): + + def __init__(self, **kwargs): + super().__init__() + ... + def callback_fn_name(self, run_context: RunContext): + pass +``` + +通过模型的yaml文件callback字段下添加一个字典列表来实现调用 +```yaml +#回调函数配置字典: +callback: + - { name: callback_class_name, args: xx } + - { name: callback_class_name2, args: xx } +``` +例如以YOLOX为示例: + +在mindyolo/utils/callback.py文件YoloxSwitchTrain类中on_train_step_begin方法里面添加逻辑,打印“train step begin”的日志 +```python +@CALLBACK_REGISTRY.registry_module() +class YoloxSwitchTrain(BaseCallback): + + def on_train_step_begin(self, run_context: RunContext): + # 自定义逻辑 + logger.info("train step begin") + pass + +``` +YOLOX对应的yaml文件configs/yolox/hyp.scratch.yaml的callback字段下添加该回调函数 +```yaml +callback: + - { name: YoloxSwitchTrain, switch_epoch_num: 285 } +``` +则每个训练step执行前都会执行logger.info("train step begin")语句。 + +借助回调函数,用户可以自定义某个挂载点需要执行的逻辑,而无需理解完整的训练流程的代码。 \ No newline at end of file diff --git a/docs/zh/how_to_guides/data_preparation.md b/docs/zh/how_to_guides/data_preparation.md index 8308b5c4..3cbdcd94 100644 --- a/docs/zh/how_to_guides/data_preparation.md +++ b/docs/zh/how_to_guides/data_preparation.md @@ -1,9 +1,6 @@ - - # 数据准备 -# 数据集格式介绍 - +## 数据集格式介绍 下载coco2017 YOLO格式 [coco2017labels-segments](https://github.com/ultralytics/yolov5/releases/download/v1.0/coco2017labels-segments.zip) 以及coco2017 原始图片 [train2017](http://images.cocodataset.org/zips/train2017.zip) , [val2017](http://images.cocodataset.org/zips/val2017.zip) ,然后将coco2017 原始图片放到coco2017 YOLO格式 images目录下: ``` @@ -40,7 +37,6 @@ detect格式:通常每行有5列,分别对应类别id以及标注框归一 63 0.197190 0.364053 0.394380 0.669653 39 0.932330 0.226240 0.034820 0.076640 ``` - segment格式:每行第一个数据为类别id,后续为两两成对的归一化坐标点x,y ``` @@ -54,7 +50,6 @@ segment格式:每行第一个数据为类别id,后续为两两成对的归 49 0.716891 0.0519583 0.683766 0.0103958 0.611688 0.0051875 0.568828 0.116875 0.590266 0.15325 0.590266 0.116875 0.613641 0.0857083 0.631172 0.0857083 0.6565 0.083125 0.679875 0.0883125 0.691563 0.0961042 0.711031 0.0649375 ``` - instances_val.json为coco格式的验证集标注,可直接调用coco api用于map的计算。 训练&推理时,需修改`configs/coco.yaml`中的`train_set`,`val_set`,`test_set`为真实数据路径 diff --git a/docs/zh/tutorials/data_augmentation.md b/docs/zh/tutorials/data_augmentation.md index 11cbce13..81d10c9a 100644 --- a/docs/zh/tutorials/data_augmentation.md +++ b/docs/zh/tutorials/data_augmentation.md @@ -36,8 +36,6 @@ MindYOLO数据增强方法通过在yaml文件里配置。例如,训练过程 ``` 以YOLOv7训练数据增强示例: - - ```yaml # 文件目录:configs/yolov7/hyp.scratch.tiny.yaml (https://github.com/mindspore-lab/mindyolo/blob/master/configs/yolov7/hyp.scratch.tiny.yaml) train_transforms: @@ -77,7 +75,6 @@ _注意:func_name表示数据增强方法名,prob,mosaic9_prob,translate 测试数据增强需要用test_transforms字段标注,配置方法同训练。 - ## 自定义数据增强 编写指南: