-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 tutuorial of config #487
Conversation
Codecov Report
@@ Coverage Diff @@
## master #487 +/- ##
==========================================
+ Coverage 77.96% 78.77% +0.81%
==========================================
Files 102 103 +1
Lines 5619 5702 +83
Branches 923 927 +4
==========================================
+ Hits 4381 4492 +111
+ Misses 1111 1088 -23
+ Partials 127 122 -5
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
docs/tutorials/config.md
Outdated
@@ -0,0 +1,380 @@ | |||
# Tutorial 1:Learn about Configs | |||
|
|||
MMCls uses python files as configs. The design of our configuration file system integrates modularity and inheritance, facilitating users to conduct various experiments. All configuration files are placed in the `$MMCls/configs` folder, which mainly contains the original configuration folder of `_base_` and many algorithm folders such as `resnet`, `swin_transformer`, `vision_transformer`, etc. |
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.
Best to use MMClassification
.
And we support not only python files, but YAML files and JSON files, which refer to mmcv docs, but the most common config format is python files.
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.
$MMcls
is confusing and not necessary.
docs/tutorials/config.md
Outdated
|
||
## Config File Naming Convention | ||
|
||
We follow the below convention to name config files. Contributors are advised to follow the same style。The config file names are divided into four parts: model information, module information, training information and data information. Logically, different parts are concatenated by underscores `'_'`, and words in the same part are concatenated by dashes `'-'`. |
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/tutorials/config.md
Outdated
- `seresnext101-32x4d` : `SeResNet101` network structure, `32x4d` means that `groups` and `width_per_group` are 32 and 4 respectively in `Bottleneck`; | ||
|
||
### module information | ||
Refers to some special `neck`, `head` or `pretrain` information, which is commonly used as pretraining information in classification tash: |
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.
Refers to some special `neck`, `head` or `pretrain` information, which is commonly used as pretraining information in classification tash: | |
Some special `neck`, `head` and `pretrain` information. In classification tasks, `pretrain` information is the most commonly used: |
docs/tutorials/config.md
Outdated
- `training info`:Training information, some training schedule, including batch size, lr schedule, data augment and the like; | ||
- `data info`:Data information, dataset name, input size and so on, such as imagenet, cifar; | ||
|
||
### model information |
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.
Use upper case
### model information | |
### Model information |
docs/tutorials/config.md
Outdated
- `ft` : Configuration file for fine-tuning | ||
- `pt` : Configuration file for pretraining | ||
|
||
Training strategy information, the training strategy is based on the recurrence profile, and the basic training strategy does not need to be marked. However, if improvements are made on this basis, the training strategy needs to be indicated and arranged in the order, such as: `{pipeline aug}-{train aug}-{loss trick}-{scheduler}-{epochs}` |
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.
Training strategy information, the training strategy is based on the recurrence profile, and the basic training strategy does not need to be marked. However, if improvements are made on this basis, the training strategy needs to be indicated and arranged in the order, such as: `{pipeline aug}-{train aug}-{loss trick}-{scheduler}-{epochs}` | |
Training recipe. Usually, only the part that is different from the original paper will be marked. These methods will be arranged in the order `{pipeline aug}-{train aug}-{loss trick}-{scheduler}-{epochs}`. |
docs/tutorials/config.md
Outdated
repvgg-D2se_deploy_4xb64-autoaug-lbs-mixup-coslr-200e_in1k.py | ||
``` | ||
|
||
Among them, `repvgg-D2se` represents algorithm information, `RepVGG` model, `D2se` is structure information; `deploy` represents module information, and this model is in the inference state; `4xb64-autoaug-lbs-mixup-coslr-200e` represents training information, 4 GPUs, the number of batches per GPU is 64, using the `auto augment`, `label smooth` and `cosine scheduler` techniques to train 200 epoches; `in1k` is the data information, which means using `224x224` input image size to train in `ImageNet1k`. |
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.
Among them, `repvgg-D2se` represents algorithm information, `RepVGG` model, `D2se` is structure information; `deploy` represents module information, and this model is in the inference state; `4xb64-autoaug-lbs-mixup-coslr-200e` represents training information, 4 GPUs, the number of batches per GPU is 64, using the `auto augment`, `label smooth` and `cosine scheduler` techniques to train 200 epoches; `in1k` is the data information, which means using `224x224` input image size to train in `ImageNet1k`. | |
- `repvgg-D2se`: Algorithm information | |
+ `repvgg`: The main algorithm. | |
+ `D2se`: The architecture. | |
- `deploy`: Module information, means the backbone is in the deploy state. | |
- `4xb64-autoaug-lbs-mixup-coslr-200e`: Training information. | |
+ `4xb64`: Use 4 GPUs and the size of batches per GPU is 64. | |
+ `autoaug`: Use `AutoAugment` in training pipeline. | |
+ `lbs`: Use label smoothing loss. | |
+ `mixup`: Use `mixup` training augment method. | |
+ `coslr`: Use cosine learning rate scheduler. | |
+ `200e`: Train the model for 200 epoches. | |
- `in1k`: Dataset information. The config is for `ImageNet1k` dataset and the input size is `224x224`. |
docs/tutorials/config.md
Outdated
|
||
## Config File Structure | ||
|
||
There are four kind basic component file in the `configs/_base_` folder, namely: |
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.
There are four kind basic component file in the `configs/_base_` folder, namely: | |
There are four kinds of basic component files in the `configs/_base_` folder, namely: |
docs/tutorials/config.md
Outdated
- [schedules](https://github.com/open-mmlab/mmclassification/tree/master/configs/_base_/schedules) | ||
- [default_runtime](https://github.com/open-mmlab/mmclassification/blob/master/configs/_base_/default_runtime.py) | ||
|
||
Many methods, such as ResNet, Swin_Transformer, ViT, RepVGG and etc, can be easily implemented by combining these components. The configs that are composed by components from `_base_` are called _primitive_. |
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.
Use these components to implement ResNet
or Swin-Transformer
? I think it's a little misleading.
Many methods, such as ResNet, Swin_Transformer, ViT, RepVGG and etc, can be easily implemented by combining these components. The configs that are composed by components from `_base_` are called _primitive_. | |
You can easily build your own training config file by inherit some base config files. And the configs that are composed by components from `_base_` are called _primitive_. |
docs/tutorials/config.md
Outdated
|
||
Many methods, such as ResNet, Swin_Transformer, ViT, RepVGG and etc, can be easily implemented by combining these components. The configs that are composed by components from `_base_` are called _primitive_. | ||
|
||
For easy understanding, we use [ResNet50 primitive config](https://github.com/open-mmlab/mmclassification/blob/master/configs/resnet/ resnet50_b32x8_imagenet.py) as a example and comment the meaning of each line. For more detaile, please refer to the API documentation. |
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.
The link is broken.
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.
Please pay attention to modify the corresponding part of the Chinese documentation
docs/tutorials/config.md
Outdated
|
||
### model | ||
The parameter `"model"` is a python dictionary in the configuration file, which mainly includes information such as network structure and loss function: | ||
- `type` : Classifier name, MMCls supports `ImageClassifier`, refer to [API 文档](https://mmclassification.readthedocs.io/zh_CN/latest/api.html#module-mmcls.models.classifiers)。 |
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.
Do we need to add a note about type
? type
is not an argument, but the class name. Many fresh users may confuse about it.
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.
Change the link to English version
docs/tutorials/config.md
Outdated
### model | ||
The parameter `"model"` is a python dictionary in the configuration file, which mainly includes information such as network structure and loss function: | ||
- `type` : Classifier name, MMCls supports `ImageClassifier`, refer to [API 文档](https://mmclassification.readthedocs.io/zh_CN/latest/api.html#module-mmcls.models.classifiers)。 | ||
- `backbone` : Backbones name, refer to [API document](https://github.com/open-mmlab/mmclassification/blob/master/mmcls/models/backbones) for available options. |
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.
Backbones name
-> Backbone configs
docs/tutorials/config.md
Outdated
type='ImageClassifier', # Classifier name | ||
backbone=dict( | ||
type='ResNet', # Backbones name | ||
depth=50, # depth of backbone, ResNet has optionsof 18, 34, 50, 101, 152. |
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.
,
-> ,
optionsof
-> options of
docs/tutorials/config.md
Outdated
- `train | val | test` : construct dataset | ||
- `type`: Dataset name, MMCls supports `ImageNet`, `Cifar` etc., refer to [API documentation](https://mmclassification.readthedocs.io/zh_CN/latest/api.html#module-mmcls.datasets) | ||
- `data_prefix` : Dataset root directory | ||
- `pipeline` : Data processing pipeline, refer to related tutorial documents [如何设计数据处理流水线](https://mmclassification.readthedocs.io/zh_CN/latest/tutorials/data_pipeline.html) |
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.
Change to English version
docs/tutorials/config.md
Outdated
dict(type='TextLoggerHook'), # The Tensorboard logger is also supported | ||
# dict(type='TensorboardLoggerHook') # also support Tensorboard logger |
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.
Repeated comment
docs/tutorials/config.md
Outdated
|
||
### Use some fields in the base configs | ||
|
||
Sometimes, you can refer to some fields in the `__base__` config, so as to avoid duplication of definitions. You can refer to [mmcv](https://mmcv.readthedocs.io/en/latest/understand_mmcv/config.html#reference-variables-from-base) for some more instructions. |
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.
_base_
instead of __base__
docs/tutorials/config.md
Outdated
|
||
Sometimes, you can refer to some fields in the `__base__` config, so as to avoid duplication of definitions. You can refer to [mmcv](https://mmcv.readthedocs.io/en/latest/understand_mmcv/config.html#reference-variables-from-base) for some more instructions. | ||
|
||
The following is a example of using `auto augment` in the training data preprocessing pipeline, refer to ["configs/_base_/datasets/imagenet_bs64_autoaug.py"](https://github.com/open-mmlab/mmclassification/blob/master/configs/_base_/datasets/imagenet_bs64_autoaug.py). When defining `train_pipeline`, just add the definition file name of `auto augment` to `__base__`, and then use `{{_base_.auto_increasing_policies}}` to reference the variables: |
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.
The following is a example of using `auto augment` in the training data preprocessing pipeline, refer to ["configs/_base_/datasets/imagenet_bs64_autoaug.py"](https://github.com/open-mmlab/mmclassification/blob/master/configs/_base_/datasets/imagenet_bs64_autoaug.py). When defining `train_pipeline`, just add the definition file name of `auto augment` to `__base__`, and then use `{{_base_.auto_increasing_policies}}` to reference the variables: | |
The following is an example of using `auto augment` in the training data preprocessing pipeline, refer to [`configs/_base_/datasets/imagenet_bs64_autoaug.py`](https://github.com/open-mmlab/mmclassification/blob/master/configs/_base_/datasets/imagenet_bs64_autoaug.py). When defining `train_pipeline`, just add the definition file name of `auto augment` to `_base_`, and then use `{{_base_.auto_increasing_policies}}` to reference the variables: |
If use quotes, _base_
will be rendered as base.
docs/tutorials/config.md
Outdated
- `type` : Classifier name, MMCls supports `ImageClassifier`, refer to [API 文档](https://mmclassification.readthedocs.io/zh_CN/latest/api.html#module-mmcls.models.classifiers)。 | ||
- `backbone` : Backbones name, refer to [API document](https://github.com/open-mmlab/mmclassification/blob/master/mmcls/models/backbones) for available options. | ||
- `neck` :Neck network name, MMCls supports `GlobalAveragePooling`, please refer to [API documentation](https://mmclassification.readthedocs.io/zh_CN/latest/api.html#module-mmcls.models.necks). | ||
-`head`: Head network name, MMCls supports single-label and multi-label classification head networks, available options refer to [API 文档](https://github.com/open-mmlab/mmclassification/blob/master/mmcls/models/heads). |
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.
Change to English version
docs/tutorials/config.md
Outdated
@@ -0,0 +1,403 @@ | |||
# Tutorial 1:Learn about Configs |
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.
Use ':' instead of ":"
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.
Done.
Co-authored-by: Ma Zerun <[email protected]>
Co-authored-by: Ma Zerun <[email protected]>
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.
LGTM
* add cn tutorials/config.md * add heads api and doc title link * Update tutorials index * Update tutorials index * Update config.md * add english version * Update config.md * Update docs * Update css * Update docs/tutorials/config.md Co-authored-by: Ma Zerun <[email protected]> * Update docs_zh-CN/tutorials/config.md Co-authored-by: Ma Zerun <[email protected]> * modify according to suggestion * Use GitHub style `code` css * change some mmcv API link to CN version * remove default in default_runtime Co-authored-by: mzr1996 <[email protected]>
Motivation
Add tutuorial of config that let user kown the name suler of config, meanning of lines in config, and how to write a config.
Modification
Add tutuorial of config in doc and doc_zh_CN
Checklist
Before PR:
After PR: