bodangjozinski
commited on
Commit
•
63c91b1
1
Parent(s):
d8414ec
Upload faster_rcnn_resnet101_1xcoco-default-mmdetection-config.py
Browse files# Config - Base MMDetection config
- for usage in the app [IllegalDumpSiteDetectionAndLandfillMonitoring.](https://github.com/IntelligentNetworkSolutions/IllegalDumpSiteDetectionAndLandfillMonitoring.)
- variables for num_batch_size, num_epochs, num_frozen_stages
# Model Weight
- downloaded from:
- page:
[MMDetection Faster RCNN Model Zoo](https://github.com/open-mmlab/mmdetection/tree/main/configs/faster_rcnn)
- specifically:
[MMDetection Trained Faster RCNN on ResNet 101 with COCO - Model File](https://download.openxlab.org.cn/models/mmdetection/FasterR-CNN/weight/faster-rcnn_r101_fpn_1x_coco)
faster_rcnn_resnet101_1xcoco-default-mmdetection-config.py
ADDED
@@ -0,0 +1,193 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
num_batch_size = 2
|
2 |
+
num_epochs = 12
|
3 |
+
num_frozen_stages = 1
|
4 |
+
|
5 |
+
# DATASET
|
6 |
+
dataset_type = 'CocoDataset'
|
7 |
+
data_root = 'data/coco/'
|
8 |
+
|
9 |
+
backend_args = None
|
10 |
+
|
11 |
+
train_pipeline = [
|
12 |
+
dict(type='LoadImageFromFile', backend_args=backend_args),
|
13 |
+
dict(type='LoadAnnotations', with_bbox=True),
|
14 |
+
dict(type='Resize', scale=(1280, 1280), keep_ratio=True),
|
15 |
+
dict(type='RandomFlip', prob=0.5),
|
16 |
+
dict(type='PackDetInputs')
|
17 |
+
]
|
18 |
+
train_dataloader = dict(
|
19 |
+
batch_size=num_batch_size,
|
20 |
+
num_workers=2,
|
21 |
+
persistent_workers=True,
|
22 |
+
sampler=dict(type='DefaultSampler', shuffle=True),
|
23 |
+
batch_sampler=dict(type='AspectRatioBatchSampler'),
|
24 |
+
dataset=dict(
|
25 |
+
type=dataset_type,
|
26 |
+
data_root=data_root,
|
27 |
+
ann_file='train/annotations_coco.json',
|
28 |
+
data_prefix=dict(img='train/'),
|
29 |
+
filter_cfg=dict(filter_empty_gt=True, min_size=32),
|
30 |
+
pipeline=train_pipeline,
|
31 |
+
backend_args=backend_args))
|
32 |
+
|
33 |
+
val_pipeline = [
|
34 |
+
dict(type='LoadImageFromFile', backend_args=backend_args),
|
35 |
+
dict(type='Resize', scale=(1280, 1280), keep_ratio=True),
|
36 |
+
dict(type='LoadAnnotations', with_bbox=True),
|
37 |
+
dict(type='PackDetInputs', meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', 'scale_factor'))
|
38 |
+
]
|
39 |
+
val_dataloader = dict(
|
40 |
+
batch_size=num_batch_size,
|
41 |
+
num_workers=2,
|
42 |
+
persistent_workers=True,
|
43 |
+
drop_last=False,
|
44 |
+
sampler=dict(type='DefaultSampler', shuffle=False),
|
45 |
+
dataset=dict(
|
46 |
+
type=dataset_type,
|
47 |
+
data_root=data_root,
|
48 |
+
ann_file='valid/annotations_coco.json',
|
49 |
+
data_prefix=dict(img='valid/'),
|
50 |
+
test_mode=True,
|
51 |
+
pipeline=val_pipeline,
|
52 |
+
backend_args=backend_args))
|
53 |
+
val_evaluator = dict(
|
54 |
+
type='CocoMetric',
|
55 |
+
ann_file=data_root + 'valid/annotations_coco.json',
|
56 |
+
metric='bbox',
|
57 |
+
format_only=False,
|
58 |
+
backend_args=backend_args)
|
59 |
+
|
60 |
+
test_pipeline = [
|
61 |
+
dict(type='LoadImageFromFile', backend_args=backend_args),
|
62 |
+
dict(type='Resize', scale=(1280, 1280), keep_ratio=True),
|
63 |
+
dict(type='LoadAnnotations', with_bbox=True),
|
64 |
+
dict(type='PackDetInputs', meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', 'scale_factor'))
|
65 |
+
]
|
66 |
+
test_dataloader = dict(
|
67 |
+
batch_size=num_batch_size,
|
68 |
+
num_workers=2,
|
69 |
+
persistent_workers=True,
|
70 |
+
drop_last=False,
|
71 |
+
sampler=dict(type='DefaultSampler', shuffle=False),
|
72 |
+
dataset=dict(
|
73 |
+
type=dataset_type,
|
74 |
+
data_root=data_root,
|
75 |
+
ann_file=data_root + 'test/annotations_coco.json',
|
76 |
+
data_prefix=dict(img='test/'),
|
77 |
+
test_mode=True,
|
78 |
+
pipeline=test_pipeline))
|
79 |
+
test_evaluator = dict(
|
80 |
+
type='CocoMetric',
|
81 |
+
metric='bbox',
|
82 |
+
format_only=True,
|
83 |
+
ann_file=data_root + 'test/annotations_coco.json',
|
84 |
+
outfile_prefix='./work_dirs/coco_detection/test')
|
85 |
+
|
86 |
+
|
87 |
+
# MODEL
|
88 |
+
model = dict(
|
89 |
+
type='FasterRCNN',
|
90 |
+
data_preprocessor=dict(
|
91 |
+
type='DetDataPreprocessor',
|
92 |
+
mean=[123.675, 116.28, 103.53],
|
93 |
+
std=[58.395, 57.12, 57.375],
|
94 |
+
bgr_to_rgb=True,
|
95 |
+
pad_size_divisor=32),
|
96 |
+
backbone=dict(
|
97 |
+
type='ResNet',
|
98 |
+
depth=50,
|
99 |
+
num_stages=4,
|
100 |
+
out_indices=(0, 1, 2, 3),
|
101 |
+
frozen_stages=num_frozen_stages,
|
102 |
+
norm_cfg=dict(type='BN', requires_grad=True),
|
103 |
+
norm_eval=True,
|
104 |
+
style='pytorch',
|
105 |
+
init_cfg=dict(type='Pretrained', checkpoint='https://download.openxlab.org.cn/models/mmdetection/FasterR-CNN/weight/faster-rcnn_r101_fpn_1x_coco')),
|
106 |
+
neck=dict(type='FPN', in_channels=[256, 512, 1024, 2048], out_channels=256, num_outs=5),
|
107 |
+
rpn_head=dict(
|
108 |
+
type='RPNHead',
|
109 |
+
in_channels=256, feat_channels=256,
|
110 |
+
anchor_generator=dict(type='AnchorGenerator', scales=[8], ratios=[0.5, 1.0, 2.0], strides=[4, 8, 16, 32, 64]),
|
111 |
+
bbox_coder=dict(type='DeltaXYWHBBoxCoder', target_means=[.0, .0, .0, .0], target_stds=[1.0, 1.0, 1.0, 1.0]),
|
112 |
+
loss_cls=dict(type='CrossEntropyLoss', use_sigmoid=True, loss_weight=1.0),
|
113 |
+
loss_bbox=dict(type='L1Loss', loss_weight=1.0)),
|
114 |
+
roi_head=dict(
|
115 |
+
type='StandardRoIHead',
|
116 |
+
bbox_roi_extractor=dict(
|
117 |
+
type='SingleRoIExtractor',
|
118 |
+
roi_layer=dict(type='RoIAlign', output_size=7, sampling_ratio=0),
|
119 |
+
out_channels=256, featmap_strides=[4, 8, 16, 32]),
|
120 |
+
bbox_head=dict(
|
121 |
+
type='Shared2FCBBoxHead',
|
122 |
+
in_channels=256,
|
123 |
+
fc_out_channels=1024,
|
124 |
+
roi_feat_size=7,
|
125 |
+
num_classes=80,
|
126 |
+
bbox_coder=dict(type='DeltaXYWHBBoxCoder', target_means=[0., 0., 0., 0.], target_stds=[0.1, 0.1, 0.2, 0.2]),
|
127 |
+
reg_class_agnostic=False,
|
128 |
+
loss_cls=dict(type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0),
|
129 |
+
loss_bbox=dict(type='L1Loss', loss_weight=1.0))),
|
130 |
+
# model training and testing settings
|
131 |
+
train_cfg=dict(
|
132 |
+
rpn=dict(
|
133 |
+
assigner=dict(
|
134 |
+
type='MaxIoUAssigner',
|
135 |
+
pos_iou_thr=0.7, neg_iou_thr=0.3, min_pos_iou=0.3,
|
136 |
+
match_low_quality=True, ignore_iof_thr=-1),
|
137 |
+
sampler=dict(type='RandomSampler', num=256, pos_fraction=0.5, neg_pos_ub=-1, add_gt_as_proposals=False),
|
138 |
+
allowed_border=-1, pos_weight=-1, debug=False),
|
139 |
+
rpn_proposal=dict(nms_pre=2000, max_per_img=1000, nms=dict(type='nms', iou_threshold=0.7), min_bbox_size=0),
|
140 |
+
rcnn=dict(
|
141 |
+
assigner=dict(
|
142 |
+
type='MaxIoUAssigner',
|
143 |
+
pos_iou_thr=0.5, neg_iou_thr=0.5, min_pos_iou=0.5,
|
144 |
+
match_low_quality=False, ignore_iof_thr=-1),
|
145 |
+
sampler=dict(type='RandomSampler', num=512, pos_fraction=0.25, neg_pos_ub=-1, add_gt_as_proposals=True),
|
146 |
+
pos_weight=-1,
|
147 |
+
debug=False)),
|
148 |
+
test_cfg=dict(
|
149 |
+
rpn=dict(nms_pre=1000, max_per_img=1000, nms=dict(type='nms', iou_threshold=0.7), min_bbox_size=0),
|
150 |
+
rcnn=dict(score_thr=0.05, nms=dict(type='nms', iou_threshold=0.5), max_per_img=100)
|
151 |
+
))
|
152 |
+
|
153 |
+
# RUNTIME
|
154 |
+
default_scope = 'mmdet'
|
155 |
+
|
156 |
+
default_hooks = dict(
|
157 |
+
timer=dict(type='IterTimerHook'),
|
158 |
+
logger=dict(type='LoggerHook', interval=50),
|
159 |
+
param_scheduler=dict(type='ParamSchedulerHook'),
|
160 |
+
checkpoint=dict(type='CheckpointHook', interval=1),
|
161 |
+
sampler_seed=dict(type='DistSamplerSeedHook'),
|
162 |
+
visualization=dict(type='DetVisualizationHook'))
|
163 |
+
|
164 |
+
env_cfg = dict(
|
165 |
+
cudnn_benchmark=False,
|
166 |
+
mp_cfg=dict(mp_start_method='fork', opencv_num_threads=0),
|
167 |
+
dist_cfg=dict(backend='nccl'),
|
168 |
+
)
|
169 |
+
|
170 |
+
vis_backends = [dict(type='LocalVisBackend')]
|
171 |
+
visualizer = dict(type='DetLocalVisualizer', vis_backends=vis_backends, name='visualizer')
|
172 |
+
log_processor = dict(type='LogProcessor', window_size=50, by_epoch=True)
|
173 |
+
|
174 |
+
log_level = 'INFO'
|
175 |
+
load_from = None
|
176 |
+
resume = False
|
177 |
+
|
178 |
+
# SCHEDULE
|
179 |
+
# training schedule for 1x
|
180 |
+
train_cfg = dict(type='EpochBasedTrainLoop', max_epochs=num_epochs, val_interval=1)
|
181 |
+
val_cfg = dict(type='ValLoop')
|
182 |
+
test_cfg = dict(type='TestLoop')
|
183 |
+
|
184 |
+
# learning rate
|
185 |
+
param_scheduler = [
|
186 |
+
dict(type='LinearLR', start_factor=0.001, by_epoch=False, begin=0, end=500),
|
187 |
+
dict(type='MultiStepLR', begin=0, end=12, by_epoch=True, milestones=[8, 11], gamma=0.1)
|
188 |
+
]
|
189 |
+
|
190 |
+
# optimizer
|
191 |
+
optim_wrapper = dict(type='OptimWrapper', optimizer=dict(type='SGD', lr=0.02, momentum=0.9, weight_decay=0.0001))
|
192 |
+
|
193 |
+
auto_scale_lr = dict(enable=False, base_batch_size=16)
|