Skip to content

Commit 9dd6877

Browse files
nullptrbaorepo
authored andcommitted
chore: update docs, fix config bugs
1 parent 4359ca4 commit 9dd6877

File tree

4 files changed

+112
-116
lines changed

4 files changed

+112
-116
lines changed

configs/rtmdet/rtmdet_nano_8xb32_300e_coco_ncadc_relu6.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from mmengine.config import read_base
22

33
with read_base():
4-
from ._base_.default_runtime import *
5-
from ._base_.schedules.schedule_1x import *
6-
from .datasets.coco_detection import *
4+
from .._base_.default_runtime import *
5+
from .._base_.schedules.schedule_1x import *
6+
from ..datasets.coco_detection import *
77

88
from torchvision.ops import nms
99
from torch.nn import ReLU, BatchNorm2d, ReLU6
@@ -68,7 +68,13 @@
6868
# Number of cached images in mixup
6969
mixup_max_cached_images = 10
7070

71-
checkpoint = "http://192.168.1.77/epoch_593_top1_59.06.pth"
71+
train_ann_file = "annotations/instances_train2017.json"
72+
val_ann_file = "annotations/instances_val2017.json"
73+
train_img_prefix = "train2017/"
74+
val_img_prefix = "val2017/"
75+
76+
77+
checkpoint = "https://download.openmmlab.com/mmdetection/v3.0/rtmdet/cspnext_rsb_pretrain/cspnext-s_imagenet_600e.pth"
7278
model = dict(
7379
type=RTMDet,
7480
data_preprocessor=dict(
@@ -242,7 +248,7 @@
242248
pin_memory=True,
243249
collate_fn=coco_collate,
244250
dataset=dict(
245-
pipeline=train_pipeline, ann_file="annotations/instances_train2017.json"
251+
pipeline=train_pipeline, ann_file=train_ann_file, data_prefix=dict(img=train_img_prefix)
246252
),
247253
)
248254
)
@@ -267,8 +273,8 @@
267273
dataset=dict(
268274
type=dataset_type,
269275
data_root=data_root,
270-
ann_file="annotations/instances_val2017.json",
271-
data_prefix=dict(img="val2017/"),
276+
ann_file=val_ann_file,
277+
data_prefix=dict(img=val_img_prefix),
272278
test_mode=True,
273279
pipeline=test_pipeline,
274280
batch_shapes_cfg=batch_shapes_cfg,

configs/rtmdet/rtmdet_nano_8xb32_300e_coco_relu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
# Number of cached images in mixup
6969
mixup_max_cached_images = 10
7070

71-
checkpoint = "http://192.168.1.77/epoch_593_top1_59.06.pth"
71+
checkpoint = "https://download.openmmlab.com/mmdetection/v3.0/rtmdet/cspnext_rsb_pretrain/cspnext-s_imagenet_600e.pth"
7272
model = dict(
7373
type=RTMDet,
7474
data_preprocessor=dict(

docs/tutorials/training/rtmdet.md

Lines changed: 49 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -11,72 +11,69 @@ Before training the RTMDet model, we need to prepare the dataset. Here, we take
1111
SSCMA offers various RTMDet model configurations, and you can choose the appropriate model for training based on your needs.
1212

1313
```sh
14-
rtmdet_l_8xb32_300e_coco.py
15-
rtmdet_m_8xb32_300e_coco.py
16-
rtmdet_mnv4_8xb32_300e_coco.py
17-
rtmdet_nano_8xb32_300e_coco.py
14+
rtmdet_nano_8xb32_300e_coco_ncadc_relu6.py
1815
rtmdet_nano_8xb32_300e_coco_relu.py
1916
rtmdet_nano_8xb32_300e_coco_relu_q.py
20-
rtmdet_s_8xb32_300e_coco.py
2117
```
2218

23-
Here, we take `rtmdet_nano_8xb32_300e_coco.py` as an example to show how to use SSCMA for RTMDet model training.
19+
Here, we take `rtmdet_nano_8xb32_300e_coco_ncadc_relu6.py` as an example to show how to use SSCMA for RTMDet model training.
2420

2521
```sh
2622
python3 tools/train.py \
27-
configs/rtmdet_nano_8xb32_300e_coco.py \
23+
configs/rtmdet/rtmdet_nano_8xb32_300e_coco_ncadc_relu6.py \
2824
--cfg-options \
2925
data_root=$(pwd)/datasets/coco_mask/mask/ \
3026
num_classes=2 \
3127
train_ann_file=train/_annotations.coco.json \
3228
val_ann_file=valid/_annotations.coco.json \
3329
train_img_prefix=train/ \
3430
val_img_prefix=valid/ \
35-
max_epochs=150 \
31+
epochs=150 \
3632
imgsz='(192,192)'
3733
```
3834

39-
- `configs/rtmdet_nano_8xb32_300e_coco.py`: Specifies the configuration file, defining the model and training settings.
35+
- `configs/rtmdet/rtmdet_nano_8xb32_300e_coco_ncadc_relu6.py`: Specifies the configuration file, defining the model and training settings.
4036
- `--cfg-options`: Used to specify additional configuration options.
4137
- `data_root`: Sets the root directory of the dataset.
4238
- `num_classes`: Specifies the number of categories the model needs to recognize.
4339
- `train_ann_file`: Specifies the path to the annotation file for training data.
4440
- `val_ann_file`: Specifies the path to the annotation file for validation data.
4541
- `train_img_prefix`: Specifies the prefix path for training images.
4642
- `val_img_prefix`: Specifies the prefix path for validation images.
47-
- `max_epochs`: Sets the maximum number of training epochs.
43+
- `epochs`: Sets the maximum number of training epochs.
4844
- `imgsz`: Specifies the image size used for model training.
4945

50-
After the training is complete, you can find the trained model in the `work_dirs/rtmdet_nano_8xb32_300e_coco` directory. Before looking for the model, we suggest focusing on the training results first. Below is an analysis of the results and some suggestions for improvement.
46+
After the training is complete, you can find the trained model in the `work_dirs/rtmdet_nano_8xb32_300e_coco_ncadc_relu6` directory. Before looking for the model, we suggest focusing on the training results first. Below is an analysis of the results and some suggestions for improvement.
5147

5248
:::details
5349

5450
```sh
55-
12/17 03:55:23 - mmengine - INFO - Saving checkpoint at 150 epochs
56-
12/17 03:55:24 - mmengine - INFO - Evaluating bbox...
51+
12/19 03:35:57 - mmengine - INFO - Epoch(train) [150][30/30] base_lr: 2.5000e-05 lr: 2.5000e-05 eta: 0:00:00 time: 0.1145 data_time: 0.0051 memory: 383 loss: 0.6947 loss_cls: 0.3424 loss_bbox: 0.3523
52+
12/19 03:35:57 - mmengine - INFO - Saving checkpoint at 150 epochs
53+
12/19 03:35:58 - mmengine - INFO - Evaluating bbox...
5754
Loading and preparing results...
58-
DONE (t=0.02s)
55+
DONE (t=0.30s)
5956
creating index...
6057
index created!
6158
Running per image evaluation...
6259
Evaluate annotation type *bbox*
6360
DONE (t=0.31s).
6461
Accumulating evaluation results...
6562
DONE (t=0.06s).
66-
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.506
67-
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.946
68-
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.456
63+
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.409
64+
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.930
65+
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.253
6966
Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = -1.000
7067
Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.000
71-
Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.517
72-
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.547
73-
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.591
74-
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.608
68+
Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.413
69+
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.437
70+
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.566
71+
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.574
7572
Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = -1.000
76-
Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.100
77-
Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.612
78-
12/17 03:55:24 - mmengine - INFO - bbox_mAP_copypaste: 0.506 0.946 0.456 -1.000 0.000 0.517
79-
12/17 03:55:24 - mmengine - INFO - Epoch(val) [150][6/6] coco/bbox_mAP: 0.5060 coco/bbox_mAP_50: 0.9460 coco/bbox_mAP_75: 0.4560 coco/bbox_mAP_s: -1.0000 coco/bbox_mAP_m: 0.0000 coco/bbox_mAP_l: 0.5170 data_time: 0.0205 time: 0.0563
73+
Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.000
74+
Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.579
75+
12/19 03:35:59 - mmengine - INFO - bbox_mAP_copypaste: 0.409 0.930 0.253 -1.000 0.000 0.413
76+
12/19 03:35:59 - mmengine - INFO - Epoch(val) [150][6/6] coco/bbox_mAP: 0.4090 coco/bbox_mAP_50: 0.9300 coco/bbox_mAP_75: 0.2530 coco/bbox_mAP_s: -1.0000 coco/bbox_mAP_m: 0.0000 coco/bbox_mAP_l: 0.4130 data_time: 0.0629 time: 0.1037
8077
```
8178

8279
By analyzing the COCO Eval results, we can identify issues and take corresponding measures for optimization. The optimization direction is suggested to start with the dataset, followed by training parameters, and then the model structure.
@@ -108,7 +105,7 @@ Under the Scalars tab, you can view the changes of recorded scalar metrics (such
108105

109106
:::
110107

111-
Find the trained model in the `work_dirs/rtmdet_nano_8xb32_300e_coco` directory. In addition, when the model training result accuracy is poor, you can analyze the COCO Eval results to find the problem and take corresponding measures for optimization.
108+
Find the trained model in the `work_dirs/rtmdet_nano_8xb32_300e_coco_ncadc_relu6` directory. In addition, when the model training result accuracy is poor, you can analyze the COCO Eval results to find the problem and take corresponding measures for optimization.
112109

113110
:::tip
114111

@@ -127,8 +124,8 @@ Here, we take exporting the TFLite model as an example. You can use the followin
127124

128125
```sh
129126
python3 tools/export.py \
130-
configs/rtmdet_nano_8xb32_300e_coco.py \
131-
work_dirs/rtmdet_nano_8xb32_300e_coco/epoch_150.pth \
127+
configs/rtmdet/rtmdet_nano_8xb32_300e_coco_ncadc_relu6.py \
128+
work_dirs/rtmdet_nano_8xb32_300e_coco_ncadc_relu6/epoch_150.pth \
132129
--cfg-options \
133130
data_root=$(pwd)/datasets/coco_mask/mask/ \
134131
num_classes=2 \
@@ -177,8 +174,8 @@ After exporting, you can use the following command to verify the TFLite Int8 mod
177174

178175
```sh
179176
python3 tools/test.py \
180-
configs/rtmdet_nano_8xb32_300e_coco.py \
181-
work_dirs/rtmdet_nano_8xb32_300e_coco/epoch_150_int8.tflite \
177+
configs/rtmdet/rtmdet_nano_8xb32_300e_coco_ncadc_relu6.py \
178+
work_dirs/rtmdet_nano_8xb32_300e_coco_ncadc_relu6/epoch_150_int8.tflite \
182179
--cfg-options \
183180
data_root=$(pwd)/datasets/coco_mask/mask/ \
184181
num_classes=2 \
@@ -192,22 +189,20 @@ python3 tools/test.py \
192189
You will get the following output:
193190

194191
```sh
195-
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.046
196-
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.112
197-
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.019
192+
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.409
193+
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.934
194+
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.284
198195
Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = -1.000
199196
Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.000
200-
Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.050
201-
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.106
202-
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.165
203-
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.352
197+
Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.413
198+
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.433
199+
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.559
200+
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.563
204201
Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = -1.000
205-
Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.200
206-
Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.353
202+
Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.000
203+
Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.568
207204
```
208205

209-
From the verification results, it can be seen that the exported model's performance on the verification set is different from its performance during training, with a decrease of 46.0% in AP@50:95 and a decrease of 83.4% in AP@50. You can try using QAT to reduce the loss of quantization accuracy.
210-
211206
:::tip
212207

213208
For a detailed explanation of the above output, please refer to [COCO Dataset Evaluation Metrics](https://cocodataset.org/#detection-eval), where we mainly focus on mAP at 50-95 IoU and 50 IoU.
@@ -221,8 +216,8 @@ QAT (Quantization-Aware Training) is a method that simulates quantization operat
221216

222217
```sh
223218
python3 tools/quantization.py \
224-
configs/rtmdet_nano_8xb32_300e_coco.py \
225-
work_dirs/rtmdet_nano_8xb32_300e_coco/epoch_150.pth \
219+
configs/rtmdet/rtmdet_nano_8xb32_300e_coco_ncadc_relu6.py \
220+
work_dirs/rtmdet_nano_8xb32_300e_coco_ncadc_relu6/epoch_150.pth \
226221
--cfg-options \
227222
data_root=$(pwd)/datasets/coco_mask/mask/ \
228223
num_classes=2 \
@@ -231,7 +226,7 @@ python3 tools/quantization.py \
231226
train_img_prefix=train/ \
232227
val_img_prefix=valid/ \
233228
imgsz='(192,192)' \
234-
max_epochs=5
229+
epochs=5
235230
```
236231

237232
:::details
@@ -272,8 +267,8 @@ After QAT training is completed, the quantized model will be automatically expor
272267

273268
```sh
274269
python3 tools/test.py \
275-
configs/rtmdet_nano_8xb32_300e_coco.py \
276-
work_dirs/rtmdet_nano_8xb32_300e_coco/qat/qat_model_int8.tflite \
270+
configs/rtmdet/rtmdet_nano_8xb32_300e_coco_ncadc_relu6.py \
271+
work_dirs/rtmdet_nano_8xb32_300e_coco_ncadc_relu6/qat/qat_model_int8.tflite \
277272
--cfg-options \
278273
data_root=$(pwd)/datasets/coco_mask/mask/ \
279274
num_classes=2 \
@@ -287,16 +282,16 @@ python3 tools/test.py \
287282
The evalution results are shown below:
288283

289284
```sh
290-
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.091
291-
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.209
292-
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.069
285+
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.455
286+
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.842
287+
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.417
293288
Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = -1.000
294289
Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.000
295-
Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.094
296-
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.138
297-
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.185
298-
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.311
290+
Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.459
291+
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.499
292+
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.583
293+
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.618
299294
Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = -1.000
300295
Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.000
301-
Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.314
296+
Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.623
302297
```

0 commit comments

Comments
 (0)