[Docs] Add an ionogram example in MMYOLO application (#643)

* [Fix] fix the config link for rtmdet_tiny

* fir the lint

* upload configs

* [Docs]Add doc for application examples

* [Doc] fix h1 title for ionogram_detection.md

* [Fix] update doc links for project/misc/

* Update links for application_examples in README

* Update links for application_examples in README

* Fix the bad commit caused by a mistake merge.

* Fix unnecessary modification on Table of Contents

* Add description of dataset preparation

* Add description of dataset preparation

* Update dataset analysis and pipeline visualization

* fix line too long

* Update rtmdet_s in the benchmark

* fix typo in the doc

* Replace local ckpt path with url

* Update file tree, check out for spaces

* Beautify configs

* Beautify configs

* Add introduction of annotation tool

* Update rtmdet benchmark

* Update rtmdet configs

* Fix typo

* Add English doc

* Minor revisio

* Fix typo

* Revision - check labels

Co-authored-by: Range King <RangeKingHZ@gmail.com>

* Revision - sentence structure

Co-authored-by: Range King <RangeKingHZ@gmail.com>

* Revision - fix typo

Co-authored-by: Range King <RangeKingHZ@gmail.com>

* Revision - parameters and FLOPs

Co-authored-by: Range King <RangeKingHZ@gmail.com>

* Revision - replace flops with FLOPs

Co-authored-by: Range King <RangeKingHZ@gmail.com>

* Revision - enhance readability

Co-authored-by: Range King <RangeKingHZ@gmail.com>

* Revision - fix typo

Co-authored-by: Range King <RangeKingHZ@gmail.com>

* Revision - correct grammatical errors

Co-authored-by: Range King <RangeKingHZ@gmail.com>

* Revision - enhance

Co-authored-by: Range King <RangeKingHZ@gmail.com>

---------

Co-authored-by: Range King <RangeKingHZ@gmail.com>
pull/662/head
Yijie Zheng 2023-03-13 11:29:37 +08:00 committed by GitHub
parent cbf5a80a44
commit 71fc5670cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 1678 additions and 8 deletions

View File

@ -192,7 +192,7 @@ For different parts from MMDetection, we have also prepared user guides and adva
- [Visualization](docs/en/recommended_topics/visualization.md)
- [Model deployment](docs/en/recommended_topics/deploy/)
- [Troubleshooting steps](docs/en/recommended_topics/troubleshooting_steps.md)
- [MMYOLO industry examples](docs/en/recommended_topics/industry_examples.md)
- [MMYOLO application examples](docs/en/recommended_topics/application_examples/)
- [MM series repo essential basics](docs/en/recommended_topics/mm_basics.md)
- [Dataset preparation and description](docs/en/recommended_topics/dataset_preparation.md)

View File

@ -213,7 +213,7 @@ MMYOLO 用法和 MMDetection 几乎一致,所有教程都是通用的,你也
- [关于可视化的一切](docs/zh_cn/recommended_topics/visualization.md)
- [模型部署流程](docs/zh_cn/recommended_topics/deploy/)
- [常见错误排查步骤](docs/zh_cn/recommended_topics/troubleshooting_steps.md)
- [MMYOLO 产业范例介绍](docs/zh_cn/recommended_topics/industry_examples.md)
- [MMYOLO 应用范例介绍](docs/zh_cn/recommended_topics/application_examples/)
- [MM 系列 Repo 必备基础](docs/zh_cn/recommended_topics/mm_basics.md)
- [数据集准备和说明](docs/zh_cn/recommended_topics/dataset_preparation.md)

View File

@ -21,13 +21,13 @@ You can switch between Chinese and English documents in the top-right corner of
recommended_topics/contributing.md
recommended_topics/model_design.md
recommended_topics/algorithm_descriptions/index.rst
recommended_topics/application_examples/index.rst
recommended_topics/replace_backbone.md
recommended_topics/complexity_analysis.md
recommended_topics/labeling_to_deployment_tutorials.md
recommended_topics/visualization.md
recommended_topics/deploy/index.rst
recommended_topics/troubleshooting_steps.md
recommended_topics/industry_examples.md
recommended_topics/mm_basics.md
recommended_topics/dataset_preparation.md

View File

@ -0,0 +1,7 @@
MMYOLO application examples
********************
.. toctree::
:maxdepth: 1
ionogram_detection.md

View File

@ -0,0 +1,307 @@
# A benchmark for ionogram real-time object detection based on MMYOLO
## Dataset
Digital ionogram is the most important way to obtain real-time ionospheric information.
Ionospheric structure detection is of great research significance for accurate extraction of ionospheric key parameters.
This study utilize 4311 ionograms with different seasons obtained by the Chinese Academy of Sciences in Hainan, Wuhan, and Huailai to establish a dataset. The six structures, including Layer E, Es-l, Es-c, F1, F2, and Spread F are manually annotated using [labelme](https://github.com/wkentaro/labelme). [Dataset Download](https://github.com/VoyagerXvoyagerx/Ionogram_detection/releases/download/Dataset/Iono4311.zip)
<div align=center>
<img width="40%" src="https://user-images.githubusercontent.com/67947949/223638535-c4583d88-aa5a-4f21-b35a-e6e8328c9bd4.jpg"/>
Preview of annotated images
</div>
1. Dataset prepration
After downloading the data, put it in the root directory of the MMYOLO repository, and use `unzip test.zip` (for Linux) to unzip it to the current folder. The structure of the unzipped folder is as follows:
```shell
Iono4311/
├── images
| ├── 20130401005200.png
| └── ...
└── labels
├── 20130401005200.json
└── ...
```
The `images` directory contains input imageswhile the `labels` directory contains annotation files generated by labelme.
2. Convert the dataset into COCO format
Use the script `tools/dataset_converters/labelme2coco.py` to convert labelme labels to COCO labels.
```shell
python tools/dataset_converters/labelme2coco.py --img-dir ./Iono4311/images \
--labels-dir ./Iono4311/labels \
--out ./Iono4311/annotations/annotations_all.json
```
3. Check the converted COCO labels
To confirm that the conversion process went successfully, use the following command to display the COCO labels on the images.
```shell
python tools/analysis_tools/browse_coco_json.py --img-dir ./Iono4311/images \
--ann-file ./Iono4311/annotations/annotations_all.json
```
4. Divide dataset into training set, validation set and test set
Set 70% of the images in the dataset as the training set, 15% as the validation set, and 15% as the test set.
```shell
python tools/misc/coco_split.py --json ./Iono4311/annotations/annotations_all.json \
--out-dir ./Iono4311/annotations \
--ratios 0.7 0.15 0.15 \
--shuffle \
--seed 14
```
The file tree after division is as follows:
```shell
Iono4311/
├── annotations
│ ├── annotations_all.json
│ ├── class_with_id.txt
│ ├── test.json
│ ├── train.json
│ └── val.json
├── classes_with_id.txt
├── images
├── labels
├── test_images
├── train_images
└── val_images
```
## Config files
The configuration files are stored in the directory `/projects/misc/ionogram_detection/`.
1. Dataset analysis
To perform a dataset analysis, a sample of 200 images from the dataset can be analyzed using the `tools/analysis_tools/dataset_analysis.py` script.
```shell
python tools/analysis_tools/dataset_analysis.py projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-100e_ionogram.py \
--out-dir output
```
Part of the output is as follows:
```shell
The information obtained is as follows:
+------------------------------+
| Information of dataset class |
+---------------+--------------+
| Class name | Bbox num |
+---------------+--------------+
| E | 98 |
| Es-l | 27 |
| Es-c | 46 |
| F1 | 100 |
| F2 | 194 |
| Spread-F | 6 |
+---------------+--------------+
```
This indicates that the distribution of categories in the dataset is unbalanced.
<div align=center>
<img width="100%" src="https://user-images.githubusercontent.com/67947949/223640412-4008a0a1-0626-419d-90bf-fb7ce6f26fc9.jpg"/>
Statistics of object sizes for each category
</div>
According to the statistics, small objects are predominant in the E, Es-l, Es-c, and F1 categories, while medium-sized objects are more common in the F2 and Spread F categories.
2. Visualization of the data processing part in the config
Taking YOLOv5-s as an example, according to the `train_pipeline` in the config file, the data augmentation strategies used during training include
- Mosaic augmentation
- Random affine
- Albumentations (include various digital image processing methods)
- HSV augmentation
- Random affine
Use the **'pipeline'** mode of the script `tools/analysis_tools/browse_dataset.py` to obtains all intermediate images in the data pipeline.
```shell
python tools/analysis_tools/browse_dataset.py projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-100e_ionogram.py \
-m pipeline \
--out-dir output
```
<div align=center>
<img src="https://user-images.githubusercontent.com/67947949/223914228-abcd017d-a068-4dcd-9d91-e6b546540060.png"/>
Visualization for intermediate images in the data pipeline
</div>
3. Optimize anchor size
Use the script `tools/analysis_tools/optimize_anchors.py` to obtain prior anchor box sizes suitable for the dataset.
```shell
python tools/analysis_tools/optimize_anchors.py projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-100e_ionogram.py \
--algorithm v5-k-means \
--input-shape 640 640 \
--prior-match-thr 4.0 \
--out-dir work_dirs/dataset_analysis_5_s
```
4. Model complexity analysis
With the config file, the parameters and FLOPs can be calculated by the script `tools/analysis_tools/get_flops.py`. Take yolov5-s as an example:
```shell
python tools/analysis_tools/get_flops.py projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-100e_ionogram.py
```
The following output indicates that the model has 7.947G FLOPs with the input shape (640, 640), and a total of 7.036M learnable parameters.
```shell
==============================
Input shape: torch.Size([640, 640])
Model Flops: 7.947G
Model Parameters: 7.036M
==============================
```
## Train and test
1. Train
**Training visualization**: By following the tutorial of [Annotation-to-deployment workflow for custom dataset](https://mmyolo.readthedocs.io/en/dev/recommended_topics/labeling_to_deployment_tutorials.html#id11), this example uses [wandb](https://wandb.ai/site) to visulize training.
**Debug tricks**: During the process of debugging code, sometimes it is necessary to train for several epochs, such as debugging the validation process or checking whether the checkpoint saving meets expectations. For datasets inherited from `BaseDataset` (such as `YOLOv5CocoDataset` in this example), setting `indices` in the `dataset` field can specify the number of samples per epoch to reduce the iteration time.
```python
train_dataloader = dict(
batch_size=train_batch_size_per_gpu,
num_workers=train_num_workers,
dataset=dict(
_delete_=True,
type='RepeatDataset',
times=1,
dataset=dict(
type=_base_.dataset_type,
indices=200, # set indices=200represent every epoch only iterator 200 samples
data_root=data_root,
metainfo=metainfo,
ann_file=train_ann_file,
data_prefix=dict(img=train_data_prefix),
filter_cfg=dict(filter_empty_gt=False, min_size=32),
pipeline=_base_.train_pipeline)))
```
**Start training**
```shell
python tools/train.py projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-100e_ionogram.py
```
2. Test
Specify the path of the config file and the model to start the test:
```shell
python tools/test.py projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-100e_ionogram.py \
work_dirs/yolov5_s-v61_fast_1xb96-100e_ionogram/xxx
```
## Experiments and results
### Choose a suitable batch size
- Often, the batch size governs the training speed, and the ideal batch size will be the largest batch size supported by the available hardware.
- If the video memory is not yet fully utilized, doubling the batch size should result in a corresponding doubling (or close to doubling) of the training throughput. This is equivalent to maintaining a constant (or nearly constant) time per step as the batch size increases.
- Automatic Mixed Precision (AMP) is a technique to accelerate the training with minimal loss in accuracy. To enable AMP training, add `--amp` to the end of the training command.
Hardware information:
- GPUV100 with 32GB memory
- CPU10-core CPU with 40GB memory
Results
| Model | Epoch(best) | AMP | Batchsize | Num workers | Memory Allocated | Training Time | Val mAP |
| -------- | ----------- | ----- | --------- | ----------- | ---------------- | ------------- | ------- |
| YOLOv5-s | 100(82) | False | 32 | 6 | 35.07% | 54 min | 0.575 |
| YOLOv5-s | 100(96) | True | 32 | 6 | 24.93% | 49 min | 0.578 |
| YOLOv5-s | 100(100) | False | 96 | 6 | 96.64% | 48 min | 0.571 |
| YOLOv5-s | 100(100) | True | 96 | 6 | 54.66% | **37** min | 0.575 |
| YOLOv5-s | 100(90) | True | 144 | 6 | 77.06% | 39 min | 0.573 |
| YOLOv5-s | 200(148) | True | 96 | 6 | 54.66% | 72 min | 0.575 |
| YOLOv5-s | 200(188) | True | 96 | **8** | 54.66% | 67 min | 0.576 |
<div align=center>
<img width="60%" src="https://user-images.githubusercontent.com/67947949/223635966-948c8424-1ba8-4df0-92d7-079029dc1231.png">
The proportion of data loading time to the total time of each step.
</div>
Based on the results above, we can conclude that
- AMP has little impact on the accuracy of the model, but can significantly reduce memory usage while training.
- Increasing batch size by three times does not reduce the training time by a corresponding factor of three. According to the `data_time` recorded during training, the larger the batch size, the larger the `data_time`, indicating that data loading has become the bottleneck limiting the training speed. Increasing `num_workers`, the number of processes used to load data, can accelerate the training speed.
### Ablation studies
In order to obtain a training pipeline applicable to the dataset, the following ablation studies with the YOLOv5-s model as an example are performed.
#### Data augmentation
| Aug Method | [config](/projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-100e_ionogram_aug0.py) | [config](/projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb32-100e_ionogram_mosaic.py) | [config](/projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-100e_ionogram_mosaic_affine.py) | [config](/projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-100e_ionogram_mosaic_affine_albu_hsv.py) | [config](/projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-100e_ionogram.py) |
| ---------- | ------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------- |
| Mosaic | | √ | √ | √ | √ |
| Affine | | | √ | √ | √ |
| Albu | | | | √ | √ |
| HSV | | | | √ | √ |
| Flip | | | | | √ |
| Val mAP | 0.507 | 0.550 | 0.572 | 0.567 | 0.575 |
The results indicate that mosaic augmentation and random affine transformation can significantly improve the performance on the validation set.
#### Using pre-trained models
If you prefer not to use pre-trained weights, you can simply set `load_from = None` in the config file. For experiments that do not use pre-trained weights, it is recommended to increase the base learning rate by a factor of four and extend the number of training epochs to 200 to ensure adequate model training.
| Model | Epoch(best) | FLOPs(G) | Params(M) | Pretrain | Val mAP | Config |
| -------- | ----------- | -------- | --------- | -------- | ------- | ------------------------------------------------------------------------------------------------ |
| YOLOv5-s | 100(82) | 7.95 | 7.04 | Coco | 0.575 | [config](/projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-100e_ionogram.py) |
| YOLOv5-s | 200(145) | 7.95 | 7.04 | None | 0.565 | [config](/projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-200e_ionogram_pre0.py) |
| YOLOv6-s | 100(54) | 24.2 | 18.84 | Coco | 0.584 | [config](/projects/misc/ionogram_detection/yolov6/yolov6_s_fast_1xb32-100e_ionogram.py) |
| YOLOv6-s | 200(188) | 24.2 | 18.84 | None | 0.557 | [config](/projects/misc/ionogram_detection/yolov6/yolov6_s_fast_1xb32-200e_ionogram_pre0.py) |
<div align=center>
<img width="60%" src="https://user-images.githubusercontent.com/67947949/223641016-9ded0d11-62b8-45f4-be5b-bd4ffae3ec21.png">
Comparison of loss reduction during training
</div>
The loss reduction curve shows that when using pre-trained weights, the loss decreases faster. It can be seen that even using models pre-trained on natural image datasets can accelerate model convergence when fine-tuned on radar image datasets.
### Benchmark for ionogram object detection
| Model | epoch(best) | FLOPs(G) | Params(M) | pretrain | val mAP | test mAP | Config | Log |
| ----------- | ----------- | -------- | --------- | -------- | ------- | -------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| YOLOv5-s | 100(82) | 7.95 | 7.04 | Coco | 0.575 | 0.584 | [config](/projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-100e_ionogram.py) | [log](https://github.com/VoyagerXvoyagerx/Ionogram_detection/blob/main/logs/yolov5_s_20230105_213510.json) |
| YOLOv5-m | 100(70) | 24.05 | 20.89 | Coco | 0.587 | 0.586 | [config](/projects/misc/ionogram_detection/yolov5/yolov5_m-v61_fast_1xb32-100e_ionogram.py) | [log](https://github.com/VoyagerXvoyagerx/Ionogram_detection/blob/main/logs/yolov5_m_20230106_004642.json) |
| YOLOv6-s | 100(54) | 24.2 | 18.84 | Coco | 0.584 | 0.594 | [config](/projects/misc/ionogram_detection/yolov6/yolov6_s_fast_1xb32-100e_ionogram.py) | [log](https://github.com/VoyagerXvoyagerx/Ionogram_detection/blob/main/logs/yolov6_s_20230107_003207.json) |
| YOLOv6-m | 100(76) | 37.08 | 44.42 | Coco | 0.590 | 0.590 | [config](/projects/misc/ionogram_detection/yolov6/yolov6_m_fast_1xb32-100e_ionogram.py) | [log](https://github.com/VoyagerXvoyagerx/Ionogram_detection/blob/main/logs/yolov6_m_20230107_201029.json) |
| YOLOv6-l | 100(76) | 71.33 | 58.47 | Coco | 0.605 | 0.597 | [config](/projects/misc/ionogram_detection/yolov6/yolov6_l_fast_1xb32-100e_ionogram.py) | [log](https://github.com/VoyagerXvoyagerx/Ionogram_detection/blob/main/logs/yolov6_l_20230108_005634.json) |
| YOLOv7-tiny | 100(78) | 6.57 | 6.02 | Coco | 0.549 | 0.568 | [config](/projects/misc/ionogram_detection/yolov7/yolov7_tiny_fast_1xb16-100e_ionogram.py) | [log](https://github.com/VoyagerXvoyagerx/Ionogram_detection/blob/main/logs/yolov7_tiny_20230215_202837.json) |
| YOLOv7-x | 100(58) | 94.27 | 70.85 | Coco | 0.602 | 0.595 | [config](/projects/misc/ionogram_detection/yolov7/yolov7_x_fast_1xb16-100e_ionogram.py) | [log](https://github.com/VoyagerXvoyagerx/Ionogram_detection/blob/main/logs/yolov7_x_20230110_165832.json) |
| rtmdet-tiny | 100(100) | 8.03 | 4.88 | Coco | 0.582 | 0.589 | [config](/projects/misc/ionogram_detection/rtmdet/rtmdet_tiny_fast_1xb32-100e_ionogram.py) | [log](https://github.com/VoyagerXvoyagerx/Ionogram_detection/blob/main/logs/rtmdet_tiny_20230310_125440.json) |
| rtmdet-s | 100(92) | 14.76 | 8.86 | Coco | 0.588 | 0.585 | [config](/projects/misc/ionogram_detection/rtmdet/rtmdet_s_fast_1xb32-100e_ionogram.py) | [log](https://github.com/VoyagerXvoyagerx/Ionogram_detection/blob/main/logs/rtmdet_s_20230310_163853.json) |

View File

@ -1 +0,0 @@
# MMYOLO industry examples

View File

@ -21,13 +21,13 @@
recommended_topics/contributing.md
recommended_topics/model_design.md
recommended_topics/algorithm_descriptions/index.rst
recommended_topics/application_examples/index.rst
recommended_topics/replace_backbone.md
recommended_topics/complexity_analysis.md
recommended_topics/labeling_to_deployment_tutorials.md
recommended_topics/visualization.md
recommended_topics/deploy/index.rst
recommended_topics/troubleshooting_steps.md
recommended_topics/industry_examples.md
recommended_topics/mm_basics.md
recommended_topics/dataset_preparation.md

View File

@ -0,0 +1,7 @@
MMYOLO 应用范例介绍
********************
.. toctree::
:maxdepth: 1
ionogram_detection.md

View File

@ -0,0 +1,306 @@
# 基于 MMYOLO 的频高图实时目标检测 benchmark
## 数据集构建
数字频高图是获取电离层实时信息最重要的途径。电离层结构检测对精准提取电离层关键参数,具有非常重要的研究意义。
利用中国科学院在海南、武汉、怀来获取的不同季节的 4311 张频高图建立数据集,使用 [labelme](https://github.com/wkentaro/labelme) 人工标注出 E 层、Es-c 层、Es-l 层、F1 层、F2 层、Spread F 层共 6 种结构。[数据集下载](https://github.com/VoyagerXvoyagerx/Ionogram_detection/releases/download/Dataset/Iono4311.zip)
<div align=center>
<img width="40%" src="https://user-images.githubusercontent.com/67947949/223638535-c4583d88-aa5a-4f21-b35a-e6e8328c9bd4.jpg"/>
使用 labelme 标注的图像预览
</div>
1. 数据集准备
下载数据后,放置在 MMYOLO 仓库的根目录下,使用 `unzip test.zip` 命令linux解压至当前文件夹。解压后的文件夹结构为
```shell
Iono4311/
├── images
| ├── 20130401005200.png
| └── ...
└── labels
├── 20130401005200.json
└── ...
```
其中,`images` 目录下存放输入图片,`labels` 目录下存放使用 labelme 标注得到的 json 文件。
2. 数据集格式转换
使用MMYOLO提供的 `tools/dataset_converters/labelme2coco.py` 脚本将 labelme 格式的标注文件转换为 COCO 格式的标注文件。
```shell
python tools/dataset_converters/labelme2coco.py --img-dir ./Iono4311/images \
--labels-dir ./Iono4311/labels \
--out ./Iono4311/annotations/annotations_all.json
```
3. 浏览数据集
使用下面的命令可以将 COCO 的 label 在图片上进行显示,这一步可以验证刚刚转换是否有问题。
```shell
python tools/analysis_tools/browse_coco_json.py --img-dir ./Iono4311/images \
--ann-file ./Iono4311/annotations/annotations_all.json
```
4. 划分训练集、验证集、测试集
设置 70% 的图片为训练集15% 作为验证集15% 为测试集。
```shell
python tools/misc/coco_split.py --json ./Iono4311/annotations/annotations_all.json \
--out-dir ./Iono4311/annotations \
--ratios 0.7 0.15 0.15 \
--shuffle \
--seed 14
```
划分后的文件夹结构:
```shell
Iono4311/
├── annotations
│ ├── annotations_all.json
│ ├── class_with_id.txt
│ ├── test.json
│ ├── train.json
│ └── val.json
├── classes_with_id.txt
├── images
├── labels
├── test_images
├── train_images
└── val_images
```
## 配置文件
配置文件存放在目录 `/projects/misc/ionogram_detection/` 下。
1. 数据集分析
使用 `tools/analysis_tools/dataset_analysis.py` 从数据集中采样 200 张图片进行可视化分析:
```shell
python tools/analysis_tools/dataset_analysis.py projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-100e_ionogram.py \
--out-dir output
```
得到以下输出:
```shell
The information obtained is as follows:
+------------------------------+
| Information of dataset class |
+---------------+--------------+
| Class name | Bbox num |
+---------------+--------------+
| E | 98 |
| Es-l | 27 |
| Es-c | 46 |
| F1 | 100 |
| F2 | 194 |
| Spread-F | 6 |
+---------------+--------------+
```
说明本数据集存在样本不均衡的现象。
<div align=center>
<img width="100%" src="https://user-images.githubusercontent.com/67947949/223640412-4008a0a1-0626-419d-90bf-fb7ce6f26fc9.jpg"/>
各类别目标大小统计
</div>
根据统计结果E、Es-l、Esc、F1 类别以小目标居多F2、Spread F 类主要是中等大小目标。
2. 可视化 config 中的数据处理部分
以 YOLOv5-s 为例,根据配置文件中的 `train_pipeline`,训练时采用的数据增强策略包括:
- 马赛克增强
- 随机仿射变换
- Albumentations 数据增强工具包(包括多种数字图像处理方法)
- HSV 随机增强图像
- 随机水平翻转
使用 `tools/analysis_tools/browse_dataset.py` 脚本的 **'pipeline'** 模式,可以可视化每个 pipeline 的输出效果:
```shell
python tools/analysis_tools/browse_dataset.py projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-100e_ionogram.py \
-m pipeline \
--out-dir output
```
<div align=center>
<img src="https://user-images.githubusercontent.com/67947949/223914228-abcd017d-a068-4dcd-9d91-e6b546540060.png"/>
pipeline 输出可视化
</div>
3. 优化 Anchor 尺寸
使用分析工具中的 `tools/analysis_tools/optimize_anchors.py` 脚本得到适用于本数据集的先验锚框尺寸。
```shell
python tools/analysis_tools/optimize_anchors.py projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-100e_ionogram.py \
--algorithm v5-k-means \
--input-shape 640 640 \
--prior-match-thr 4.0 \
--out-dir work_dirs/dataset_analysis_5_s
```
4. 模型复杂度分析
根据配置文件,使用分析工具中的 `tools/analysis_tools/get_flops.py` 脚本可以得到模型的参数量、浮点计算量等信息。以 YOLOv5-s 为例:
```shell
python tools/analysis_tools/get_flops.py projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-100e_ionogram.py
```
得到如下输出,表示模型的浮点运算量为 7.947G,一共有 7.036M 个可学习参数。
```shell
==============================
Input shape: torch.Size([640, 640])
Model Flops: 7.947G
Model Parameters: 7.036M
==============================
```
## 训练和测试
1. 训练
训练可视化:本范例按照[标注+训练+测试+部署全流程](https://mmyolo.readthedocs.io/zh_CN/dev/recommended_topics/labeling_to_deployment_tutorials.html#id11)中的步骤安装和配置 [wandb](https://wandb.ai/site)。
调试技巧:在调试代码的过程中,有时需要训练几个 epoch例如调试验证过程或者权重的保存是否符合期望。对于继承自 `BaseDataset` 的数据集(如本范例中的 `YOLOv5CocoDataset`),在 `train_dataloader` 中的 `dataset` 字段增加 `indices` 参数,即可指定每个 epoch 迭代的样本数,减少迭代时间。
```python
train_dataloader = dict(
batch_size=train_batch_size_per_gpu,
num_workers=train_num_workers,
dataset=dict(
_delete_=True,
type='RepeatDataset',
times=1,
dataset=dict(
type=_base_.dataset_type,
indices=200, # 设置 indices=200表示每个 epoch 只迭代 200 个样本
data_root=data_root,
metainfo=metainfo,
ann_file=train_ann_file,
data_prefix=dict(img=train_data_prefix),
filter_cfg=dict(filter_empty_gt=False, min_size=32),
pipeline=_base_.train_pipeline)))
```
启动训练:
```shell
python tools/train.py projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-100e_ionogram.py
```
2. 测试
指定配置文件和模型的路径以启动测试:
```shell
python tools/test.py projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-100e_ionogram.py \
work_dirs/yolov5_s-v61_fast_1xb96-100e_ionogram/xxx
```
## 实验与结果分析
### 选择合适的 batch size
- Batch size 主导了训练速度。通常,理想的 batch size 是是硬件能支持的最大 batch size。
- 当显存占用没有达到饱和时,如果 batch size 翻倍,训练吞吐量也应该翻倍(或接近翻倍),训练时间应该减半或接近减半。
- 使用**混合精度训练**可以加快训练速度、减小显存。在执行 `train.py` 脚本时添加 `--amp` 参数即可开启。
硬件信息:
- GPUV100显存 32G
- CPU10核内存 40G
实验结果:
| Model | Epoch(best) | AMP | Batchsize | Num workers | Memory Allocated | Training Time | Val mAP |
| -------- | ----------- | ----- | --------- | ----------- | ---------------- | ------------- | ------- |
| YOLOv5-s | 100(82) | False | 32 | 6 | 35.07% | 54 min | 0.575 |
| YOLOv5-s | 100(96) | True | 32 | 6 | 24.93% | 49 min | 0.578 |
| YOLOv5-s | 100(100) | False | 96 | 6 | 96.64% | 48 min | 0.571 |
| YOLOv5-s | 100(100) | True | 96 | 6 | 54.66% | **37** min | 0.575 |
| YOLOv5-s | 100(90) | True | 144 | 6 | 77.06% | 39 min | 0.573 |
| YOLOv5-s | 200(148) | True | 96 | 6 | 54.66% | 72 min | 0.575 |
| YOLOv5-s | 200(188) | True | 96 | **8** | 54.66% | 67 min | 0.576 |
<div align=center>
<img width="60%" src="https://user-images.githubusercontent.com/67947949/223635966-948c8424-1ba8-4df0-92d7-079029dc1231.png">
不同 batch size 的训练过程中,数据加载时间 `data_time` 占每步总时长的比例
</div>
分析结果,可以得出以下结论:
- 混合精度训练对模型的精度几乎没有影响,并且可以明显减少显存占用。
- Batch size 增加 3 倍,和训练时长并没有相应地减小 3 倍。根据训练过程中 `data_time` 的记录batch size 越大,`data_time` 也越大,说明数据加载成为了限制训练速度的瓶颈。增大加载数据的进程数 `num_workers` 可以加快数据加载。
### 消融实验
为了得到适用于本数据集的训练流水线,以 YOLOv5-s 模型为例,进行以下消融实验。
#### 不同数据增强方法
| Aug Method | [config](/projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-100e_ionogram_aug0.py) | [config](/projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb32-100e_ionogram_mosaic.py) | [config](/projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-100e_ionogram_mosaic_affine.py) | [config](/projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-100e_ionogram_mosaic_affine_albu_hsv.py) | [config](/projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-100e_ionogram.py) |
| ---------- | ------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------- |
| Mosaic | | √ | √ | √ | √ |
| Affine | | | √ | √ | √ |
| Albu | | | | √ | √ |
| HSV | | | | √ | √ |
| Flip | | | | | √ |
| Val mAP | 0.507 | 0.550 | 0.572 | 0.567 | 0.575 |
结果表明,马赛克增强和随机仿射变换可以对验证集表现带来明显的提升。
#### 是否使用预训练权重
在配置文件中,修改 `load_from = None` 即可不使用预训练权重。对不使用预训练权重的实验,将基础学习率增大四倍,训练轮数增加至 200 轮,使模型得到较为充分的训练。
| Model | Epoch(best) | FLOPs(G) | Params(M) | Pretrain | Val mAP | Config |
| -------- | ----------- | -------- | --------- | -------- | ------- | ------------------------------------------------------------------------------------------------ |
| YOLOv5-s | 100(82) | 7.95 | 7.04 | Coco | 0.575 | [config](/projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-100e_ionogram.py) |
| YOLOv5-s | 200(145) | 7.95 | 7.04 | None | 0.565 | [config](/projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-200e_ionogram_pre0.py) |
| YOLOv6-s | 100(54) | 24.2 | 18.84 | Coco | 0.584 | [config](/projects/misc/ionogram_detection/yolov6/yolov6_s_fast_1xb32-100e_ionogram.py) |
| YOLOv6-s | 200(188) | 24.2 | 18.84 | None | 0.557 | [config](/projects/misc/ionogram_detection/yolov6/yolov6_s_fast_1xb32-200e_ionogram_pre0.py) |
<div align=center>
<img width="60%" src="https://user-images.githubusercontent.com/67947949/223641016-9ded0d11-62b8-45f4-be5b-bd4ffae3ec21.png">
训练过程中的损失下降对比图
</div>
损失下降曲线表明使用预训练权重时loss 下降得更快。可见即使是自然图像数据集上预训练的模型,在雷达图像数据集上微调时,也可以加快模型收敛。
### 频高图结构检测 benchmark
| Model | epoch(best) | FLOPs(G) | Params(M) | pretrain | val mAP | test mAP | Config | Log |
| ----------- | ----------- | -------- | --------- | -------- | ------- | -------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| YOLOv5-s | 100(82) | 7.95 | 7.04 | Coco | 0.575 | 0.584 | [config](/projects/misc/ionogram_detection/yolov5/yolov5_s-v61_fast_1xb96-100e_ionogram.py) | [log](https://github.com/VoyagerXvoyagerx/Ionogram_detection/blob/main/logs/yolov5_s_20230105_213510.json) |
| YOLOv5-m | 100(70) | 24.05 | 20.89 | Coco | 0.587 | 0.586 | [config](/projects/misc/ionogram_detection/yolov5/yolov5_m-v61_fast_1xb32-100e_ionogram.py) | [log](https://github.com/VoyagerXvoyagerx/Ionogram_detection/blob/main/logs/yolov5_m_20230106_004642.json) |
| YOLOv6-s | 100(54) | 24.2 | 18.84 | Coco | 0.584 | 0.594 | [config](/projects/misc/ionogram_detection/yolov6/yolov6_s_fast_1xb32-100e_ionogram.py) | [log](https://github.com/VoyagerXvoyagerx/Ionogram_detection/blob/main/logs/yolov6_s_20230107_003207.json) |
| YOLOv6-m | 100(76) | 37.08 | 44.42 | Coco | 0.590 | 0.590 | [config](/projects/misc/ionogram_detection/yolov6/yolov6_m_fast_1xb32-100e_ionogram.py) | [log](https://github.com/VoyagerXvoyagerx/Ionogram_detection/blob/main/logs/yolov6_m_20230107_201029.json) |
| YOLOv6-l | 100(76) | 71.33 | 58.47 | Coco | 0.605 | 0.597 | [config](/projects/misc/ionogram_detection/yolov6/yolov6_l_fast_1xb32-100e_ionogram.py) | [log](https://github.com/VoyagerXvoyagerx/Ionogram_detection/blob/main/logs/yolov6_l_20230108_005634.json) |
| YOLOv7-tiny | 100(78) | 6.57 | 6.02 | Coco | 0.549 | 0.568 | [config](/projects/misc/ionogram_detection/yolov7/yolov7_tiny_fast_1xb16-100e_ionogram.py) | [log](https://github.com/VoyagerXvoyagerx/Ionogram_detection/blob/main/logs/yolov7_tiny_20230215_202837.json) |
| YOLOv7-x | 100(58) | 94.27 | 70.85 | Coco | 0.602 | 0.595 | [config](/projects/misc/ionogram_detection/yolov7/yolov7_x_fast_1xb16-100e_ionogram.py) | [log](https://github.com/VoyagerXvoyagerx/Ionogram_detection/blob/main/logs/yolov7_x_20230110_165832.json) |
| rtmdet-tiny | 100(100) | 8.03 | 4.88 | Coco | 0.582 | 0.589 | [config](/projects/misc/ionogram_detection/rtmdet/rtmdet_tiny_fast_1xb32-100e_ionogram.py) | [log](https://github.com/VoyagerXvoyagerx/Ionogram_detection/blob/main/logs/rtmdet_tiny_20230310_125440.json) |
| rtmdet-s | 100(92) | 14.76 | 8.86 | Coco | 0.588 | 0.585 | [config](/projects/misc/ionogram_detection/rtmdet/rtmdet_s_fast_1xb32-100e_ionogram.py) | [log](https://github.com/VoyagerXvoyagerx/Ionogram_detection/blob/main/logs/rtmdet_s_20230310_163853.json) |

View File

@ -1 +0,0 @@
# MMYOLO 产业范例介绍

View File

@ -1,3 +1,3 @@
Tips: 这个是自定义数据集的 config 文件,请结合 [自定义数据集教程](https://github.com/open-mmlab/mmyolo/blob/dev/docs/zh_cn/user_guides/custom_dataset.md) 来使用。
Tips: 这个是自定义数据集的 config 文件,请结合 [标注+训练+测试+部署全流程](https://github.com/open-mmlab/mmyolo/blob/main/docs/zh_cn/recommended_topics/labeling_to_deployment_tutorials.md) 来使用。
Tips: This is the config file of the custom dataset. Please use it in combination with [custom dataset](https://github.com/open-mmlab/mmyolo/blob/dev/docs/en/user_guides/custom_dataset.md).
Tips: This is the config file of the custom dataset. Please use it in combination with [Annotation-to-deployment workflow for custom dataset](https://github.com/open-mmlab/mmyolo/blob/main/docs/en/recommended_topics/labeling_to_deployment_tutorials.md).

View File

@ -0,0 +1,3 @@
Tips: 这是 MMYOLO 应用范例的配置文件,请结合 [基于 MMYOLO 的频高图实时目标检测 benchmark](/docs/zh_cn/recommended_topics/application_examples/ionogram_detection.md) 来使用。
Tips: This is the config file of the MMYOLO application examples. Please use it in combination with [A Benchmark for Ionogram Detection Based on MMYOLO](/docs/en/recommended_topics/application_examples/ionogram_detection.md).

View File

@ -0,0 +1,107 @@
_base_ = 'mmyolo::rtmdet/rtmdet_l_syncbn_fast_8xb32-300e_coco.py'
# ======================== Modified parameters ======================
# -----data related-----
data_root = './Iono4311/'
train_ann_file = 'annotations/train.json'
train_data_prefix = 'train_images/'
val_ann_file = 'annotations/val.json'
val_data_prefix = 'val_images/'
test_ann_file = 'annotations/test.json'
test_data_prefix = 'test_images/'
class_name = ('E', 'Es-l', 'Es-c', 'F1', 'F2', 'Spread-F')
num_classes = len(class_name)
metainfo = dict(
classes=class_name,
palette=[(250, 165, 30), (120, 69, 125), (53, 125, 34), (0, 11, 123),
(130, 20, 12), (120, 121, 80)])
train_batch_size_per_gpu = 32
train_num_workers = 8
val_batch_size_per_gpu = train_batch_size_per_gpu
# Config of batch shapes. Only on val.
batch_shapes_cfg = dict(batch_size=val_batch_size_per_gpu)
# -----train val related-----
load_from = 'https://download.openmmlab.com/mmyolo/v0/rtmdet/rtmdet_l_syncbn_fast_8xb32-300e_coco/rtmdet_l_syncbn_fast_8xb32-300e_coco_20230102_135928-ee3abdc4.pth' # noqa
# default hooks
save_epoch_intervals = 10
max_epochs = 100
max_keep_ckpts = 1
# learning rate
param_scheduler = [
dict(
type='LinearLR', start_factor=1.0e-5, by_epoch=False, begin=0,
end=300),
dict(
# use cosine lr from 20 to 100 epoch
type='CosineAnnealingLR',
eta_min=_base_.base_lr * 0.05,
begin=max_epochs // 5,
end=max_epochs,
T_max=max_epochs * 4 // 5,
by_epoch=True,
convert_to_iter_based=True),
]
# train_cfg
val_interval = 2
val_begin = 20
tta_model = None
tta_pipeline = None
visualizer = dict(
vis_backends=[dict(type='LocalVisBackend'),
dict(type='WandbVisBackend')])
# ===================== Unmodified in most cases ==================
model = dict(
bbox_head=dict(head_module=dict(num_classes=num_classes)),
train_cfg=dict(assigner=dict(num_classes=num_classes)))
train_dataloader = dict(
batch_size=train_batch_size_per_gpu,
num_workers=train_num_workers,
dataset=dict(
metainfo=metainfo,
data_root=data_root,
ann_file=train_ann_file,
data_prefix=dict(img=train_data_prefix)))
val_dataloader = dict(
batch_size=val_batch_size_per_gpu,
num_workers=train_num_workers,
dataset=dict(
metainfo=metainfo,
data_root=data_root,
data_prefix=dict(img=val_data_prefix),
ann_file=val_ann_file))
test_dataloader = dict(
batch_size=val_batch_size_per_gpu,
num_workers=train_num_workers,
dataset=dict(
metainfo=metainfo,
data_root=data_root,
data_prefix=dict(img=test_data_prefix),
ann_file=test_ann_file))
default_hooks = dict(
checkpoint=dict(
interval=save_epoch_intervals,
max_keep_ckpts=max_keep_ckpts,
save_best='auto'))
val_evaluator = dict(ann_file=data_root + val_ann_file)
test_evaluator = dict(ann_file=data_root + test_ann_file)
train_cfg = dict(
type='EpochBasedTrainLoop',
max_epochs=max_epochs,
val_begin=val_begin,
val_interval=val_interval)

View File

@ -0,0 +1,83 @@
_base_ = './rtmdet_l_fast_1xb32-100e_ionogram.py'
load_from = 'https://download.openmmlab.com/mmyolo/v0/rtmdet/rtmdet_s_syncbn_fast_8xb32-300e_coco/rtmdet_s_syncbn_fast_8xb32-300e_coco_20221230_182329-0a8c901a.pth' # noqa
# ======================= Modified parameters =====================
deepen_factor = 0.33
widen_factor = 0.5
img_scale = _base_.img_scale
# ratio range for random resize
random_resize_ratio_range = (0.5, 2.0)
# Number of cached images in mosaic
mosaic_max_cached_images = 40
# Number of cached images in mixup
mixup_max_cached_images = 20
# ===================== Unmodified in most cases ==================
model = dict(
backbone=dict(deepen_factor=deepen_factor, widen_factor=widen_factor),
neck=dict(
deepen_factor=deepen_factor,
widen_factor=widen_factor,
),
bbox_head=dict(head_module=dict(widen_factor=widen_factor)))
train_pipeline = [
dict(type='LoadImageFromFile', file_client_args=_base_.file_client_args),
dict(type='LoadAnnotations', with_bbox=True),
dict(
type='Mosaic',
img_scale=img_scale,
use_cached=True,
max_cached_images=mosaic_max_cached_images,
pad_val=114.0),
dict(
type='mmdet.RandomResize',
# img_scale is (width, height)
scale=(img_scale[0] * 2, img_scale[1] * 2),
ratio_range=random_resize_ratio_range, # note
resize_type='mmdet.Resize',
keep_ratio=True),
dict(type='mmdet.RandomCrop', crop_size=img_scale),
dict(type='mmdet.YOLOXHSVRandomAug'),
dict(type='mmdet.RandomFlip', prob=0.5),
dict(type='mmdet.Pad', size=img_scale, pad_val=dict(img=(114, 114, 114))),
dict(
type='YOLOv5MixUp',
use_cached=True,
max_cached_images=mixup_max_cached_images),
dict(type='mmdet.PackDetInputs')
]
train_pipeline_stage2 = [
dict(type='LoadImageFromFile', file_client_args=_base_.file_client_args),
dict(type='LoadAnnotations', with_bbox=True),
dict(
type='mmdet.RandomResize',
scale=img_scale,
ratio_range=random_resize_ratio_range, # note
resize_type='mmdet.Resize',
keep_ratio=True),
dict(type='mmdet.RandomCrop', crop_size=img_scale),
dict(type='mmdet.YOLOXHSVRandomAug'),
dict(type='mmdet.RandomFlip', prob=0.5),
dict(type='mmdet.Pad', size=img_scale, pad_val=dict(img=(114, 114, 114))),
dict(type='mmdet.PackDetInputs')
]
train_dataloader = dict(dataset=dict(pipeline=train_pipeline))
custom_hooks = [
dict(
type='EMAHook',
ema_type='ExpMomentumEMA',
momentum=0.0002,
update_buffers=True,
strict_load=False,
priority=49),
dict(
type='mmdet.PipelineSwitchHook',
switch_epoch=_base_.max_epochs - _base_.num_epochs_stage2,
switch_pipeline=train_pipeline_stage2)
]

View File

@ -0,0 +1,62 @@
_base_ = './rtmdet_s_fast_1xb32-100e_ionogram.py'
# ======================= Modified parameters ======================
deepen_factor = 0.167
widen_factor = 0.375
img_scale = _base_.img_scale
load_from = 'https://download.openmmlab.com/mmyolo/v0/rtmdet/rtmdet_tiny_syncbn_fast_8xb32-300e_coco/rtmdet_tiny_syncbn_fast_8xb32-300e_coco_20230102_140117-dbb1dc83.pth' # noqa
# learning rate
param_scheduler = [
dict(
type='LinearLR', start_factor=1.0e-5, by_epoch=False, begin=0,
end=300),
dict(
# use cosine lr from 50 to 100 epoch
type='CosineAnnealingLR',
eta_min=_base_.base_lr * 0.05,
begin=_base_.max_epochs // 2,
end=_base_.max_epochs,
T_max=_base_.max_epochs // 2,
by_epoch=True,
convert_to_iter_based=True),
]
# =======================Unmodified in most cases==================
model = dict(
backbone=dict(deepen_factor=deepen_factor, widen_factor=widen_factor),
neck=dict(deepen_factor=deepen_factor, widen_factor=widen_factor),
bbox_head=dict(head_module=dict(widen_factor=widen_factor)))
train_pipeline = [
dict(type='LoadImageFromFile', file_client_args=_base_.file_client_args),
dict(type='LoadAnnotations', with_bbox=True),
dict(
type='Mosaic',
img_scale=img_scale,
use_cached=True,
max_cached_images=20, # note
random_pop=False, # note
pad_val=114.0),
dict(
type='mmdet.RandomResize',
# img_scale is (width, height)
scale=(img_scale[0] * 2, img_scale[1] * 2),
ratio_range=(0.5, 2.0),
resize_type='mmdet.Resize',
keep_ratio=True),
dict(type='mmdet.RandomCrop', crop_size=img_scale),
dict(type='mmdet.YOLOXHSVRandomAug'),
dict(type='mmdet.RandomFlip', prob=0.5),
dict(type='mmdet.Pad', size=img_scale, pad_val=dict(img=(114, 114, 114))),
dict(
type='YOLOv5MixUp',
use_cached=True,
random_pop=False,
max_cached_images=10,
prob=0.5),
dict(type='mmdet.PackDetInputs')
]
train_dataloader = dict(dataset=dict(pipeline=train_pipeline))

View File

@ -0,0 +1,95 @@
_base_ = './yolov5_s-v61_fast_1xb96-100e_ionogram.py'
# ======================= Modified parameters =====================
# Copied from '../../yolov5/yolov5_m-v61_syncbn_fast_8xb16-300e_coco.py'
deepen_factor = 0.67
widen_factor = 0.75
lr_factor = 0.1
affine_scale = 0.9
loss_cls_weight = 0.3
loss_obj_weight = 0.7
mixup_prob = 0.1
# -----data related-----
train_batch_size_per_gpu = 32
# -----train val related-----
# Scale lr for SGD
base_lr = _base_.base_lr * train_batch_size_per_gpu \
/ _base_.train_batch_size_per_gpu
load_from = 'https://download.openmmlab.com/mmyolo/v0/yolov5/yolov5_m-v61_syncbn_fast_8xb16-300e_coco/yolov5_m-v61_syncbn_fast_8xb16-300e_coco_20220917_204944-516a710f.pth' # noqa
# ===================== Unmodified in most cases ==================
num_classes = _base_.num_classes
num_det_layers = _base_.num_det_layers
img_scale = _base_.img_scale
model = dict(
backbone=dict(
deepen_factor=deepen_factor,
widen_factor=widen_factor,
),
neck=dict(
deepen_factor=deepen_factor,
widen_factor=widen_factor,
),
bbox_head=dict(
head_module=dict(widen_factor=widen_factor),
loss_cls=dict(loss_weight=loss_cls_weight *
(num_classes / 80 * 3 / num_det_layers)),
loss_obj=dict(loss_weight=loss_obj_weight *
((img_scale[0] / 640)**2 * 3 / num_det_layers))))
pre_transform = _base_.pre_transform
albu_train_transforms = _base_.albu_train_transforms
mosaic_affine_pipeline = [
dict(
type='Mosaic',
img_scale=img_scale,
pad_val=114.0,
pre_transform=pre_transform),
dict(
type='YOLOv5RandomAffine',
max_rotate_degree=0.0,
max_shear_degree=0.0,
scaling_ratio_range=(1 - affine_scale, 1 + affine_scale),
# img_scale is (width, height)
border=(-img_scale[0] // 2, -img_scale[1] // 2),
border_val=(114, 114, 114))
]
# enable mixup
train_pipeline = [
*pre_transform, *mosaic_affine_pipeline,
dict(
type='YOLOv5MixUp',
prob=mixup_prob,
pre_transform=[*pre_transform, *mosaic_affine_pipeline]),
dict(
type='mmdet.Albu',
transforms=albu_train_transforms,
bbox_params=dict(
type='BboxParams',
format='pascal_voc',
label_fields=['gt_bboxes_labels', 'gt_ignore_flags']),
keymap={
'img': 'image',
'gt_bboxes': 'bboxes'
}),
dict(type='YOLOv5HSVRandomAug'),
dict(type='mmdet.RandomFlip', prob=0.5),
dict(
type='mmdet.PackDetInputs',
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', 'flip',
'flip_direction'))
]
train_dataloader = dict(
batch_size=train_batch_size_per_gpu,
dataset=dict(dataset=dict(pipeline=train_pipeline)))
val_dataloader = dict(batch_size=train_batch_size_per_gpu)
test_dataloader = dict(batch_size=train_batch_size_per_gpu)
optim_wrapper = dict(optimizer=dict(lr=base_lr))
default_hooks = dict(param_scheduler=dict(lr_factor=lr_factor))

View File

@ -0,0 +1,37 @@
_base_ = './yolov5_s-v61_fast_1xb96-100e_ionogram.py'
# ======================= Modified parameters =====================
# -----data related-----
train_batch_size_per_gpu = 32
# -----train val related-----
base_lr = _base_.base_lr * train_batch_size_per_gpu \
/ _base_.train_batch_size_per_gpu / 2
train_pipeline = [
dict(type='LoadImageFromFile', file_client_args=dict(backend='disk')),
dict(type='LoadAnnotations', with_bbox=True),
dict(
type='Mosaic',
img_scale=(640, 640),
pad_val=114.0,
pre_transform=[
dict(
type='LoadImageFromFile',
file_client_args=dict(backend='disk')),
dict(type='LoadAnnotations', with_bbox=True)
]),
dict(
type='mmdet.PackDetInputs',
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape'))
]
# ===================== Unmodified in most cases ==================
train_dataloader = dict(
batch_size=train_batch_size_per_gpu,
dataset=dict(dataset=dict(pipeline=train_pipeline)))
val_dataloader = dict(batch_size=train_batch_size_per_gpu)
test_dataloader = dict(batch_size=train_batch_size_per_gpu)
optim_wrapper = dict(optimizer=dict(lr=base_lr))

View File

@ -0,0 +1,108 @@
_base_ = 'mmyolo::yolov5/yolov5_s-v61_syncbn_fast_8xb16-300e_coco.py'
# ======================= Modified parameters =====================
# -----data related-----
data_root = './Iono4311/'
train_ann_file = 'annotations/train.json'
train_data_prefix = 'train_images/'
val_ann_file = 'annotations/val.json'
val_data_prefix = 'val_images/'
test_ann_file = 'annotations/test.json'
test_data_prefix = 'test_images/'
class_name = ('E', 'Es-l', 'Es-c', 'F1', 'F2', 'Spread-F')
num_classes = len(class_name)
metainfo = dict(
classes=class_name,
palette=[(250, 165, 30), (120, 69, 125), (53, 125, 34), (0, 11, 123),
(130, 20, 12), (120, 121, 80)])
# Batch size of a single GPU during training
train_batch_size_per_gpu = 96
# Worker to pre-fetch data for each single GPU during training
train_num_workers = 8
# -----model related-----
# Basic size of multi-scale prior box
anchors = [[[8, 6], [24, 4], [19, 9]], [[22, 19], [17, 49], [29, 45]],
[[44, 66], [96, 76], [126, 59]]]
# -----train val related-----
# base_lr_default * (your_bs / default_bs (8x16)) for SGD
base_lr = _base_.base_lr * train_batch_size_per_gpu / (8 * 16)
max_epochs = 100
load_from = 'https://download.openmmlab.com/mmyolo/v0/yolov5/yolov5_s-v61_syncbn_fast_8xb16-300e_coco/yolov5_s-v61_syncbn_fast_8xb16-300e_coco_20220918_084700-86e02187.pth' # noqa
# default_hooks
save_epoch_intervals = 10
logger_interval = 20
max_keep_ckpts = 1
# train_cfg
val_interval = 2
val_begin = 20
tta_model = None
tta_pipeline = None
visualizer = dict(
vis_backends=[dict(type='LocalVisBackend'),
dict(type='WandbVisBackend')])
# ===================== Unmodified in most cases ==================
model = dict(
bbox_head=dict(
head_module=dict(num_classes=num_classes),
prior_generator=dict(base_sizes=anchors),
loss_cls=dict(loss_weight=0.5 *
(num_classes / 80 * 3 / _base_.num_det_layers))))
train_dataloader = dict(
batch_size=train_batch_size_per_gpu,
num_workers=train_num_workers,
dataset=dict(
_delete_=True,
type='RepeatDataset',
times=1,
dataset=dict(
type=_base_.dataset_type,
data_root=data_root,
metainfo=metainfo,
ann_file=train_ann_file,
data_prefix=dict(img=train_data_prefix),
filter_cfg=dict(filter_empty_gt=False, min_size=32),
pipeline=_base_.train_pipeline)))
val_dataloader = dict(
batch_size=train_batch_size_per_gpu,
num_workers=train_num_workers,
dataset=dict(
metainfo=metainfo,
data_root=data_root,
ann_file=val_ann_file,
data_prefix=dict(img=val_data_prefix)))
test_dataloader = dict(
batch_size=train_batch_size_per_gpu,
num_workers=train_num_workers,
dataset=dict(
metainfo=metainfo,
data_root=data_root,
ann_file=test_ann_file,
data_prefix=dict(img=test_data_prefix)))
optim_wrapper = dict(optimizer=dict(lr=base_lr))
default_hooks = dict(
checkpoint=dict(
type='CheckpointHook',
save_param_scheduler=None, # for yolov5
interval=save_epoch_intervals,
max_keep_ckpts=max_keep_ckpts,
save_best='auto'),
param_scheduler=dict(max_epochs=max_epochs),
logger=dict(type='LoggerHook', interval=logger_interval))
val_evaluator = dict(ann_file=data_root + val_ann_file)
test_evaluator = dict(ann_file=data_root + test_ann_file)
train_cfg = dict(
max_epochs=max_epochs, val_begin=val_begin, val_interval=val_interval)

View File

@ -0,0 +1,21 @@
_base_ = './yolov5_s-v61_fast_1xb96-100e_ionogram.py'
# ======================= Modified parameters =====================
# -----train val related-----
train_pipeline = [
dict(type='LoadImageFromFile', file_client_args=dict(backend='disk')),
dict(type='LoadAnnotations', with_bbox=True),
dict(type='YOLOv5KeepRatioResize', scale=(640, 640)),
dict(
type='LetterResize',
scale=(640, 640),
allow_scale_up=False,
pad_val=dict(img=114)),
dict(
type='mmdet.PackDetInputs',
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
'scale_factor', 'pad_param'))
]
# ===================== Unmodified in most cases ==================
train_dataloader = dict(dataset=dict(dataset=dict(pipeline=train_pipeline)))

View File

@ -0,0 +1,31 @@
_base_ = './yolov5_s-v61_fast_1xb96-100e_ionogram.py'
# ======================= Modified parameters =====================
# -----train val related-----
train_pipeline = [
dict(type='LoadImageFromFile', file_client_args=dict(backend='disk')),
dict(type='LoadAnnotations', with_bbox=True),
dict(
type='Mosaic',
img_scale=(640, 640),
pad_val=114.0,
pre_transform=[
dict(
type='LoadImageFromFile',
file_client_args=dict(backend='disk')),
dict(type='LoadAnnotations', with_bbox=True)
]),
dict(
type='YOLOv5RandomAffine',
max_rotate_degree=0.0,
max_shear_degree=0.0,
scaling_ratio_range=(0.5, 1.5),
border=(-320, -320),
border_val=(114, 114, 114)),
dict(
type='mmdet.PackDetInputs',
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape'))
]
# ===================== Unmodified in most cases ==================
train_dataloader = dict(dataset=dict(dataset=dict(pipeline=train_pipeline)))

View File

@ -0,0 +1,46 @@
_base_ = './yolov5_s-v61_fast_1xb96-100e_ionogram.py'
# ======================= Modified parameters =====================
# -----train val related-----
train_pipeline = [
dict(type='LoadImageFromFile', file_client_args=dict(backend='disk')),
dict(type='LoadAnnotations', with_bbox=True),
dict(
type='Mosaic',
img_scale=(640, 640),
pad_val=114.0,
pre_transform=[
dict(
type='LoadImageFromFile',
file_client_args=dict(backend='disk')),
dict(type='LoadAnnotations', with_bbox=True)
]),
dict(
type='YOLOv5RandomAffine',
max_rotate_degree=0.0,
max_shear_degree=0.0,
scaling_ratio_range=(0.5, 1.5),
border=(-320, -320),
border_val=(114, 114, 114)),
dict(
type='mmdet.Albu',
transforms=[
dict(type='Blur', p=0.01),
dict(type='MedianBlur', p=0.01),
dict(type='ToGray', p=0.01),
dict(type='CLAHE', p=0.01)
],
bbox_params=dict(
type='BboxParams',
format='pascal_voc',
label_fields=['gt_bboxes_labels', 'gt_ignore_flags']),
keymap=dict(img='image', gt_bboxes='bboxes')),
dict(type='YOLOv5HSVRandomAug'),
# dict(type='mmdet.RandomFlip', prob=0.5),
dict(
type='mmdet.PackDetInputs',
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape'))
]
# ===================== Unmodified in most cases ==================
train_dataloader = dict(dataset=dict(dataset=dict(pipeline=train_pipeline)))

View File

@ -0,0 +1,17 @@
_base_ = './yolov5_s-v61_fast_1xb96-100e_ionogram.py'
# ======================= Modified parameters =====================
# -----train val related-----
base_lr = _base_.base_lr * 4
max_epochs = 200
load_from = None
logger_interval = 50
train_cfg = dict(max_epochs=max_epochs, )
# ===================== Unmodified in most cases ==================
optim_wrapper = dict(optimizer=dict(lr=base_lr))
default_hooks = dict(
param_scheduler=dict(max_epochs=max_epochs),
logger=dict(type='LoggerHook', interval=logger_interval))

View File

@ -0,0 +1,29 @@
_base_ = './yolov6_m_fast_1xb32-100e_ionogram.py'
# ======================= Modified parameters =======================
# -----model related-----
deepen_factor = 1
widen_factor = 1
# -----train val related-----
load_from = 'https://download.openmmlab.com/mmyolo/v0/yolov6/yolov6_l_syncbn_fast_8xb32-300e_coco/yolov6_l_syncbn_fast_8xb32-300e_coco_20221109_183156-91e3c447.pth' # noqa
# ====================== Unmodified in most cases ===================
model = dict(
backbone=dict(
deepen_factor=deepen_factor,
widen_factor=widen_factor,
hidden_ratio=1. / 2,
block_cfg=dict(
type='ConvWrapper',
norm_cfg=dict(type='BN', momentum=0.03, eps=0.001)),
act_cfg=dict(type='SiLU', inplace=True)),
neck=dict(
deepen_factor=deepen_factor,
widen_factor=widen_factor,
hidden_ratio=1. / 2,
block_cfg=dict(
type='ConvWrapper',
norm_cfg=dict(type='BN', momentum=0.03, eps=0.001)),
block_act_cfg=dict(type='SiLU', inplace=True)),
bbox_head=dict(head_module=dict(widen_factor=widen_factor)))

View File

@ -0,0 +1,63 @@
_base_ = './yolov6_s_fast_1xb32-100e_ionogram.py'
# ======================= Modified parameters =======================
# -----model related-----
# The scaling factor that controls the depth of the network structure
deepen_factor = 0.6
# The scaling factor that controls the width of the network structure
widen_factor = 0.75
# -----train val related-----
affine_scale = 0.9 # YOLOv5RandomAffine scaling ratio
load_from = 'https://download.openmmlab.com/mmyolo/v0/yolov6/yolov6_m_syncbn_fast_8xb32-300e_coco/yolov6_m_syncbn_fast_8xb32-300e_coco_20221109_182658-85bda3f4.pth' # noqa
# ====================== Unmodified in most cases ===================
model = dict(
backbone=dict(
type='YOLOv6CSPBep',
deepen_factor=deepen_factor,
widen_factor=widen_factor,
hidden_ratio=2. / 3,
block_cfg=dict(type='RepVGGBlock'),
act_cfg=dict(type='ReLU', inplace=True)),
neck=dict(
type='YOLOv6CSPRepPAFPN',
deepen_factor=deepen_factor,
widen_factor=widen_factor,
block_cfg=dict(type='RepVGGBlock'),
hidden_ratio=2. / 3,
block_act_cfg=dict(type='ReLU', inplace=True)),
bbox_head=dict(
type='YOLOv6Head', head_module=dict(widen_factor=widen_factor)))
mosaic_affine_pipeline = [
dict(
type='Mosaic',
img_scale=_base_.img_scale,
pad_val=114.0,
pre_transform=_base_.pre_transform),
dict(
type='YOLOv5RandomAffine',
max_rotate_degree=0.0,
max_shear_degree=0.0,
scaling_ratio_range=(1 - affine_scale, 1 + affine_scale),
# img_scale is (width, height)
border=(-_base_.img_scale[0] // 2, -_base_.img_scale[1] // 2),
border_val=(114, 114, 114))
]
train_pipeline = [
*_base_.pre_transform, *mosaic_affine_pipeline,
dict(
type='YOLOv5MixUp',
prob=0.1,
pre_transform=[*_base_.pre_transform, *mosaic_affine_pipeline]),
dict(type='YOLOv5HSVRandomAug'),
dict(type='mmdet.RandomFlip', prob=0.5),
dict(
type='mmdet.PackDetInputs',
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', 'flip',
'flip_direction'))
]
train_dataloader = dict(dataset=dict(dataset=dict(pipeline=train_pipeline)))

View File

@ -0,0 +1,108 @@
_base_ = 'mmyolo::yolov6/yolov6_s_syncbn_fast_8xb32-400e_coco.py'
# ======================= Modified parameters =====================
# -----data related-----
data_root = './Iono4311/'
train_ann_file = 'annotations/train.json'
train_data_prefix = 'train_images/'
val_ann_file = 'annotations/val.json'
val_data_prefix = 'val_images/'
test_ann_file = 'annotations/test.json'
test_data_prefix = 'test_images/'
class_name = ('E', 'Es-l', 'Es-c', 'F1', 'F2', 'Spread-F')
num_classes = len(class_name)
metainfo = dict(
classes=class_name,
palette=[(250, 165, 30), (120, 69, 125), (53, 125, 34), (0, 11, 123),
(130, 20, 12), (120, 121, 80)])
train_batch_size_per_gpu = 32
train_num_workers = 8
tta_model = None
tta_pipeline = None
# -----train val related-----
load_from = 'https://download.openmmlab.com/mmyolo/v0/yolov6/yolov6_s_syncbn_fast_8xb32-400e_coco/yolov6_s_syncbn_fast_8xb32-400e_coco_20221102_203035-932e1d91.pth' # noqa
# base_lr_default * (your_bs 32 / default_bs (8 x 32))
base_lr = _base_.base_lr * train_batch_size_per_gpu / (8 * 32)
max_epochs = 100
save_epoch_intervals = 10
val_begin = 20
max_keep_ckpts = 1
log_interval = 50
visualizer = dict(
vis_backends=[dict(type='LocalVisBackend'),
dict(type='WandbVisBackend')])
# ==================== Unmodified in most cases ===================
train_cfg = dict(
max_epochs=max_epochs,
val_begin=val_begin,
val_interval=save_epoch_intervals,
dynamic_intervals=None)
model = dict(
bbox_head=dict(head_module=dict(num_classes=num_classes)),
train_cfg=dict(
initial_assigner=dict(num_classes=num_classes),
assigner=dict(num_classes=num_classes)))
train_dataloader = dict(
batch_size=train_batch_size_per_gpu,
num_workers=train_num_workers,
dataset=dict(
_delete_=True,
type='RepeatDataset',
times=1,
dataset=dict(
type=_base_.dataset_type,
data_root=data_root,
metainfo=metainfo,
ann_file=train_ann_file,
data_prefix=dict(img=train_data_prefix),
filter_cfg=dict(filter_empty_gt=False, min_size=32),
pipeline=_base_.train_pipeline)))
val_dataloader = dict(
dataset=dict(
metainfo=metainfo,
data_root=data_root,
ann_file=val_ann_file,
data_prefix=dict(img=val_data_prefix)))
test_dataloader = dict(
dataset=dict(
metainfo=metainfo,
data_root=data_root,
ann_file=test_ann_file,
data_prefix=dict(img=test_data_prefix)))
val_evaluator = dict(ann_file=data_root + val_data_prefix)
test_evaluator = dict(ann_file=data_root + test_data_prefix)
optim_wrapper = dict(optimizer=dict(lr=base_lr))
default_hooks = dict(
checkpoint=dict(
type='CheckpointHook',
interval=save_epoch_intervals,
max_keep_ckpts=max_keep_ckpts,
save_best='auto'),
param_scheduler=dict(max_epochs=max_epochs),
logger=dict(type='LoggerHook', interval=log_interval))
custom_hooks = [
dict(
type='EMAHook',
ema_type='ExpMomentumEMA',
momentum=0.0001,
update_buffers=True,
strict_load=False,
priority=49),
dict(
type='mmdet.PipelineSwitchHook',
switch_epoch=max_epochs - _base_.num_last_epochs,
switch_pipeline=_base_.train_pipeline_stage2)
]

View File

@ -0,0 +1,17 @@
_base_ = './yolov6_s_fast_1xb32-100e_ionogram.py'
# ======================= Modified parameters =====================
base_lr = _base_.base_lr * 4
optim_wrapper = dict(optimizer=dict(lr=base_lr))
max_epochs = 200
load_from = None
# ==================== Unmodified in most cases ===================
train_cfg = dict(
max_epochs=max_epochs,
val_begin=20,
)
default_hooks = dict(
param_scheduler=dict(max_epochs=max_epochs),
logger=dict(type='LoggerHook', interval=50))

View File

@ -0,0 +1,98 @@
_base_ = 'mmyolo::yolov7/yolov7_l_syncbn_fast_8x16b-300e_coco.py'
# ======================== Modified parameters ======================
# -----data related-----
data_root = './Iono4311/'
train_ann_file = 'annotations/train.json'
train_data_prefix = 'train_images/'
val_ann_file = 'annotations/val.json'
val_data_prefix = 'val_images/'
test_ann_file = 'annotations/test.json'
test_data_prefix = 'test_images/'
class_name = ('E', 'Es-l', 'Es-c', 'F1', 'F2', 'Spread-F')
num_classes = len(class_name)
metainfo = dict(
classes=class_name,
palette=[(250, 165, 30), (120, 69, 125), (53, 125, 34), (0, 11, 123),
(130, 20, 12), (120, 121, 80)])
train_batch_size_per_gpu = 16
train_num_workers = 8
# -----model related-----
anchors = [[[14, 14], [35, 6], [32, 18]], [[32, 45], [28, 97], [52, 80]],
[[71, 122], [185, 94], [164, 134]]]
# -----train val related-----
# base_lr_default * (your_bs 32 / default_bs (8 x 16))
base_lr = _base_.base_lr * train_batch_size_per_gpu / (8 * 16)
load_from = 'https://download.openmmlab.com/mmyolo/v0/yolov7/yolov7_l_syncbn_fast_8x16b-300e_coco/yolov7_l_syncbn_fast_8x16b-300e_coco_20221123_023601-8113c0eb.pth' # noqa
# default hooks
save_epoch_intervals = 10
max_epochs = 100
max_keep_ckpts = 1
# train_cfg
val_interval = 2
val_begin = 20
tta_model = None
tta_pipeline = None
visualizer = dict(
vis_backends=[dict(type='LocalVisBackend'),
dict(type='WandbVisBackend')])
# ===================== Unmodified in most cases ==================
model = dict(
bbox_head=dict(
head_module=dict(num_classes=num_classes),
prior_generator=dict(base_sizes=anchors),
loss_cls=dict(loss_weight=_base_.loss_cls_weight *
(num_classes / 80 * 3 / _base_.num_det_layers))))
train_dataloader = dict(
batch_size=train_batch_size_per_gpu,
num_workers=train_num_workers,
dataset=dict(
metainfo=metainfo,
data_root=data_root,
ann_file=train_ann_file,
data_prefix=dict(img=train_data_prefix)))
val_dataloader = dict(
batch_size=train_batch_size_per_gpu,
num_workers=train_num_workers,
dataset=dict(
metainfo=metainfo,
data_root=data_root,
data_prefix=dict(img=val_data_prefix),
ann_file=val_ann_file))
test_dataloader = dict(
batch_size=train_batch_size_per_gpu,
num_workers=train_num_workers,
dataset=dict(
metainfo=metainfo,
data_root=data_root,
data_prefix=dict(img=test_data_prefix),
ann_file=test_ann_file))
optim_wrapper = dict(
optimizer=dict(lr=base_lr, batch_size_per_gpu=train_batch_size_per_gpu))
default_hooks = dict(
param_scheduler=dict(max_epochs=max_epochs),
checkpoint=dict(
interval=save_epoch_intervals, max_keep_ckpts=max_keep_ckpts))
val_evaluator = dict(ann_file=data_root + val_ann_file)
test_evaluator = dict(ann_file=data_root + test_ann_file)
train_cfg = dict(
type='EpochBasedTrainLoop',
max_epochs=max_epochs,
val_begin=val_begin,
val_interval=val_interval)

View File

@ -0,0 +1,101 @@
_base_ = './yolov7_l_fast_1xb16-100e_ionogram.py'
# ======================== Modified parameters =======================
# pre-train
load_from = 'https://download.openmmlab.com/mmyolo/v0/yolov7/yolov7_tiny_syncbn_fast_8x16b-300e_coco/yolov7_tiny_syncbn_fast_8x16b-300e_coco_20221126_102719-0ee5bbdf.pth' # noqa
# -----model related-----
# Data augmentation
max_translate_ratio = 0.1 # YOLOv5RandomAffine
scaling_ratio_range = (0.5, 1.6) # YOLOv5RandomAffine
mixup_prob = 0.05 # YOLOv5MixUp
randchoice_mosaic_prob = [0.8, 0.2]
mixup_alpha = 8.0 # YOLOv5MixUp
mixup_beta = 8.0 # YOLOv5MixUp
# -----train val related-----
loss_cls_weight = 0.5
loss_obj_weight = 1.0
lr_factor = 0.01 # Learning rate scaling factor
# ====================== Unmodified in most cases ====================
num_classes = _base_.num_classes
num_det_layers = _base_.num_det_layers
img_scale = _base_.img_scale
pre_transform = _base_.pre_transform
model = dict(
backbone=dict(
arch='Tiny', act_cfg=dict(type='LeakyReLU', negative_slope=0.1)),
neck=dict(
is_tiny_version=True,
in_channels=[128, 256, 512],
out_channels=[64, 128, 256],
block_cfg=dict(
_delete_=True, type='TinyDownSampleBlock', middle_ratio=0.25),
act_cfg=dict(type='LeakyReLU', negative_slope=0.1),
use_repconv_outs=False),
bbox_head=dict(
head_module=dict(in_channels=[128, 256, 512]),
loss_cls=dict(loss_weight=loss_cls_weight *
(num_classes / 80 * 3 / num_det_layers)),
loss_obj=dict(loss_weight=loss_obj_weight *
((img_scale[0] / 640)**2 * 3 / num_det_layers))))
mosiac4_pipeline = [
dict(
type='Mosaic',
img_scale=img_scale,
pad_val=114.0,
pre_transform=pre_transform),
dict(
type='YOLOv5RandomAffine',
max_rotate_degree=0.0,
max_shear_degree=0.0,
max_translate_ratio=max_translate_ratio, # change
scaling_ratio_range=scaling_ratio_range, # change
# img_scale is (width, height)
border=(-img_scale[0] // 2, -img_scale[1] // 2),
border_val=(114, 114, 114)),
]
mosiac9_pipeline = [
dict(
type='Mosaic9',
img_scale=img_scale,
pad_val=114.0,
pre_transform=pre_transform),
dict(
type='YOLOv5RandomAffine',
max_rotate_degree=0.0,
max_shear_degree=0.0,
max_translate_ratio=max_translate_ratio, # change
scaling_ratio_range=scaling_ratio_range, # change
border=(-img_scale[0] // 2, -img_scale[1] // 2),
border_val=(114, 114, 114)),
]
randchoice_mosaic_pipeline = dict(
type='RandomChoice',
transforms=[mosiac4_pipeline, mosiac9_pipeline],
prob=randchoice_mosaic_prob)
train_pipeline = [
*pre_transform,
randchoice_mosaic_pipeline,
dict(
type='YOLOv5MixUp',
alpha=mixup_alpha,
beta=mixup_beta,
prob=mixup_prob, # change
pre_transform=[*pre_transform, randchoice_mosaic_pipeline]),
dict(type='YOLOv5HSVRandomAug'),
dict(type='mmdet.RandomFlip', prob=0.5),
dict(
type='mmdet.PackDetInputs',
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', 'flip',
'flip_direction'))
]
train_dataloader = dict(dataset=dict(pipeline=train_pipeline))
default_hooks = dict(param_scheduler=dict(lr_factor=lr_factor))

View File

@ -0,0 +1,19 @@
_base_ = './yolov7_l_fast_1xb16-100e_ionogram.py'
# ======================== Modified parameters =======================
load_from = 'https://download.openmmlab.com/mmyolo/v0/yolov7/yolov7_x_syncbn_fast_8x16b-300e_coco/yolov7_x_syncbn_fast_8x16b-300e_coco_20221124_215331-ef949a68.pth' # noqa
# ===================== Unmodified in most cases ==================
model = dict(
backbone=dict(arch='X'),
neck=dict(
in_channels=[640, 1280, 1280],
out_channels=[160, 320, 640],
block_cfg=dict(
type='ELANBlock',
middle_ratio=0.4,
block_ratio=0.4,
num_blocks=3,
num_convs_in_block=2),
use_repconv_outs=False),
bbox_head=dict(head_module=dict(in_channels=[320, 640, 1280])))