1
+ # CMNeXt Detection with RCNN detector
2
+ # custom_configs/DELIVER/deliver_cmnext_rcnn.py
3
+ import os
4
+ _base_ = [
5
+ './deliver_dataset.py' # Inherit dataset config
6
+ ]
7
+
8
+ data_root = '/SSDb/jemo_maeng/dset/DELIVER'
9
+
10
+ # Model settings
11
+ model = dict (
12
+ type = 'FasterRCNN' ,
13
+ data_preprocessor = _base_ .data_preprocessor , # This comes from _base_
14
+ backbone = dict (
15
+ type = 'CMNextBackbone' ,
16
+ backbone = 'CMNeXt-B2' ,
17
+ modals = ['rgb' , 'depth' , 'event' , 'lidar' ],
18
+ out_indices = (0 , 1 , 2 , 3 ),
19
+ frozen_stages = - 1 ,
20
+ pretrained = '/SSDb/jemo_maeng/src/Project/Drone24/detection/drone-mmdetection-jm/pretrained_weights/segformer/mit_b2.pth'
21
+ ),
22
+ neck = dict (
23
+ type = 'FPN' , # MMDetection 표준 FPN 사용
24
+ in_channels = [64 , 128 , 320 , 512 ],
25
+ out_channels = 256 ,
26
+ num_outs = 5
27
+ ),
28
+ rpn_head = dict (
29
+ type = 'RPNHead' ,
30
+ in_channels = 256 ,
31
+ feat_channels = 256 ,
32
+ anchor_generator = dict (
33
+ type = 'AnchorGenerator' , # 32 16 8 4
34
+ # scales=[8],
35
+ scales = [2 , 4 , 8 , 16 ],
36
+ ratios = [0.5 , 1.0 , 2.0 ],
37
+ strides = [4 , 8 , 16 , 32 , 64 ]
38
+ ),
39
+ bbox_coder = dict (
40
+ type = 'DeltaXYWHBBoxCoder' ,
41
+ target_means = [.0 , .0 , .0 , .0 ],
42
+ target_stds = [1.0 , 1.0 , 1.0 , 1.0 ]
43
+ ),
44
+ loss_cls = dict (
45
+ type = 'CrossEntropyLoss' , use_sigmoid = True , loss_weight = 1.0
46
+ ),
47
+ loss_bbox = dict (type = 'L1Loss' , loss_weight = 1.0 )
48
+ ),
49
+ roi_head = dict (
50
+ type = 'StandardRoIHead' ,
51
+ bbox_roi_extractor = dict (
52
+ type = 'SingleRoIExtractor' ,
53
+ roi_layer = dict (type = 'RoIAlign' , output_size = 7 , sampling_ratio = 0 ),
54
+ out_channels = 256 ,
55
+ featmap_strides = [4 , 8 , 16 , 32 ]
56
+ ),
57
+ bbox_head = dict (
58
+ type = 'Shared2FCBBoxHead' ,
59
+ in_channels = 256 ,
60
+ fc_out_channels = 1024 ,
61
+ roi_feat_size = 7 ,
62
+ num_classes = 2 , # Vehicle, Human
63
+ bbox_coder = dict (
64
+ type = 'DeltaXYWHBBoxCoder' ,
65
+ target_means = [0. , 0. , 0. , 0. ],
66
+ target_stds = [0.1 , 0.1 , 0.2 , 0.2 ]
67
+ ),
68
+ reg_class_agnostic = False ,
69
+ loss_cls = dict (
70
+ type = 'CrossEntropyLoss' , use_sigmoid = False , loss_weight = 1.0
71
+ ),
72
+ loss_bbox = dict (type = 'L1Loss' , loss_weight = 1.0 )
73
+ )
74
+ ),
75
+ # Training config
76
+ train_cfg = dict (
77
+ rpn = dict (
78
+ assigner = dict (
79
+ type = 'MaxIoUAssigner' ,
80
+ pos_iou_thr = 0.7 ,
81
+ neg_iou_thr = 0.3 ,
82
+ min_pos_iou = 0.3 ,
83
+ match_low_quality = True ,
84
+ ignore_iof_thr = - 1
85
+ ),
86
+ sampler = dict (
87
+ type = 'RandomSampler' ,
88
+ num = 256 ,
89
+ pos_fraction = 0.5 ,
90
+ neg_pos_ub = - 1 ,
91
+ add_gt_as_proposals = False
92
+ ),
93
+ allowed_border = - 1 ,
94
+ pos_weight = - 1 ,
95
+ debug = False
96
+ ),
97
+ rpn_proposal = dict (
98
+ nms_pre = 2000 ,
99
+ max_per_img = 1000 ,
100
+ nms = dict (type = 'nms' , iou_threshold = 0.7 ),
101
+ min_bbox_size = 0
102
+ ),
103
+ rcnn = dict (
104
+ assigner = dict (
105
+ type = 'MaxIoUAssigner' ,
106
+ pos_iou_thr = 0.5 , # 🔥 0.5 → 0.3
107
+ neg_iou_thr = 0.5 , # 🔥 0.5 → 0.1
108
+ min_pos_iou = 0.5 , # 🔥 0.5 → 0.1
109
+ match_low_quality = False , # 🔥 False → True
110
+ ignore_iof_thr = - 1
111
+ ),
112
+ sampler = dict (
113
+ type = 'RandomSampler' ,
114
+ num = 512 ,
115
+ pos_fraction = 0.25 ,
116
+ neg_pos_ub = - 1 ,
117
+ add_gt_as_proposals = True
118
+ ),
119
+ pos_weight = - 1 ,
120
+ debug = False
121
+ )
122
+ ),
123
+ # Testing config
124
+ test_cfg = dict (
125
+ rpn = dict (
126
+ nms_pre = 1000 ,
127
+ max_per_img = 1000 ,
128
+ nms = dict (type = 'nms' , iou_threshold = 0.7 ),
129
+ min_bbox_size = 0
130
+ ),
131
+ rcnn = dict (
132
+ score_thr = 0.05 ,
133
+ nms = dict (type = 'nms' , iou_threshold = 0.5 ),
134
+ max_per_img = 100
135
+ )
136
+ )
137
+ )
138
+
139
+ train_dataloader = dict (
140
+ batch_size = 8 ,
141
+ num_workers = 2 ,
142
+ persistent_workers = True ,
143
+ sampler = dict (type = 'DefaultSampler' , shuffle = True ),
144
+ dataset = dict (
145
+ data_root = data_root ,
146
+ ann_file = 'coco_train_xywh.json' ,
147
+ ),
148
+ )
149
+
150
+ val_dataloader = dict (
151
+ batch_size = 1 ,
152
+ num_workers = 2 ,
153
+ persistent_workers = True ,
154
+ drop_last = False ,
155
+ sampler = dict (type = 'DefaultSampler' , shuffle = False ),
156
+ dataset = dict (
157
+ data_root = data_root ,
158
+ ann_file = 'coco_val_xywh.json' ,
159
+ ),
160
+ )
161
+
162
+ test_dataloader = val_dataloader
163
+
164
+ # Evaluation settings
165
+ val_evaluator = dict (
166
+ type = 'CocoMetric' ,
167
+ ann_file = os .path .join (data_root , 'coco_val_xywh.json' ), # Fixed: consistent with dataset
168
+ metric = 'bbox' ,
169
+ format_only = False
170
+ )
171
+ train_cfg = dict (
172
+ type = 'EpochBasedTrainLoop' ,
173
+ max_epochs = 50 ,
174
+ val_interval = 5 )
175
+
176
+
177
+ optim_wrapper = dict (
178
+ type = 'OptimWrapper' ,
179
+ optimizer = dict (type = 'SGD' , lr = 0.01 , momentum = 0.9 , weight_decay = 0.0001 ),
180
+ clip_grad = dict (max_norm = 5 , norm_type = 2 ),
181
+ accumulative_counts = 4
182
+ )
183
+
184
+ param_scheduler = [
185
+ dict (
186
+ type = 'LinearLR' ,
187
+ start_factor = 0.001 ,
188
+ by_epoch = False ,
189
+ begin = 0 ,
190
+ end = 500 ), # warmup
191
+ dict (
192
+ type = 'CosineAnnealingLR' ,
193
+ T_max = 100 , # cosine annealing
194
+ by_epoch = True ,
195
+ begin = 10 ,
196
+ end = 50 ,
197
+ eta_min = 1e-6 )
198
+ ]
199
+
200
+ vis_backends = [
201
+ dict (type = 'LocalVisBackend' ),
202
+ dict (
203
+ type = 'WandbVisBackend' ,
204
+ init_kwargs = dict (
205
+ project = 'DELIVER' ,
206
+ name = 'hinton-deliver_cmnext_rcnn_lr0.01_ep50' ,
207
+ tags = ['CMNeXt' , 'RCNN' , 'full-finetune' , 'epoch-50' ],
208
+ notes = 'CMNeXt RCNN with epoch 50 cosinelr' ,
209
+ save_code = True
210
+ ),
211
+ define_metric_cfg = dict (
212
+ loss_cls = dict (summary = 'min' ),
213
+ loss_bbox = dict (summary = 'min' ),
214
+ loss_iou = dict (summary = 'min' ),
215
+ loss = dict (summary = 'min' ),
216
+ bbox_mAP = dict (summary = 'max' ),
217
+ bbox_mAP_50 = dict (summary = 'max' ),
218
+ bbox_mAP_75 = dict (summary = 'max' )
219
+ )
220
+ )
221
+ ]
222
+
223
+
224
+ # Experiment name for logging
225
+ experiment_name = 'deliver_cmnext_b2_faster_rcnn_2x_cosinelr0.01_ep50'
226
+
227
+ # Override work_dir if needed
228
+ work_dir = f'./work_dirs/{ experiment_name } '
0 commit comments