mirror of https://github.com/open-mmlab/mmyolo.git
[CodeCamp] Add docs about how to freeze the weight of backbone or neck (#418)
* Add docs about how to freeze the weight of backbone or neck * refine the docs * refine the docs * refine the docspull/408/head^2
parent
b1f7e80fe3
commit
14d9cab354
|
@ -351,6 +351,31 @@ model = dict(
|
|||
)
|
||||
```
|
||||
|
||||
#### Freeze the weight of backbone or neck
|
||||
|
||||
In MMYOLO, we can freeze some `stages` of the backbone network by setting `frozen_stages` parameters, so that these `stage` parameters do not participate in model updating.
|
||||
It should be noted that `frozen_stages = i` means that all parameters from the initial `stage` to the `i`<sup>th</sup> `stage` will be frozen. The following is an example of `YOLOv5`. Other algorithms are the same logic.
|
||||
|
||||
```python
|
||||
_base_ = './yolov5_s-v61_syncbn_8xb16-300e_coco.py'
|
||||
|
||||
model = dict(
|
||||
backbone=dict(
|
||||
frozen_stages=1 # Indicates that the parameters in the first stage and all stages before it are frozen
|
||||
))
|
||||
```
|
||||
|
||||
In addition, it's able to freeze the whole `neck` with the parameter `freeze_all` in MMYOLO. The following is an example of `YOLOv5`. Other algorithms are the same logic.
|
||||
|
||||
```python
|
||||
_base_ = './yolov5_s-v61_syncbn_8xb16-300e_coco.py'
|
||||
|
||||
model = dict(
|
||||
neck=dict(
|
||||
freeze_all=True # If freeze_all=True, all parameters of the neck will be frozen
|
||||
))
|
||||
```
|
||||
|
||||
## Output prediction results
|
||||
|
||||
If you want to save the prediction results as a specific file for offline evaluation, MMYOLO currently supports both json and pkl formats.
|
||||
|
|
|
@ -355,6 +355,31 @@ model = dict(
|
|||
)
|
||||
```
|
||||
|
||||
#### 冻结 backbone 或 neck 的权重
|
||||
|
||||
在 MMYOLO 中我们可以通过设置 `frozen_stages` 参数去冻结主干网络的部分 `stage`, 使这些 `stage` 的参数不参与模型的更新。
|
||||
需要注意的是:`frozen_stages = i` 表示的意思是指从最开始的 `stage` 开始到第 `i` 层 `stage` 的所有参数都会被冻结。下面是 `YOLOv5` 的例子,其他算法也是同样的逻辑:
|
||||
|
||||
```python
|
||||
_base_ = './yolov5_s-v61_syncbn_8xb16-300e_coco.py'
|
||||
|
||||
model = dict(
|
||||
backbone=dict(
|
||||
frozen_stages=1 # 表示第一层 stage 以及它之前的所有 stage 中的参数都会被冻结
|
||||
))
|
||||
```
|
||||
|
||||
此外, MMYOLO 中也可以通过参数 `freeze_all` 去冻结整个 `neck` 的参数。下面是 `YOLOv5` 的例子,其他算法也是同样的逻辑:
|
||||
|
||||
```python
|
||||
_base_ = './yolov5_s-v61_syncbn_8xb16-300e_coco.py'
|
||||
|
||||
model = dict(
|
||||
neck=dict(
|
||||
freeze_all=True # freeze_all=True 时表示整个 neck 的参数都会被冻结
|
||||
))
|
||||
```
|
||||
|
||||
## 输出预测结果
|
||||
|
||||
如果想将预测结果保存为特定的文件,用于离线评估,目前 MMYOLO 支持 json 和 pkl 两种格式。
|
||||
|
|
Loading…
Reference in New Issue