mirror of https://github.com/open-mmlab/mmyolo.git
[Docs] Refine config.md (#191)
* Refine __delete__ example in config.md * Add missing docstring in cspnext.py * Refine docstring of cspnext * Correct the description of param_scheduler * Refine description param_scheduler in config.md * Update docs/zh_cn/user_guides/config.md Co-authored-by: Haian Huang(深度眸) <1286304229@qq.com> Co-authored-by: Haian Huang(深度眸) <1286304229@qq.com>pull/249/head
parent
2f5d16f5f1
commit
75997fcd60
|
@ -286,7 +286,7 @@ optim_wrapper = dict( # Optimizer wrapper config
|
|||
constructor='YOLOv5OptimizerConstructor') # The constructor for YOLOv5 optimizer
|
||||
```
|
||||
|
||||
`param_scheduler` is the field that configures methods of adjusting optimization hyperparameters such as learning rate and momentum. Users can combine multiple schedulers to create a desired parameter adjustment strategy. Find more in the [parameter scheduler tutorial](https://mmengine.readthedocs.io/en/latest/tutorials/param_scheduler.html). In MMYOLO, no parameter optimizer is introduced.
|
||||
`param_scheduler` is the field that configures methods of adjusting optimization hyperparameters such as learning rate and momentum. Users can combine multiple schedulers to create a desired parameter adjustment strategy. Find more in the [parameter scheduler tutorial](https://mmengine.readthedocs.io/en/latest/tutorials/param_scheduler.html). In YOLOv5, parameter scheduling is complex to implement and difficult to implement with `param_scheduler`. So we use `YOLOv5ParamSchedulerHook` to implement it (see next section), which is simpler but less versatile.
|
||||
|
||||
```python
|
||||
param_scheduler = None
|
||||
|
@ -387,26 +387,29 @@ If you wish to inspect the config file, you may run `mim run mmdet print_config
|
|||
Sometimes, you may set `_delete_=True` to ignore some of the fields in base configs.
|
||||
You may refer to the [mmengine config tutorial](https://mmengine.readthedocs.io/en/latest/tutorials/config.html) for a simple illustration.
|
||||
|
||||
In MMYOLO, for example, to change the backbone of YOLOv5 with the following config.
|
||||
In MMYOLO, for example, to change the backbone of RTMDet with the following config.
|
||||
|
||||
```python
|
||||
model = dict(
|
||||
type='YOLODetector',
|
||||
data_preprocessor=dict(...),
|
||||
backbone=dict(
|
||||
type='YOLOv5CSPDarknet',
|
||||
type='CSPNeXt',
|
||||
arch='P5',
|
||||
expand_ratio=0.5,
|
||||
deepen_factor=deepen_factor,
|
||||
widen_factor=widen_factor,
|
||||
norm_cfg=dict(type='BN', momentum=0.03, eps=0.001),
|
||||
channel_attention=True,
|
||||
norm_cfg=dict(type='BN'),
|
||||
act_cfg=dict(type='SiLU', inplace=True)),
|
||||
neck=dict(...),
|
||||
bbox_head=dict(...))
|
||||
```
|
||||
|
||||
The `_delete_=True` would replace all old keys in the `backbone` field with new keys. For example, `YOLOv5` uses `YOLOv5CSPDarknet`, it is necessary to replace the backbone with `YOLOv6EfficientRep`. Since `YOLOv5CSPDarknet` and `YOLOv6EfficientRep` have different fields, you need to use `_delete_=True` to replace all old keys in the `backbone` field.
|
||||
If you want to change `CSPNeXt` to `YOLOv6EfficientRep` for the RTMDet backbone, because there are different fields (`channel_attention` and `expand_ratio`) in `CSPNeXt` and `YOLOv6EfficientRep`, you need to use `_delete_=True` to replace all the old keys in the `backbone` field with the new keys.
|
||||
|
||||
```python
|
||||
_base_ = '../yolov5/yolov5_s-v61_syncbn_8xb16-300e_coco.py'
|
||||
_base_ = '../rtmdet/rtmdet_l_syncbn_8xb32-300e_coco.py'
|
||||
model = dict(
|
||||
backbone=dict(
|
||||
_delete_=True,
|
||||
|
|
|
@ -287,7 +287,7 @@ optim_wrapper = dict( # 优化器封装的配置
|
|||
|
||||
```
|
||||
|
||||
`param_scheduler` 字段用于配置参数调度器(Parameter Scheduler)来调整优化器的超参数(例如学习率和动量)。 用户可以组合多个调度器来创建所需的参数调整策略。 在[参数调度器教程](https://mmengine.readthedocs.io/zh_CN/latest/tutorials/param_scheduler.html) 和参数调度器 API 文档 中查找更多信息。在 MMYOLO 中,未引入任何参数调度器。
|
||||
`param_scheduler` 字段用于配置参数调度器(Parameter Scheduler)来调整优化器的超参数(例如学习率和动量)。 用户可以组合多个调度器来创建所需的参数调整策略。 在[参数调度器教程](https://mmengine.readthedocs.io/zh_CN/latest/tutorials/param_scheduler.html) 和参数调度器 API 文档 中查找更多信息。在 YOLOv5 中,参数调度实现比较复杂,难以通过 `param_scheduler` 实现。所以我们采用了 `YOLOv5ParamSchedulerHook` 来实现(见下节),这样做更简单但是通用性较差。
|
||||
|
||||
```python
|
||||
param_scheduler = None
|
||||
|
@ -386,26 +386,29 @@ _base_ = [
|
|||
|
||||
有时,您也许会设置 `_delete_=True` 去忽略基础配置文件里的一些域内容。 您也许可以参照 [MMEngine 配置文件教程](https://mmengine.readthedocs.io/en/latest/tutorials/config.html) 来获得一些简单的指导。
|
||||
|
||||
在 MMYOLO 里,例如为了改变 YOLOv5 的主干网络的某些内容:
|
||||
在 MMYOLO 里,例如为了改变 RTMDet 的主干网络的某些内容:
|
||||
|
||||
```python
|
||||
model = dict(
|
||||
type='YOLODetector',
|
||||
data_preprocessor=dict(...),
|
||||
backbone=dict(
|
||||
type='YOLOv5CSPDarknet',
|
||||
type='CSPNeXt',
|
||||
arch='P5',
|
||||
expand_ratio=0.5,
|
||||
deepen_factor=deepen_factor,
|
||||
widen_factor=widen_factor,
|
||||
norm_cfg=dict(type='BN', momentum=0.03, eps=0.001),
|
||||
channel_attention=True,
|
||||
norm_cfg=dict(type='BN'),
|
||||
act_cfg=dict(type='SiLU', inplace=True)),
|
||||
neck=dict(...),
|
||||
bbox_head=dict(...))
|
||||
```
|
||||
|
||||
基础配置的 `YOLOv5` 使用 `YOLOv5CSPDarknet`,在需要将主干网络改成 `YOLOv6EfficientRep` 的时候,因为 `YOLOv5CSPDarknet` 和 `YOLOv6EfficientRep` 中有不同的字段,需要使用 `_delete_=True` 将新的键去替换 `backbone` 域内所有老的键。
|
||||
如果想把 RTMDet 主干网络的 `CSPNeXt` 改成 `YOLOv6EfficientRep`,因为 `CSPNeXt` 和 `YOLOv6EfficientRep` 中有不同的字段(`channel_attention` 和 `expand_ratio`),这时候就需要使用 `_delete_=True` 将新的键去替换 `backbone` 域内所有老的键。
|
||||
|
||||
```python
|
||||
_base_ = '../yolov5/yolov5_s-v61_syncbn_8xb16-300e_coco.py'
|
||||
_base_ = '../rtmdet/rtmdet_l_syncbn_8xb32-300e_coco.py'
|
||||
model = dict(
|
||||
backbone=dict(
|
||||
_delete_=True,
|
||||
|
|
|
@ -28,12 +28,13 @@ class CSPNeXt(BaseBackbone):
|
|||
frozen_stages (int): Stages to be frozen (stop grad and set eval
|
||||
mode). -1 means not freezing any parameters. Defaults to -1.
|
||||
plugins (list[dict]): List of plugins for stages, each dict contains:
|
||||
|
||||
- cfg (dict, required): Cfg dict to build plugin.
|
||||
- cfg (dict, required): Cfg dict to build plugin.Defaults to
|
||||
- stages (tuple[bool], optional): Stages to apply plugin, length
|
||||
should be same as 'num_stages'.
|
||||
use_depthwise (bool): Whether to use depthwise separable convolution.
|
||||
Defaults to False.
|
||||
expand_ratio (float): Ratio to adjust the number of channels of the
|
||||
hidden layer. Defaults to 0.5.
|
||||
arch_ovewrite (list): Overwrite default arch settings.
|
||||
Defaults to None.
|
||||
channel_attention (bool): Whether to add channel attention in each
|
||||
|
|
|
@ -27,7 +27,7 @@ class CSPNeXtPAFPN(BaseYOLONeck):
|
|||
use_depthwise (bool): Whether to use depthwise separable convolution in
|
||||
blocks. Defaults to False.
|
||||
expand_ratio (float): Ratio to adjust the number of channels of the
|
||||
hidden layer. Default: 0.5
|
||||
hidden layer. Defaults to 0.5.
|
||||
upsample_cfg (dict): Config dict for interpolate layer.
|
||||
Default: `dict(scale_factor=2, mode='nearest')`
|
||||
conv_cfg (dict, optional): Config dict for convolution layer.
|
||||
|
|
Loading…
Reference in New Issue