ZJF-Thunder
commited on
Commit
·
e26e560
1
Parent(s):
bf05784
添加文件
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .dev_scripts/batch_test.py +212 -0
- .dev_scripts/batch_test.sh +19 -0
- .dev_scripts/benchmark_filter.py +158 -0
- .dev_scripts/convert_benchmark_script.py +86 -0
- .dev_scripts/gather_benchmark_metric.py +142 -0
- .dev_scripts/gather_models.py +162 -0
- .dev_scripts/linter.sh +3 -0
- .gitattributes +2 -1
- .github/CODE_OF_CONDUCT.md +76 -0
- .github/CONTRIBUTING.md +1 -0
- .github/ISSUE_TEMPLATE/config.yml +9 -0
- .github/ISSUE_TEMPLATE/error-report.md +47 -0
- .github/ISSUE_TEMPLATE/feature_request.md +22 -0
- .github/ISSUE_TEMPLATE/general_questions.md +8 -0
- .github/ISSUE_TEMPLATE/reimplementation_questions.md +68 -0
- .github/workflows/build.yml +142 -0
- .github/workflows/build_pat.yml +24 -0
- .github/workflows/deploy.yml +24 -0
- .pre-commit-config.yaml +40 -0
- .readthedocs.yml +7 -0
- LICENSE +220 -0
- configs/_base_/datasets/cityscapes_detection.py +55 -0
- configs/_base_/datasets/cityscapes_instance.py +55 -0
- configs/_base_/datasets/coco_detection.py +56 -0
- configs/_base_/datasets/coco_instance.py +50 -0
- configs/_base_/datasets/coco_instance_semantic.py +53 -0
- configs/_base_/datasets/deepfashion.py +53 -0
- configs/_base_/datasets/lvis_v0.5_instance.py +23 -0
- configs/_base_/datasets/lvis_v1_instance.py +23 -0
- configs/_base_/datasets/voc0712.py +55 -0
- configs/_base_/datasets/wider_face.py +63 -0
- configs/_base_/default_runtime.py +29 -0
- configs/_base_/models/cascade_mask_rcnn_r50_fpn.py +196 -0
- configs/_base_/models/cascade_mask_rcnn_swin_fpn.py +207 -0
- configs/_base_/models/cascade_rcnn_r50_fpn.py +179 -0
- configs/_base_/models/fast_rcnn_r50_fpn.py +62 -0
- configs/_base_/models/faster_rcnn_r50_caffe_c4.py +112 -0
- configs/_base_/models/faster_rcnn_r50_caffe_dc5.py +103 -0
- configs/_base_/models/faster_rcnn_r50_fpn.py +107 -0
- configs/_base_/models/mask_rcnn_r50_caffe_c4.py +123 -0
- configs/_base_/models/mask_rcnn_r50_fpn.py +120 -0
- configs/_base_/models/mask_rcnn_swin_fpn.py +136 -0
- configs/_base_/models/mask_reppointsv2_swin_bifpn.py +124 -0
- configs/_base_/models/reppointsv2_swin_bifpn.py +91 -0
- configs/_base_/models/retinanet_r50_fpn.py +60 -0
- configs/_base_/models/rpn_r50_caffe_c4.py +56 -0
- configs/_base_/models/rpn_r50_fpn.py +59 -0
- configs/_base_/models/ssd300.py +50 -0
- configs/_base_/schedules/schedule_1x.py +11 -0
- configs/_base_/schedules/schedule_20e.py +11 -0
.dev_scripts/batch_test.py
ADDED
@@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
some instructions
|
3 |
+
1. Fill the models that needs to be checked in the modelzoo_dict
|
4 |
+
2. Arange the structure of the directory as follows, the script will find the
|
5 |
+
corresponding config itself:
|
6 |
+
model_dir/model_family/checkpoints
|
7 |
+
e.g.: models/faster_rcnn/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth
|
8 |
+
models/faster_rcnn/faster_rcnn_r101_fpn_1x_coco_20200130-047c8118.pth
|
9 |
+
3. Excute the batch_test.sh
|
10 |
+
"""
|
11 |
+
|
12 |
+
import argparse
|
13 |
+
import json
|
14 |
+
import os
|
15 |
+
import subprocess
|
16 |
+
|
17 |
+
import mmcv
|
18 |
+
import torch
|
19 |
+
from mmcv import Config, get_logger
|
20 |
+
from mmcv.parallel import MMDataParallel, MMDistributedDataParallel
|
21 |
+
from mmcv.runner import (get_dist_info, init_dist, load_checkpoint,
|
22 |
+
wrap_fp16_model)
|
23 |
+
|
24 |
+
from mmdet.apis import multi_gpu_test, single_gpu_test
|
25 |
+
from mmdet.datasets import (build_dataloader, build_dataset,
|
26 |
+
replace_ImageToTensor)
|
27 |
+
from mmdet.models import build_detector
|
28 |
+
|
29 |
+
modelzoo_dict = {
|
30 |
+
'configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py': {
|
31 |
+
'bbox': 0.374
|
32 |
+
},
|
33 |
+
'configs/mask_rcnn/mask_rcnn_r50_fpn_1x_coco.py': {
|
34 |
+
'bbox': 0.382,
|
35 |
+
'segm': 0.347
|
36 |
+
},
|
37 |
+
'configs/rpn/rpn_r50_fpn_1x_coco.py': {
|
38 |
+
'AR@1000': 0.582
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
|
43 |
+
def parse_args():
|
44 |
+
parser = argparse.ArgumentParser(
|
45 |
+
description='The script used for checking the correctness \
|
46 |
+
of batch inference')
|
47 |
+
parser.add_argument('model_dir', help='directory of models')
|
48 |
+
parser.add_argument(
|
49 |
+
'json_out', help='the output json records test information like mAP')
|
50 |
+
parser.add_argument(
|
51 |
+
'--launcher',
|
52 |
+
choices=['none', 'pytorch', 'slurm', 'mpi'],
|
53 |
+
default='none',
|
54 |
+
help='job launcher')
|
55 |
+
parser.add_argument('--local_rank', type=int, default=0)
|
56 |
+
args = parser.parse_args()
|
57 |
+
if 'LOCAL_RANK' not in os.environ:
|
58 |
+
os.environ['LOCAL_RANK'] = str(args.local_rank)
|
59 |
+
return args
|
60 |
+
|
61 |
+
|
62 |
+
def check_finish(all_model_dict, result_file):
|
63 |
+
# check if all models are checked
|
64 |
+
tested_cfgs = []
|
65 |
+
with open(result_file, 'r+') as f:
|
66 |
+
for line in f:
|
67 |
+
line = json.loads(line)
|
68 |
+
tested_cfgs.append(line['cfg'])
|
69 |
+
is_finish = True
|
70 |
+
for cfg in sorted(all_model_dict.keys()):
|
71 |
+
if cfg not in tested_cfgs:
|
72 |
+
return cfg
|
73 |
+
if is_finish:
|
74 |
+
with open(result_file, 'a+') as f:
|
75 |
+
f.write('finished\n')
|
76 |
+
|
77 |
+
|
78 |
+
def dump_dict(record_dict, json_out):
|
79 |
+
# dump result json dict
|
80 |
+
with open(json_out, 'a+') as f:
|
81 |
+
mmcv.dump(record_dict, f, file_format='json')
|
82 |
+
f.write('\n')
|
83 |
+
|
84 |
+
|
85 |
+
def main():
|
86 |
+
args = parse_args()
|
87 |
+
# touch the output json if not exist
|
88 |
+
with open(args.json_out, 'a+'):
|
89 |
+
pass
|
90 |
+
# init distributed env first, since logger depends on the dist
|
91 |
+
# info.
|
92 |
+
if args.launcher == 'none':
|
93 |
+
distributed = False
|
94 |
+
else:
|
95 |
+
distributed = True
|
96 |
+
init_dist(args.launcher, backend='nccl')
|
97 |
+
rank, world_size = get_dist_info()
|
98 |
+
|
99 |
+
logger = get_logger('root')
|
100 |
+
|
101 |
+
# read info of checkpoints and config
|
102 |
+
result_dict = dict()
|
103 |
+
for model_family_dir in os.listdir(args.model_dir):
|
104 |
+
for model in os.listdir(
|
105 |
+
os.path.join(args.model_dir, model_family_dir)):
|
106 |
+
# cpt: rpn_r50_fpn_1x_coco_20200218-5525fa2e.pth
|
107 |
+
# cfg: rpn_r50_fpn_1x_coco.py
|
108 |
+
cfg = model.split('.')[0][:-18] + '.py'
|
109 |
+
cfg_path = os.path.join('configs', model_family_dir, cfg)
|
110 |
+
assert os.path.isfile(
|
111 |
+
cfg_path), f'{cfg_path} is not valid config path'
|
112 |
+
cpt_path = os.path.join(args.model_dir, model_family_dir, model)
|
113 |
+
result_dict[cfg_path] = cpt_path
|
114 |
+
assert cfg_path in modelzoo_dict, f'please fill the ' \
|
115 |
+
f'performance of cfg: {cfg_path}'
|
116 |
+
cfg = check_finish(result_dict, args.json_out)
|
117 |
+
cpt = result_dict[cfg]
|
118 |
+
try:
|
119 |
+
cfg_name = cfg
|
120 |
+
logger.info(f'evaluate {cfg}')
|
121 |
+
record = dict(cfg=cfg, cpt=cpt)
|
122 |
+
cfg = Config.fromfile(cfg)
|
123 |
+
# cfg.data.test.ann_file = 'data/val_0_10.json'
|
124 |
+
# set cudnn_benchmark
|
125 |
+
if cfg.get('cudnn_benchmark', False):
|
126 |
+
torch.backends.cudnn.benchmark = True
|
127 |
+
cfg.model.pretrained = None
|
128 |
+
if cfg.model.get('neck'):
|
129 |
+
if isinstance(cfg.model.neck, list):
|
130 |
+
for neck_cfg in cfg.model.neck:
|
131 |
+
if neck_cfg.get('rfp_backbone'):
|
132 |
+
if neck_cfg.rfp_backbone.get('pretrained'):
|
133 |
+
neck_cfg.rfp_backbone.pretrained = None
|
134 |
+
elif cfg.model.neck.get('rfp_backbone'):
|
135 |
+
if cfg.model.neck.rfp_backbone.get('pretrained'):
|
136 |
+
cfg.model.neck.rfp_backbone.pretrained = None
|
137 |
+
|
138 |
+
# in case the test dataset is concatenated
|
139 |
+
if isinstance(cfg.data.test, dict):
|
140 |
+
cfg.data.test.test_mode = True
|
141 |
+
elif isinstance(cfg.data.test, list):
|
142 |
+
for ds_cfg in cfg.data.test:
|
143 |
+
ds_cfg.test_mode = True
|
144 |
+
|
145 |
+
# build the dataloader
|
146 |
+
samples_per_gpu = 2 # hack test with 2 image per gpu
|
147 |
+
if samples_per_gpu > 1:
|
148 |
+
# Replace 'ImageToTensor' to 'DefaultFormatBundle'
|
149 |
+
cfg.data.test.pipeline = replace_ImageToTensor(
|
150 |
+
cfg.data.test.pipeline)
|
151 |
+
dataset = build_dataset(cfg.data.test)
|
152 |
+
data_loader = build_dataloader(
|
153 |
+
dataset,
|
154 |
+
samples_per_gpu=samples_per_gpu,
|
155 |
+
workers_per_gpu=cfg.data.workers_per_gpu,
|
156 |
+
dist=distributed,
|
157 |
+
shuffle=False)
|
158 |
+
|
159 |
+
# build the model and load checkpoint
|
160 |
+
cfg.model.train_cfg = None
|
161 |
+
model = build_detector(cfg.model, test_cfg=cfg.get('test_cfg'))
|
162 |
+
fp16_cfg = cfg.get('fp16', None)
|
163 |
+
if fp16_cfg is not None:
|
164 |
+
wrap_fp16_model(model)
|
165 |
+
|
166 |
+
checkpoint = load_checkpoint(model, cpt, map_location='cpu')
|
167 |
+
# old versions did not save class info in checkpoints,
|
168 |
+
# this walkaround is for backward compatibility
|
169 |
+
if 'CLASSES' in checkpoint.get('meta', {}):
|
170 |
+
model.CLASSES = checkpoint['meta']['CLASSES']
|
171 |
+
else:
|
172 |
+
model.CLASSES = dataset.CLASSES
|
173 |
+
|
174 |
+
if not distributed:
|
175 |
+
model = MMDataParallel(model, device_ids=[0])
|
176 |
+
outputs = single_gpu_test(model, data_loader)
|
177 |
+
else:
|
178 |
+
model = MMDistributedDataParallel(
|
179 |
+
model.cuda(),
|
180 |
+
device_ids=[torch.cuda.current_device()],
|
181 |
+
broadcast_buffers=False)
|
182 |
+
outputs = multi_gpu_test(model, data_loader, 'tmp')
|
183 |
+
if rank == 0:
|
184 |
+
ref_mAP_dict = modelzoo_dict[cfg_name]
|
185 |
+
metrics = list(ref_mAP_dict.keys())
|
186 |
+
metrics = [
|
187 |
+
m if m != 'AR@1000' else 'proposal_fast' for m in metrics
|
188 |
+
]
|
189 |
+
eval_results = dataset.evaluate(outputs, metrics)
|
190 |
+
print(eval_results)
|
191 |
+
for metric in metrics:
|
192 |
+
if metric == 'proposal_fast':
|
193 |
+
ref_metric = modelzoo_dict[cfg_name]['AR@1000']
|
194 |
+
eval_metric = eval_results['AR@1000']
|
195 |
+
else:
|
196 |
+
ref_metric = modelzoo_dict[cfg_name][metric]
|
197 |
+
eval_metric = eval_results[f'{metric}_mAP']
|
198 |
+
if abs(ref_metric - eval_metric) > 0.003:
|
199 |
+
record['is_normal'] = False
|
200 |
+
dump_dict(record, args.json_out)
|
201 |
+
check_finish(result_dict, args.json_out)
|
202 |
+
except Exception as e:
|
203 |
+
logger.error(f'rank: {rank} test fail with error: {e}')
|
204 |
+
record['terminate'] = True
|
205 |
+
dump_dict(record, args.json_out)
|
206 |
+
check_finish(result_dict, args.json_out)
|
207 |
+
# hack there to throw some error to prevent hang out
|
208 |
+
subprocess.call('xxx')
|
209 |
+
|
210 |
+
|
211 |
+
if __name__ == '__main__':
|
212 |
+
main()
|
.dev_scripts/batch_test.sh
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export PYTHONPATH=${PWD}
|
2 |
+
|
3 |
+
partition=$1
|
4 |
+
model_dir=$2
|
5 |
+
json_out=$3
|
6 |
+
job_name=batch_test
|
7 |
+
gpus=8
|
8 |
+
gpu_per_node=8
|
9 |
+
|
10 |
+
touch $json_out
|
11 |
+
lastLine=$(tail -n 1 $json_out)
|
12 |
+
while [ "$lastLine" != "finished" ]
|
13 |
+
do
|
14 |
+
srun -p ${partition} --gres=gpu:${gpu_per_node} -n${gpus} --ntasks-per-node=${gpu_per_node} \
|
15 |
+
--job-name=${job_name} --kill-on-bad-exit=1 \
|
16 |
+
python .dev_scripts/batch_test.py $model_dir $json_out --launcher='slurm'
|
17 |
+
lastLine=$(tail -n 1 $json_out)
|
18 |
+
echo $lastLine
|
19 |
+
done
|
.dev_scripts/benchmark_filter.py
ADDED
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import argparse
|
2 |
+
import os
|
3 |
+
import os.path as osp
|
4 |
+
|
5 |
+
import mmcv
|
6 |
+
|
7 |
+
|
8 |
+
def parse_args():
|
9 |
+
parser = argparse.ArgumentParser(description='Filter configs to train')
|
10 |
+
parser.add_argument(
|
11 |
+
'--basic-arch',
|
12 |
+
action='store_true',
|
13 |
+
help='to train models in basic arch')
|
14 |
+
parser.add_argument(
|
15 |
+
'--datasets', action='store_true', help='to train models in dataset')
|
16 |
+
parser.add_argument(
|
17 |
+
'--data-pipeline',
|
18 |
+
action='store_true',
|
19 |
+
help='to train models related to data pipeline, e.g. augmentations')
|
20 |
+
parser.add_argument(
|
21 |
+
'--nn-module',
|
22 |
+
action='store_true',
|
23 |
+
help='to train models related to neural network modules')
|
24 |
+
parser.add_argument(
|
25 |
+
'--model-options',
|
26 |
+
nargs='+',
|
27 |
+
help='custom options to special model benchmark')
|
28 |
+
|
29 |
+
args = parser.parse_args()
|
30 |
+
return args
|
31 |
+
|
32 |
+
|
33 |
+
basic_arch_root = [
|
34 |
+
'atss', 'cascade_rcnn', 'cascade_rpn', 'centripetalnet', 'cornernet',
|
35 |
+
'detectors', 'detr', 'double_heads', 'dynamic_rcnn', 'faster_rcnn', 'fcos',
|
36 |
+
'foveabox', 'fp16', 'free_anchor', 'fsaf', 'gfl', 'ghm', 'grid_rcnn',
|
37 |
+
'guided_anchoring', 'htc', 'libra_rcnn', 'mask_rcnn', 'ms_rcnn',
|
38 |
+
'nas_fcos', 'paa', 'pisa', 'point_rend', 'reppoints', 'retinanet', 'rpn',
|
39 |
+
'sabl', 'ssd', 'tridentnet', 'vfnet', 'yolact', 'yolo', 'sparse_rcnn',
|
40 |
+
'scnet'
|
41 |
+
]
|
42 |
+
|
43 |
+
datasets_root = [
|
44 |
+
'wider_face', 'pascal_voc', 'cityscapes', 'lvis', 'deepfashion'
|
45 |
+
]
|
46 |
+
|
47 |
+
data_pipeline_root = ['albu_example', 'instaboost']
|
48 |
+
|
49 |
+
nn_module_root = [
|
50 |
+
'carafe', 'dcn', 'empirical_attention', 'gcnet', 'gn', 'gn+ws', 'hrnet',
|
51 |
+
'pafpn', 'nas_fpn', 'regnet', 'resnest', 'res2net', 'groie'
|
52 |
+
]
|
53 |
+
|
54 |
+
benchmark_pool = [
|
55 |
+
'configs/albu_example/mask_rcnn_r50_fpn_albu_1x_coco.py',
|
56 |
+
'configs/atss/atss_r50_fpn_1x_coco.py',
|
57 |
+
'configs/carafe/mask_rcnn_r50_fpn_carafe_1x_coco.py',
|
58 |
+
'configs/cascade_rcnn/cascade_mask_rcnn_r50_fpn_1x_coco.py',
|
59 |
+
'configs/cascade_rpn/crpn_faster_rcnn_r50_caffe_fpn_1x_coco.py',
|
60 |
+
'configs/centripetalnet/'
|
61 |
+
'centripetalnet_hourglass104_mstest_16x6_210e_coco.py',
|
62 |
+
'configs/cityscapes/mask_rcnn_r50_fpn_1x_cityscapes.py',
|
63 |
+
'configs/cornernet/'
|
64 |
+
'cornernet_hourglass104_mstest_8x6_210e_coco.py', # special
|
65 |
+
'configs/dcn/mask_rcnn_r50_fpn_mdconv_c3-c5_1x_coco.py',
|
66 |
+
'configs/dcn/faster_rcnn_r50_fpn_dpool_1x_coco.py',
|
67 |
+
'configs/dcn/faster_rcnn_r50_fpn_mdpool_1x_coco.py',
|
68 |
+
'configs/dcn/mask_rcnn_r50_fpn_dconv_c3-c5_1x_coco.py',
|
69 |
+
'configs/detectors/detectors_htc_r50_1x_coco.py',
|
70 |
+
'configs/detr/detr_r50_8x2_150e_coco.py',
|
71 |
+
'configs/double_heads/dh_faster_rcnn_r50_fpn_1x_coco.py',
|
72 |
+
'configs/dynamic_rcnn/dynamic_rcnn_r50_fpn_1x.py',
|
73 |
+
'configs/empirical_attention/faster_rcnn_r50_fpn_attention_1111_dcn_1x_coco.py', # noqa
|
74 |
+
'configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py',
|
75 |
+
'configs/faster_rcnn/faster_rcnn_r50_fpn_ohem_1x_coco.py',
|
76 |
+
'configs/faster_rcnn/faster_rcnn_r50_caffe_fpn_1x_coco.py',
|
77 |
+
'configs/faster_rcnn/faster_rcnn_r50_caffe_fpn_mstrain_1x_coco.py',
|
78 |
+
'configs/faster_rcnn/faster_rcnn_r50_caffe_dc5_mstrain_1x_coco.py',
|
79 |
+
'configs/fcos/fcos_center_r50_caffe_fpn_gn-head_4x4_1x_coco.py',
|
80 |
+
'configs/foveabox/fovea_align_r50_fpn_gn-head_4x4_2x_coco.py',
|
81 |
+
'configs/fp16/retinanet_r50_fpn_fp16_1x_coco.py',
|
82 |
+
'configs/fp16/mask_rcnn_r50_fpn_fp16_1x_coco.py',
|
83 |
+
'configs/free_anchor/retinanet_free_anchor_r50_fpn_1x_coco.py',
|
84 |
+
'configs/fsaf/fsaf_r50_fpn_1x_coco.py',
|
85 |
+
'configs/gcnet/mask_rcnn_r50_fpn_r4_gcb_c3-c5_1x_coco.py',
|
86 |
+
'configs/gfl/gfl_r50_fpn_1x_coco.py',
|
87 |
+
'configs/ghm/retinanet_ghm_r50_fpn_1x_coco.py',
|
88 |
+
'configs/gn/mask_rcnn_r50_fpn_gn-all_2x_coco.py',
|
89 |
+
'configs/gn+ws/mask_rcnn_r50_fpn_gn_ws-all_2x_coco.py',
|
90 |
+
'configs/grid_rcnn/grid_rcnn_r50_fpn_gn-head_2x_coco.py',
|
91 |
+
'configs/groie/faster_rcnn_r50_fpn_groie_1x_coco.py',
|
92 |
+
'configs/guided_anchoring/ga_faster_r50_caffe_fpn_1x_coco.py',
|
93 |
+
'configs/hrnet/mask_rcnn_hrnetv2p_w18_1x_coco.py',
|
94 |
+
'configs/htc/htc_r50_fpn_1x_coco.py',
|
95 |
+
'configs/instaboost/mask_rcnn_r50_fpn_instaboost_4x_coco.py',
|
96 |
+
'configs/libra_rcnn/libra_faster_rcnn_r50_fpn_1x_coco.py',
|
97 |
+
'configs/lvis/mask_rcnn_r50_fpn_sample1e-3_mstrain_1x_lvis_v1.py',
|
98 |
+
'configs/mask_rcnn/mask_rcnn_r50_caffe_fpn_mstrain-poly_1x_coco.py',
|
99 |
+
'configs/ms_rcnn/ms_rcnn_r50_caffe_fpn_1x_coco.py',
|
100 |
+
'configs/nas_fcos/nas_fcos_nashead_r50_caffe_fpn_gn-head_4x4_1x_coco.py',
|
101 |
+
'configs/nas_fpn/retinanet_r50_nasfpn_crop640_50e_coco.py',
|
102 |
+
'configs/paa/paa_r50_fpn_1x_coco.py',
|
103 |
+
'configs/pafpn/faster_rcnn_r50_pafpn_1x_coco.py',
|
104 |
+
'configs/pisa/pisa_mask_rcnn_r50_fpn_1x_coco.py',
|
105 |
+
'configs/point_rend/point_rend_r50_caffe_fpn_mstrain_1x_coco.py',
|
106 |
+
'configs/regnet/mask_rcnn_regnetx-3.2GF_fpn_1x_coco.py',
|
107 |
+
'configs/reppoints/reppoints_moment_r50_fpn_gn-neck+head_1x_coco.py',
|
108 |
+
'configs/res2net/faster_rcnn_r2_101_fpn_2x_coco.py',
|
109 |
+
'configs/resnest/'
|
110 |
+
'mask_rcnn_s50_fpn_syncbn-backbone+head_mstrain_1x_coco.py',
|
111 |
+
'configs/retinanet/retinanet_r50_caffe_fpn_1x_coco.py',
|
112 |
+
'configs/rpn/rpn_r50_fpn_1x_coco.py',
|
113 |
+
'configs/sabl/sabl_retinanet_r50_fpn_1x_coco.py',
|
114 |
+
'configs/ssd/ssd300_coco.py',
|
115 |
+
'configs/tridentnet/tridentnet_r50_caffe_1x_coco.py',
|
116 |
+
'configs/vfnet/vfnet_r50_fpn_1x_coco.py',
|
117 |
+
'configs/yolact/yolact_r50_1x8_coco.py',
|
118 |
+
'configs/yolo/yolov3_d53_320_273e_coco.py',
|
119 |
+
'configs/sparse_rcnn/sparse_rcnn_r50_fpn_1x_coco.py',
|
120 |
+
'configs/scnet/scnet_r50_fpn_1x_coco.py'
|
121 |
+
]
|
122 |
+
|
123 |
+
|
124 |
+
def main():
|
125 |
+
args = parse_args()
|
126 |
+
|
127 |
+
benchmark_type = []
|
128 |
+
if args.basic_arch:
|
129 |
+
benchmark_type += basic_arch_root
|
130 |
+
if args.datasets:
|
131 |
+
benchmark_type += datasets_root
|
132 |
+
if args.data_pipeline:
|
133 |
+
benchmark_type += data_pipeline_root
|
134 |
+
if args.nn_module:
|
135 |
+
benchmark_type += nn_module_root
|
136 |
+
|
137 |
+
special_model = args.model_options
|
138 |
+
if special_model is not None:
|
139 |
+
benchmark_type += special_model
|
140 |
+
|
141 |
+
config_dpath = 'configs/'
|
142 |
+
benchmark_configs = []
|
143 |
+
for cfg_root in benchmark_type:
|
144 |
+
cfg_dir = osp.join(config_dpath, cfg_root)
|
145 |
+
configs = os.scandir(cfg_dir)
|
146 |
+
for cfg in configs:
|
147 |
+
config_path = osp.join(cfg_dir, cfg.name)
|
148 |
+
if (config_path in benchmark_pool
|
149 |
+
and config_path not in benchmark_configs):
|
150 |
+
benchmark_configs.append(config_path)
|
151 |
+
|
152 |
+
print(f'Totally found {len(benchmark_configs)} configs to benchmark')
|
153 |
+
config_dicts = dict(models=benchmark_configs)
|
154 |
+
mmcv.dump(config_dicts, 'regression_test_configs.json')
|
155 |
+
|
156 |
+
|
157 |
+
if __name__ == '__main__':
|
158 |
+
main()
|
.dev_scripts/convert_benchmark_script.py
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import argparse
|
2 |
+
import os
|
3 |
+
import os.path as osp
|
4 |
+
|
5 |
+
import mmcv
|
6 |
+
|
7 |
+
|
8 |
+
def parse_args():
|
9 |
+
parser = argparse.ArgumentParser(
|
10 |
+
description='Convert benchmark model json to script')
|
11 |
+
parser.add_argument(
|
12 |
+
'json_path', type=str, help='json path output by benchmark_filter')
|
13 |
+
parser.add_argument('partition', type=str, help='slurm partition name')
|
14 |
+
parser.add_argument(
|
15 |
+
'--max-keep-ckpts',
|
16 |
+
type=int,
|
17 |
+
default=1,
|
18 |
+
help='The maximum checkpoints to keep')
|
19 |
+
parser.add_argument(
|
20 |
+
'--run', action='store_true', help='run script directly')
|
21 |
+
parser.add_argument(
|
22 |
+
'--out', type=str, help='path to save model benchmark script')
|
23 |
+
|
24 |
+
args = parser.parse_args()
|
25 |
+
return args
|
26 |
+
|
27 |
+
|
28 |
+
def main():
|
29 |
+
args = parse_args()
|
30 |
+
if args.out:
|
31 |
+
out_suffix = args.out.split('.')[-1]
|
32 |
+
assert args.out.endswith('.sh'), \
|
33 |
+
f'Expected out file path suffix is .sh, but get .{out_suffix}'
|
34 |
+
assert args.out or args.run, \
|
35 |
+
('Please specify at least one operation (save/run/ the '
|
36 |
+
'script) with the argument "--out" or "--run"')
|
37 |
+
|
38 |
+
json_data = mmcv.load(args.json_path)
|
39 |
+
model_cfgs = json_data['models']
|
40 |
+
|
41 |
+
partition = args.partition # cluster name
|
42 |
+
|
43 |
+
root_name = './tools'
|
44 |
+
train_script_name = osp.join(root_name, 'slurm_train.sh')
|
45 |
+
# stdout is no output
|
46 |
+
stdout_cfg = '>/dev/null'
|
47 |
+
|
48 |
+
max_keep_ckpts = args.max_keep_ckpts
|
49 |
+
|
50 |
+
commands = []
|
51 |
+
for i, cfg in enumerate(model_cfgs):
|
52 |
+
# print cfg name
|
53 |
+
echo_info = f'echo \'{cfg}\' &'
|
54 |
+
commands.append(echo_info)
|
55 |
+
commands.append('\n')
|
56 |
+
|
57 |
+
fname, _ = osp.splitext(osp.basename(cfg))
|
58 |
+
out_fname = osp.join(root_name, fname)
|
59 |
+
# default setting
|
60 |
+
command_info = f'GPUS=8 GPUS_PER_NODE=8 ' \
|
61 |
+
f'CPUS_PER_TASK=2 {train_script_name} '
|
62 |
+
command_info += f'{partition} '
|
63 |
+
command_info += f'{fname} '
|
64 |
+
command_info += f'{cfg} '
|
65 |
+
command_info += f'{out_fname} '
|
66 |
+
if max_keep_ckpts:
|
67 |
+
command_info += f'--cfg-options ' \
|
68 |
+
f'checkpoint_config.max_keep_ckpts=' \
|
69 |
+
f'{max_keep_ckpts}' + ' '
|
70 |
+
command_info += f'{stdout_cfg} &'
|
71 |
+
|
72 |
+
commands.append(command_info)
|
73 |
+
|
74 |
+
if i < len(model_cfgs):
|
75 |
+
commands.append('\n')
|
76 |
+
|
77 |
+
command_str = ''.join(commands)
|
78 |
+
if args.out:
|
79 |
+
with open(args.out, 'w') as f:
|
80 |
+
f.write(command_str)
|
81 |
+
if args.run:
|
82 |
+
os.system(command_str)
|
83 |
+
|
84 |
+
|
85 |
+
if __name__ == '__main__':
|
86 |
+
main()
|
.dev_scripts/gather_benchmark_metric.py
ADDED
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import argparse
|
2 |
+
import glob
|
3 |
+
import os.path as osp
|
4 |
+
|
5 |
+
import mmcv
|
6 |
+
from gather_models import get_final_results
|
7 |
+
|
8 |
+
try:
|
9 |
+
import xlrd
|
10 |
+
except ImportError:
|
11 |
+
xlrd = None
|
12 |
+
try:
|
13 |
+
import xlutils
|
14 |
+
from xlutils.copy import copy
|
15 |
+
except ImportError:
|
16 |
+
xlutils = None
|
17 |
+
|
18 |
+
|
19 |
+
def parse_args():
|
20 |
+
parser = argparse.ArgumentParser(
|
21 |
+
description='Gather benchmarked models metric')
|
22 |
+
parser.add_argument(
|
23 |
+
'root',
|
24 |
+
type=str,
|
25 |
+
help='root path of benchmarked models to be gathered')
|
26 |
+
parser.add_argument(
|
27 |
+
'benchmark_json', type=str, help='json path of benchmark models')
|
28 |
+
parser.add_argument(
|
29 |
+
'--out', type=str, help='output path of gathered metrics to be stored')
|
30 |
+
parser.add_argument(
|
31 |
+
'--not-show', action='store_true', help='not show metrics')
|
32 |
+
parser.add_argument(
|
33 |
+
'--excel', type=str, help='input path of excel to be recorded')
|
34 |
+
parser.add_argument(
|
35 |
+
'--ncol', type=int, help='Number of column to be modified or appended')
|
36 |
+
|
37 |
+
args = parser.parse_args()
|
38 |
+
return args
|
39 |
+
|
40 |
+
|
41 |
+
if __name__ == '__main__':
|
42 |
+
args = parse_args()
|
43 |
+
|
44 |
+
if args.excel:
|
45 |
+
assert args.ncol, 'Please specify "--excel" and "--ncol" ' \
|
46 |
+
'at the same time'
|
47 |
+
if xlrd is None:
|
48 |
+
raise RuntimeError(
|
49 |
+
'xlrd is not installed,'
|
50 |
+
'Please use “pip install xlrd==1.2.0” to install')
|
51 |
+
if xlutils is None:
|
52 |
+
raise RuntimeError(
|
53 |
+
'xlutils is not installed,'
|
54 |
+
'Please use “pip install xlutils==2.0.0” to install')
|
55 |
+
readbook = xlrd.open_workbook(args.excel)
|
56 |
+
sheet = readbook.sheet_by_name('Sheet1')
|
57 |
+
sheet_info = {}
|
58 |
+
total_nrows = sheet.nrows
|
59 |
+
for i in range(3, sheet.nrows):
|
60 |
+
sheet_info[sheet.row_values(i)[0]] = i
|
61 |
+
xlrw = copy(readbook)
|
62 |
+
table = xlrw.get_sheet(0)
|
63 |
+
|
64 |
+
root_path = args.root
|
65 |
+
metrics_out = args.out
|
66 |
+
benchmark_json_path = args.benchmark_json
|
67 |
+
model_configs = mmcv.load(benchmark_json_path)['models']
|
68 |
+
|
69 |
+
result_dict = {}
|
70 |
+
for config in model_configs:
|
71 |
+
config_name = osp.split(config)[-1]
|
72 |
+
config_name = osp.splitext(config_name)[0]
|
73 |
+
result_path = osp.join(root_path, config_name)
|
74 |
+
if osp.exists(result_path):
|
75 |
+
# 1 read config
|
76 |
+
cfg = mmcv.Config.fromfile(config)
|
77 |
+
total_epochs = cfg.runner.max_epochs
|
78 |
+
final_results = cfg.evaluation.metric
|
79 |
+
if not isinstance(final_results, list):
|
80 |
+
final_results = [final_results]
|
81 |
+
final_results_out = []
|
82 |
+
for key in final_results:
|
83 |
+
if 'proposal_fast' in key:
|
84 |
+
final_results_out.append('AR@1000') # RPN
|
85 |
+
elif 'mAP' not in key:
|
86 |
+
final_results_out.append(key + '_mAP')
|
87 |
+
|
88 |
+
# 2 determine whether total_epochs ckpt exists
|
89 |
+
ckpt_path = f'epoch_{total_epochs}.pth'
|
90 |
+
if osp.exists(osp.join(result_path, ckpt_path)):
|
91 |
+
log_json_path = list(
|
92 |
+
sorted(glob.glob(osp.join(result_path, '*.log.json'))))[-1]
|
93 |
+
|
94 |
+
# 3 read metric
|
95 |
+
model_performance = get_final_results(log_json_path,
|
96 |
+
total_epochs,
|
97 |
+
final_results_out)
|
98 |
+
if model_performance is None:
|
99 |
+
print(f'log file error: {log_json_path}')
|
100 |
+
continue
|
101 |
+
for performance in model_performance:
|
102 |
+
if performance in ['AR@1000', 'bbox_mAP', 'segm_mAP']:
|
103 |
+
metric = round(model_performance[performance] * 100, 1)
|
104 |
+
model_performance[performance] = metric
|
105 |
+
result_dict[config] = model_performance
|
106 |
+
|
107 |
+
# update and append excel content
|
108 |
+
if args.excel:
|
109 |
+
if 'AR@1000' in model_performance:
|
110 |
+
metrics = f'{model_performance["AR@1000"]}(AR@1000)'
|
111 |
+
elif 'segm_mAP' in model_performance:
|
112 |
+
metrics = f'{model_performance["bbox_mAP"]}/' \
|
113 |
+
f'{model_performance["segm_mAP"]}'
|
114 |
+
else:
|
115 |
+
metrics = f'{model_performance["bbox_mAP"]}'
|
116 |
+
|
117 |
+
row_num = sheet_info.get(config, None)
|
118 |
+
if row_num:
|
119 |
+
table.write(row_num, args.ncol, metrics)
|
120 |
+
else:
|
121 |
+
table.write(total_nrows, 0, config)
|
122 |
+
table.write(total_nrows, args.ncol, metrics)
|
123 |
+
total_nrows += 1
|
124 |
+
|
125 |
+
else:
|
126 |
+
print(f'{config} not exist: {ckpt_path}')
|
127 |
+
else:
|
128 |
+
print(f'not exist: {config}')
|
129 |
+
|
130 |
+
# 4 save or print results
|
131 |
+
if metrics_out:
|
132 |
+
mmcv.mkdir_or_exist(metrics_out)
|
133 |
+
mmcv.dump(result_dict, osp.join(metrics_out, 'model_metric_info.json'))
|
134 |
+
if not args.not_show:
|
135 |
+
print('===================================')
|
136 |
+
for config_name, metrics in result_dict.items():
|
137 |
+
print(config_name, metrics)
|
138 |
+
print('===================================')
|
139 |
+
if args.excel:
|
140 |
+
filename, sufflx = osp.splitext(args.excel)
|
141 |
+
xlrw.save(f'{filename}_o{sufflx}')
|
142 |
+
print(f'>>> Output {filename}_o{sufflx}')
|
.dev_scripts/gather_models.py
ADDED
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import argparse
|
2 |
+
import glob
|
3 |
+
import json
|
4 |
+
import os.path as osp
|
5 |
+
import shutil
|
6 |
+
import subprocess
|
7 |
+
|
8 |
+
import mmcv
|
9 |
+
import torch
|
10 |
+
|
11 |
+
|
12 |
+
def process_checkpoint(in_file, out_file):
|
13 |
+
checkpoint = torch.load(in_file, map_location='cpu')
|
14 |
+
# remove optimizer for smaller file size
|
15 |
+
if 'optimizer' in checkpoint:
|
16 |
+
del checkpoint['optimizer']
|
17 |
+
# if it is necessary to remove some sensitive data in checkpoint['meta'],
|
18 |
+
# add the code here.
|
19 |
+
torch.save(checkpoint, out_file)
|
20 |
+
sha = subprocess.check_output(['sha256sum', out_file]).decode()
|
21 |
+
final_file = out_file.rstrip('.pth') + '-{}.pth'.format(sha[:8])
|
22 |
+
subprocess.Popen(['mv', out_file, final_file])
|
23 |
+
return final_file
|
24 |
+
|
25 |
+
|
26 |
+
def get_final_epoch(config):
|
27 |
+
cfg = mmcv.Config.fromfile('./configs/' + config)
|
28 |
+
return cfg.total_epochs
|
29 |
+
|
30 |
+
|
31 |
+
def get_final_results(log_json_path, epoch, results_lut):
|
32 |
+
result_dict = dict()
|
33 |
+
with open(log_json_path, 'r') as f:
|
34 |
+
for line in f.readlines():
|
35 |
+
log_line = json.loads(line)
|
36 |
+
if 'mode' not in log_line.keys():
|
37 |
+
continue
|
38 |
+
|
39 |
+
if log_line['mode'] == 'train' and log_line['epoch'] == epoch:
|
40 |
+
result_dict['memory'] = log_line['memory']
|
41 |
+
|
42 |
+
if log_line['mode'] == 'val' and log_line['epoch'] == epoch:
|
43 |
+
result_dict.update({
|
44 |
+
key: log_line[key]
|
45 |
+
for key in results_lut if key in log_line
|
46 |
+
})
|
47 |
+
return result_dict
|
48 |
+
|
49 |
+
|
50 |
+
def parse_args():
|
51 |
+
parser = argparse.ArgumentParser(description='Gather benchmarked models')
|
52 |
+
parser.add_argument(
|
53 |
+
'root',
|
54 |
+
type=str,
|
55 |
+
help='root path of benchmarked models to be gathered')
|
56 |
+
parser.add_argument(
|
57 |
+
'out', type=str, help='output path of gathered models to be stored')
|
58 |
+
|
59 |
+
args = parser.parse_args()
|
60 |
+
return args
|
61 |
+
|
62 |
+
|
63 |
+
def main():
|
64 |
+
args = parse_args()
|
65 |
+
models_root = args.root
|
66 |
+
models_out = args.out
|
67 |
+
mmcv.mkdir_or_exist(models_out)
|
68 |
+
|
69 |
+
# find all models in the root directory to be gathered
|
70 |
+
raw_configs = list(mmcv.scandir('./configs', '.py', recursive=True))
|
71 |
+
|
72 |
+
# filter configs that is not trained in the experiments dir
|
73 |
+
used_configs = []
|
74 |
+
for raw_config in raw_configs:
|
75 |
+
if osp.exists(osp.join(models_root, raw_config)):
|
76 |
+
used_configs.append(raw_config)
|
77 |
+
print(f'Find {len(used_configs)} models to be gathered')
|
78 |
+
|
79 |
+
# find final_ckpt and log file for trained each config
|
80 |
+
# and parse the best performance
|
81 |
+
model_infos = []
|
82 |
+
for used_config in used_configs:
|
83 |
+
exp_dir = osp.join(models_root, used_config)
|
84 |
+
# check whether the exps is finished
|
85 |
+
final_epoch = get_final_epoch(used_config)
|
86 |
+
final_model = 'epoch_{}.pth'.format(final_epoch)
|
87 |
+
model_path = osp.join(exp_dir, final_model)
|
88 |
+
|
89 |
+
# skip if the model is still training
|
90 |
+
if not osp.exists(model_path):
|
91 |
+
continue
|
92 |
+
|
93 |
+
# get the latest logs
|
94 |
+
log_json_path = list(
|
95 |
+
sorted(glob.glob(osp.join(exp_dir, '*.log.json'))))[-1]
|
96 |
+
log_txt_path = list(sorted(glob.glob(osp.join(exp_dir, '*.log'))))[-1]
|
97 |
+
cfg = mmcv.Config.fromfile('./configs/' + used_config)
|
98 |
+
results_lut = cfg.evaluation.metric
|
99 |
+
if not isinstance(results_lut, list):
|
100 |
+
results_lut = [results_lut]
|
101 |
+
# case when using VOC, the evaluation key is only 'mAP'
|
102 |
+
results_lut = [key + '_mAP' for key in results_lut if 'mAP' not in key]
|
103 |
+
model_performance = get_final_results(log_json_path, final_epoch,
|
104 |
+
results_lut)
|
105 |
+
|
106 |
+
if model_performance is None:
|
107 |
+
continue
|
108 |
+
|
109 |
+
model_time = osp.split(log_txt_path)[-1].split('.')[0]
|
110 |
+
model_infos.append(
|
111 |
+
dict(
|
112 |
+
config=used_config,
|
113 |
+
results=model_performance,
|
114 |
+
epochs=final_epoch,
|
115 |
+
model_time=model_time,
|
116 |
+
log_json_path=osp.split(log_json_path)[-1]))
|
117 |
+
|
118 |
+
# publish model for each checkpoint
|
119 |
+
publish_model_infos = []
|
120 |
+
for model in model_infos:
|
121 |
+
model_publish_dir = osp.join(models_out, model['config'].rstrip('.py'))
|
122 |
+
mmcv.mkdir_or_exist(model_publish_dir)
|
123 |
+
|
124 |
+
model_name = osp.split(model['config'])[-1].split('.')[0]
|
125 |
+
|
126 |
+
model_name += '_' + model['model_time']
|
127 |
+
publish_model_path = osp.join(model_publish_dir, model_name)
|
128 |
+
trained_model_path = osp.join(models_root, model['config'],
|
129 |
+
'epoch_{}.pth'.format(model['epochs']))
|
130 |
+
|
131 |
+
# convert model
|
132 |
+
final_model_path = process_checkpoint(trained_model_path,
|
133 |
+
publish_model_path)
|
134 |
+
|
135 |
+
# copy log
|
136 |
+
shutil.copy(
|
137 |
+
osp.join(models_root, model['config'], model['log_json_path']),
|
138 |
+
osp.join(model_publish_dir, f'{model_name}.log.json'))
|
139 |
+
shutil.copy(
|
140 |
+
osp.join(models_root, model['config'],
|
141 |
+
model['log_json_path'].rstrip('.json')),
|
142 |
+
osp.join(model_publish_dir, f'{model_name}.log'))
|
143 |
+
|
144 |
+
# copy config to guarantee reproducibility
|
145 |
+
config_path = model['config']
|
146 |
+
config_path = osp.join(
|
147 |
+
'configs',
|
148 |
+
config_path) if 'configs' not in config_path else config_path
|
149 |
+
target_cconfig_path = osp.split(config_path)[-1]
|
150 |
+
shutil.copy(config_path,
|
151 |
+
osp.join(model_publish_dir, target_cconfig_path))
|
152 |
+
|
153 |
+
model['model_path'] = final_model_path
|
154 |
+
publish_model_infos.append(model)
|
155 |
+
|
156 |
+
models = dict(models=publish_model_infos)
|
157 |
+
print(f'Totally gathered {len(publish_model_infos)} models')
|
158 |
+
mmcv.dump(models, osp.join(models_out, 'model_info.json'))
|
159 |
+
|
160 |
+
|
161 |
+
if __name__ == '__main__':
|
162 |
+
main()
|
.dev_scripts/linter.sh
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
yapf -r -i mmdet/ configs/ tests/ tools/
|
2 |
+
isort -rc mmdet/ configs/ tests/ tools/
|
3 |
+
flake8 .
|
.gitattributes
CHANGED
@@ -34,4 +34,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
35 |
*.gif filter=lfs diff=lfs merge=lfs -text
|
36 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
37 |
-
*.png filter=lfs diff=lfs merge=lfs -text
|
|
|
|
34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
35 |
*.gif filter=lfs diff=lfs merge=lfs -text
|
36 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
37 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
38 |
+
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
.github/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Contributor Covenant Code of Conduct
|
2 |
+
|
3 |
+
## Our Pledge
|
4 |
+
|
5 |
+
In the interest of fostering an open and welcoming environment, we as
|
6 |
+
contributors and maintainers pledge to making participation in our project and
|
7 |
+
our community a harassment-free experience for everyone, regardless of age, body
|
8 |
+
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
9 |
+
level of experience, education, socio-economic status, nationality, personal
|
10 |
+
appearance, race, religion, or sexual identity and orientation.
|
11 |
+
|
12 |
+
## Our Standards
|
13 |
+
|
14 |
+
Examples of behavior that contributes to creating a positive environment
|
15 |
+
include:
|
16 |
+
|
17 |
+
* Using welcoming and inclusive language
|
18 |
+
* Being respectful of differing viewpoints and experiences
|
19 |
+
* Gracefully accepting constructive criticism
|
20 |
+
* Focusing on what is best for the community
|
21 |
+
* Showing empathy towards other community members
|
22 |
+
|
23 |
+
Examples of unacceptable behavior by participants include:
|
24 |
+
|
25 |
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26 |
+
advances
|
27 |
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28 |
+
* Public or private harassment
|
29 |
+
* Publishing others' private information, such as a physical or electronic
|
30 |
+
address, without explicit permission
|
31 |
+
* Other conduct which could reasonably be considered inappropriate in a
|
32 |
+
professional setting
|
33 |
+
|
34 |
+
## Our Responsibilities
|
35 |
+
|
36 |
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37 |
+
behavior and are expected to take appropriate and fair corrective action in
|
38 |
+
response to any instances of unacceptable behavior.
|
39 |
+
|
40 |
+
Project maintainers have the right and responsibility to remove, edit, or
|
41 |
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42 |
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43 |
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44 |
+
threatening, offensive, or harmful.
|
45 |
+
|
46 |
+
## Scope
|
47 |
+
|
48 |
+
This Code of Conduct applies both within project spaces and in public spaces
|
49 |
+
when an individual is representing the project or its community. Examples of
|
50 |
+
representing a project or community include using an official project e-mail
|
51 |
+
address, posting via an official social media account, or acting as an appointed
|
52 |
+
representative at an online or offline event. Representation of a project may be
|
53 |
+
further defined and clarified by project maintainers.
|
54 |
+
|
55 |
+
## Enforcement
|
56 |
+
|
57 |
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58 |
+
reported by contacting the project team at [email protected]. All
|
59 |
+
complaints will be reviewed and investigated and will result in a response that
|
60 |
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61 |
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62 |
+
Further details of specific enforcement policies may be posted separately.
|
63 |
+
|
64 |
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65 |
+
faith may face temporary or permanent repercussions as determined by other
|
66 |
+
members of the project's leadership.
|
67 |
+
|
68 |
+
## Attribution
|
69 |
+
|
70 |
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71 |
+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
72 |
+
|
73 |
+
[homepage]: https://www.contributor-covenant.org
|
74 |
+
|
75 |
+
For answers to common questions about this code of conduct, see
|
76 |
+
https://www.contributor-covenant.org/faq
|
.github/CONTRIBUTING.md
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
We appreciate all contributions to improve MMDetection. Please refer to [CONTRIBUTING.md](https://github.com/open-mmlab/mmcv/blob/master/CONTRIBUTING.md) in MMCV for more details about the contributing guideline.
|
.github/ISSUE_TEMPLATE/config.yml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
blank_issues_enabled: false
|
2 |
+
|
3 |
+
contact_links:
|
4 |
+
- name: Common Issues
|
5 |
+
url: https://mmdetection.readthedocs.io/en/latest/faq.html
|
6 |
+
about: Check if your issue already has solutions
|
7 |
+
- name: MMDetection Documentation
|
8 |
+
url: https://mmdetection.readthedocs.io/en/latest/
|
9 |
+
about: Check if your question is answered in docs
|
.github/ISSUE_TEMPLATE/error-report.md
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
name: Error report
|
3 |
+
about: Create a report to help us improve
|
4 |
+
title: ''
|
5 |
+
labels: ''
|
6 |
+
assignees: ''
|
7 |
+
|
8 |
+
---
|
9 |
+
|
10 |
+
Thanks for your error report and we appreciate it a lot.
|
11 |
+
|
12 |
+
**Checklist**
|
13 |
+
|
14 |
+
1. I have searched related issues but cannot get the expected help.
|
15 |
+
2. I have read the [FAQ documentation](https://mmdetection.readthedocs.io/en/latest/faq.html) but cannot get the expected help.
|
16 |
+
3. The bug has not been fixed in the latest version.
|
17 |
+
|
18 |
+
**Describe the bug**
|
19 |
+
A clear and concise description of what the bug is.
|
20 |
+
|
21 |
+
**Reproduction**
|
22 |
+
|
23 |
+
1. What command or script did you run?
|
24 |
+
|
25 |
+
```none
|
26 |
+
A placeholder for the command.
|
27 |
+
```
|
28 |
+
|
29 |
+
2. Did you make any modifications on the code or config? Did you understand what you have modified?
|
30 |
+
3. What dataset did you use?
|
31 |
+
|
32 |
+
**Environment**
|
33 |
+
|
34 |
+
1. Please run `python mmdet/utils/collect_env.py` to collect necessary environment information and paste it here.
|
35 |
+
2. You may add addition that may be helpful for locating the problem, such as
|
36 |
+
- How you installed PyTorch [e.g., pip, conda, source]
|
37 |
+
- Other environment variables that may be related (such as `$PATH`, `$LD_LIBRARY_PATH`, `$PYTHONPATH`, etc.)
|
38 |
+
|
39 |
+
**Error traceback**
|
40 |
+
If applicable, paste the error trackback here.
|
41 |
+
|
42 |
+
```none
|
43 |
+
A placeholder for trackback.
|
44 |
+
```
|
45 |
+
|
46 |
+
**Bug fix**
|
47 |
+
If you have already identified the reason, you can provide the information here. If you are willing to create a PR to fix it, please also leave a comment here and that would be much appreciated!
|
.github/ISSUE_TEMPLATE/feature_request.md
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
name: Feature request
|
3 |
+
about: Suggest an idea for this project
|
4 |
+
title: ''
|
5 |
+
labels: ''
|
6 |
+
assignees: ''
|
7 |
+
|
8 |
+
---
|
9 |
+
|
10 |
+
**Describe the feature**
|
11 |
+
|
12 |
+
**Motivation**
|
13 |
+
A clear and concise description of the motivation of the feature.
|
14 |
+
Ex1. It is inconvenient when [....].
|
15 |
+
Ex2. There is a recent paper [....], which is very helpful for [....].
|
16 |
+
|
17 |
+
**Related resources**
|
18 |
+
If there is an official code release or third-party implementations, please also provide the information here, which would be very helpful.
|
19 |
+
|
20 |
+
**Additional context**
|
21 |
+
Add any other context or screenshots about the feature request here.
|
22 |
+
If you would like to implement the feature and create a PR, please leave a comment here and that would be much appreciated.
|
.github/ISSUE_TEMPLATE/general_questions.md
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
name: General questions
|
3 |
+
about: Ask general questions to get help
|
4 |
+
title: ''
|
5 |
+
labels: ''
|
6 |
+
assignees: ''
|
7 |
+
|
8 |
+
---
|
.github/ISSUE_TEMPLATE/reimplementation_questions.md
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
name: Reimplementation Questions
|
3 |
+
about: Ask about questions during model reimplementation
|
4 |
+
title: ''
|
5 |
+
labels: 'reimplementation'
|
6 |
+
assignees: ''
|
7 |
+
|
8 |
+
---
|
9 |
+
|
10 |
+
**Notice**
|
11 |
+
|
12 |
+
There are several common situations in the reimplementation issues as below
|
13 |
+
|
14 |
+
1. Reimplement a model in the model zoo using the provided configs
|
15 |
+
2. Reimplement a model in the model zoo on other dataset (e.g., custom datasets)
|
16 |
+
3. Reimplement a custom model but all the components are implemented in MMDetection
|
17 |
+
4. Reimplement a custom model with new modules implemented by yourself
|
18 |
+
|
19 |
+
There are several things to do for different cases as below.
|
20 |
+
|
21 |
+
- For case 1 & 3, please follow the steps in the following sections thus we could help to quick identify the issue.
|
22 |
+
- For case 2 & 4, please understand that we are not able to do much help here because we usually do not know the full code and the users should be responsible to the code they write.
|
23 |
+
- One suggestion for case 2 & 4 is that the users should first check whether the bug lies in the self-implemented code or the original code. For example, users can first make sure that the same model runs well on supported datasets. If you still need help, please describe what you have done and what you obtain in the issue, and follow the steps in the following sections and try as clear as possible so that we can better help you.
|
24 |
+
|
25 |
+
**Checklist**
|
26 |
+
|
27 |
+
1. I have searched related issues but cannot get the expected help.
|
28 |
+
2. The issue has not been fixed in the latest version.
|
29 |
+
|
30 |
+
**Describe the issue**
|
31 |
+
|
32 |
+
A clear and concise description of what the problem you meet and what have you done.
|
33 |
+
|
34 |
+
**Reproduction**
|
35 |
+
|
36 |
+
1. What command or script did you run?
|
37 |
+
|
38 |
+
```none
|
39 |
+
A placeholder for the command.
|
40 |
+
```
|
41 |
+
|
42 |
+
2. What config dir you run?
|
43 |
+
|
44 |
+
```none
|
45 |
+
A placeholder for the config.
|
46 |
+
```
|
47 |
+
|
48 |
+
3. Did you make any modifications on the code or config? Did you understand what you have modified?
|
49 |
+
4. What dataset did you use?
|
50 |
+
|
51 |
+
**Environment**
|
52 |
+
|
53 |
+
1. Please run `python mmdet/utils/collect_env.py` to collect necessary environment information and paste it here.
|
54 |
+
2. You may add addition that may be helpful for locating the problem, such as
|
55 |
+
1. How you installed PyTorch [e.g., pip, conda, source]
|
56 |
+
2. Other environment variables that may be related (such as `$PATH`, `$LD_LIBRARY_PATH`, `$PYTHONPATH`, etc.)
|
57 |
+
|
58 |
+
**Results**
|
59 |
+
|
60 |
+
If applicable, paste the related results here, e.g., what you expect and what you get.
|
61 |
+
|
62 |
+
```none
|
63 |
+
A placeholder for results comparison
|
64 |
+
```
|
65 |
+
|
66 |
+
**Issue fix**
|
67 |
+
|
68 |
+
If you have already identified the reason, you can provide the information here. If you are willing to create a PR to fix it, please also leave a comment here and that would be much appreciated!
|
.github/workflows/build.yml
ADDED
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: build
|
2 |
+
|
3 |
+
on: [push, pull_request]
|
4 |
+
|
5 |
+
jobs:
|
6 |
+
lint:
|
7 |
+
runs-on: ubuntu-latest
|
8 |
+
steps:
|
9 |
+
- uses: actions/checkout@v2
|
10 |
+
- name: Set up Python 3.7
|
11 |
+
uses: actions/setup-python@v2
|
12 |
+
with:
|
13 |
+
python-version: 3.7
|
14 |
+
- name: Install pre-commit hook
|
15 |
+
run: |
|
16 |
+
pip install pre-commit
|
17 |
+
pre-commit install
|
18 |
+
- name: Linting
|
19 |
+
run: pre-commit run --all-files
|
20 |
+
- name: Check docstring coverage
|
21 |
+
run: |
|
22 |
+
pip install interrogate
|
23 |
+
interrogate -v --ignore-init-method --ignore-module --ignore-nested-functions --ignore-regex "__repr__" --fail-under 80 mmdet
|
24 |
+
|
25 |
+
build_cpu:
|
26 |
+
runs-on: ubuntu-latest
|
27 |
+
strategy:
|
28 |
+
matrix:
|
29 |
+
python-version: [3.7]
|
30 |
+
torch: [1.3.1, 1.5.1, 1.6.0]
|
31 |
+
include:
|
32 |
+
- torch: 1.3.1
|
33 |
+
torchvision: 0.4.2
|
34 |
+
mmcv: "latest+torch1.3.0+cpu"
|
35 |
+
- torch: 1.5.1
|
36 |
+
torchvision: 0.6.1
|
37 |
+
mmcv: "latest+torch1.5.0+cpu"
|
38 |
+
- torch: 1.6.0
|
39 |
+
torchvision: 0.7.0
|
40 |
+
mmcv: "latest+torch1.6.0+cpu"
|
41 |
+
steps:
|
42 |
+
- uses: actions/checkout@v2
|
43 |
+
- name: Set up Python ${{ matrix.python-version }}
|
44 |
+
uses: actions/setup-python@v2
|
45 |
+
with:
|
46 |
+
python-version: ${{ matrix.python-version }}
|
47 |
+
- name: Install Pillow
|
48 |
+
run: pip install Pillow==6.2.2
|
49 |
+
if: ${{matrix.torchvision == '0.4.2'}}
|
50 |
+
- name: Install PyTorch
|
51 |
+
run: pip install torch==${{matrix.torch}}+cpu torchvision==${{matrix.torchvision}}+cpu -f https://download.pytorch.org/whl/torch_stable.html
|
52 |
+
- name: Install MMCV
|
53 |
+
run: |
|
54 |
+
pip install mmcv-full==${{matrix.mmcv}} -f https://download.openmmlab.com/mmcv/dist/index.html --use-deprecated=legacy-resolver
|
55 |
+
python -c 'import mmcv; print(mmcv.__version__)'
|
56 |
+
- name: Install unittest dependencies
|
57 |
+
run: pip install -r requirements/tests.txt -r requirements/optional.txt
|
58 |
+
- name: Build and install
|
59 |
+
run: rm -rf .eggs && pip install -e .
|
60 |
+
- name: Run unittests and generate coverage report
|
61 |
+
run: |
|
62 |
+
coverage run --branch --source mmdet -m pytest tests/
|
63 |
+
coverage xml
|
64 |
+
coverage report -m
|
65 |
+
|
66 |
+
build_cuda:
|
67 |
+
runs-on: ubuntu-latest
|
68 |
+
|
69 |
+
env:
|
70 |
+
CUDA: 10.1.105-1
|
71 |
+
CUDA_SHORT: 10.1
|
72 |
+
UBUNTU_VERSION: ubuntu1804
|
73 |
+
strategy:
|
74 |
+
matrix:
|
75 |
+
python-version: [3.7]
|
76 |
+
torch: [1.3.1, 1.5.1+cu101, 1.6.0+cu101]
|
77 |
+
include:
|
78 |
+
- torch: 1.3.1
|
79 |
+
torchvision: 0.4.2
|
80 |
+
mmcv: "latest+torch1.3.0+cu101"
|
81 |
+
- torch: 1.5.1+cu101
|
82 |
+
torchvision: 0.6.1+cu101
|
83 |
+
mmcv: "latest+torch1.5.0+cu101"
|
84 |
+
- torch: 1.6.0+cu101
|
85 |
+
torchvision: 0.7.0+cu101
|
86 |
+
mmcv: "latest+torch1.6.0+cu101"
|
87 |
+
- torch: 1.6.0+cu101
|
88 |
+
torchvision: 0.7.0+cu101
|
89 |
+
mmcv: "latest+torch1.6.0+cu101"
|
90 |
+
python-version: 3.6
|
91 |
+
- torch: 1.6.0+cu101
|
92 |
+
torchvision: 0.7.0+cu101
|
93 |
+
mmcv: "latest+torch1.6.0+cu101"
|
94 |
+
python-version: 3.8
|
95 |
+
|
96 |
+
steps:
|
97 |
+
- uses: actions/checkout@v2
|
98 |
+
- name: Set up Python ${{ matrix.python-version }}
|
99 |
+
uses: actions/setup-python@v2
|
100 |
+
with:
|
101 |
+
python-version: ${{ matrix.python-version }}
|
102 |
+
- name: Install CUDA
|
103 |
+
run: |
|
104 |
+
export INSTALLER=cuda-repo-${UBUNTU_VERSION}_${CUDA}_amd64.deb
|
105 |
+
wget http://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/x86_64/${INSTALLER}
|
106 |
+
sudo dpkg -i ${INSTALLER}
|
107 |
+
wget https://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/x86_64/7fa2af80.pub
|
108 |
+
sudo apt-key add 7fa2af80.pub
|
109 |
+
sudo apt update -qq
|
110 |
+
sudo apt install -y cuda-${CUDA_SHORT/./-} cuda-cufft-dev-${CUDA_SHORT/./-}
|
111 |
+
sudo apt clean
|
112 |
+
export CUDA_HOME=/usr/local/cuda-${CUDA_SHORT}
|
113 |
+
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${CUDA_HOME}/include:${LD_LIBRARY_PATH}
|
114 |
+
export PATH=${CUDA_HOME}/bin:${PATH}
|
115 |
+
- name: Install Pillow
|
116 |
+
run: pip install Pillow==6.2.2
|
117 |
+
if: ${{matrix.torchvision < 0.5}}
|
118 |
+
- name: Install PyTorch
|
119 |
+
run: pip install torch==${{matrix.torch}} torchvision==${{matrix.torchvision}} -f https://download.pytorch.org/whl/torch_stable.html
|
120 |
+
- name: Install mmdet dependencies
|
121 |
+
run: |
|
122 |
+
pip install mmcv-full==${{matrix.mmcv}} -f https://download.openmmlab.com/mmcv/dist/index.html --use-deprecated=legacy-resolver
|
123 |
+
pip install -r requirements.txt
|
124 |
+
python -c 'import mmcv; print(mmcv.__version__)'
|
125 |
+
- name: Build and install
|
126 |
+
run: |
|
127 |
+
rm -rf .eggs
|
128 |
+
python setup.py check -m -s
|
129 |
+
TORCH_CUDA_ARCH_LIST=7.0 pip install .
|
130 |
+
- name: Run unittests and generate coverage report
|
131 |
+
run: |
|
132 |
+
coverage run --branch --source mmdet -m pytest tests/
|
133 |
+
coverage xml
|
134 |
+
coverage report -m
|
135 |
+
- name: Upload coverage to Codecov
|
136 |
+
uses: codecov/[email protected]
|
137 |
+
with:
|
138 |
+
file: ./coverage.xml
|
139 |
+
flags: unittests
|
140 |
+
env_vars: OS,PYTHON
|
141 |
+
name: codecov-umbrella
|
142 |
+
fail_ci_if_error: false
|
.github/workflows/build_pat.yml
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: build_pat
|
2 |
+
|
3 |
+
on: push
|
4 |
+
|
5 |
+
jobs:
|
6 |
+
build_parrots:
|
7 |
+
runs-on: ubuntu-latest
|
8 |
+
container:
|
9 |
+
image: ghcr.io/sunnyxiaohu/parrots-mmcv:1.2.1
|
10 |
+
credentials:
|
11 |
+
username: sunnyxiaohu
|
12 |
+
password: ${{secrets.CR_PAT}}
|
13 |
+
|
14 |
+
steps:
|
15 |
+
- uses: actions/checkout@v2
|
16 |
+
- name: Install mmdet dependencies
|
17 |
+
run: |
|
18 |
+
git clone https://github.com/open-mmlab/mmcv.git && cd mmcv
|
19 |
+
MMCV_WITH_OPS=1 python setup.py install
|
20 |
+
cd .. && rm -rf mmcv
|
21 |
+
python -c 'import mmcv; print(mmcv.__version__)'
|
22 |
+
pip install -r requirements.txt
|
23 |
+
- name: Build and install
|
24 |
+
run: rm -rf .eggs && pip install -e .
|
.github/workflows/deploy.yml
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: deploy
|
2 |
+
|
3 |
+
on: push
|
4 |
+
|
5 |
+
jobs:
|
6 |
+
build-n-publish:
|
7 |
+
runs-on: ubuntu-latest
|
8 |
+
if: startsWith(github.event.ref, 'refs/tags')
|
9 |
+
steps:
|
10 |
+
- uses: actions/checkout@v2
|
11 |
+
- name: Set up Python 3.7
|
12 |
+
uses: actions/setup-python@v2
|
13 |
+
with:
|
14 |
+
python-version: 3.7
|
15 |
+
- name: Install torch
|
16 |
+
run: pip install torch
|
17 |
+
- name: Install wheel
|
18 |
+
run: pip install wheel
|
19 |
+
- name: Build MMDetection
|
20 |
+
run: python setup.py sdist bdist_wheel
|
21 |
+
- name: Publish distribution to PyPI
|
22 |
+
run: |
|
23 |
+
pip install twine
|
24 |
+
twine upload dist/* -u __token__ -p ${{ secrets.pypi_password }}
|
.pre-commit-config.yaml
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
repos:
|
2 |
+
- repo: https://gitlab.com/pycqa/flake8.git
|
3 |
+
rev: 3.8.3
|
4 |
+
hooks:
|
5 |
+
- id: flake8
|
6 |
+
- repo: https://github.com/asottile/seed-isort-config
|
7 |
+
rev: v2.2.0
|
8 |
+
hooks:
|
9 |
+
- id: seed-isort-config
|
10 |
+
- repo: https://github.com/timothycrosley/isort
|
11 |
+
rev: 4.3.21
|
12 |
+
hooks:
|
13 |
+
- id: isort
|
14 |
+
- repo: https://github.com/pre-commit/mirrors-yapf
|
15 |
+
rev: v0.30.0
|
16 |
+
hooks:
|
17 |
+
- id: yapf
|
18 |
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
19 |
+
rev: v3.1.0
|
20 |
+
hooks:
|
21 |
+
- id: trailing-whitespace
|
22 |
+
- id: check-yaml
|
23 |
+
- id: end-of-file-fixer
|
24 |
+
- id: requirements-txt-fixer
|
25 |
+
- id: double-quote-string-fixer
|
26 |
+
- id: check-merge-conflict
|
27 |
+
- id: fix-encoding-pragma
|
28 |
+
args: ["--remove"]
|
29 |
+
- id: mixed-line-ending
|
30 |
+
args: ["--fix=lf"]
|
31 |
+
- repo: https://github.com/jumanjihouse/pre-commit-hooks
|
32 |
+
rev: 2.1.4
|
33 |
+
hooks:
|
34 |
+
- id: markdownlint
|
35 |
+
args: ["-r", "~MD002,~MD013,~MD024,~MD029,~MD033,~MD034,~MD036"]
|
36 |
+
- repo: https://github.com/myint/docformatter
|
37 |
+
rev: v1.3.1
|
38 |
+
hooks:
|
39 |
+
- id: docformatter
|
40 |
+
args: ["--in-place", "--wrap-descriptions", "79"]
|
.readthedocs.yml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
version: 2
|
2 |
+
|
3 |
+
python:
|
4 |
+
version: 3.7
|
5 |
+
install:
|
6 |
+
- requirements: requirements/docs.txt
|
7 |
+
- requirements: requirements/readthedocs.txt
|
LICENSE
ADDED
@@ -0,0 +1,220 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Copyright 2018-2019 Open-MMLab. All rights reserved.
|
2 |
+
|
3 |
+
Apache License
|
4 |
+
Version 2.0, January 2004
|
5 |
+
http://www.apache.org/licenses/
|
6 |
+
|
7 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
8 |
+
|
9 |
+
1. Definitions.
|
10 |
+
|
11 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
12 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
13 |
+
|
14 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
15 |
+
the copyright owner that is granting the License.
|
16 |
+
|
17 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
18 |
+
other entities that control, are controlled by, or are under common
|
19 |
+
control with that entity. For the purposes of this definition,
|
20 |
+
"control" means (i) the power, direct or indirect, to cause the
|
21 |
+
direction or management of such entity, whether by contract or
|
22 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
23 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
24 |
+
|
25 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
26 |
+
exercising permissions granted by this License.
|
27 |
+
|
28 |
+
"Source" form shall mean the preferred form for making modifications,
|
29 |
+
including but not limited to software source code, documentation
|
30 |
+
source, and configuration files.
|
31 |
+
|
32 |
+
"Object" form shall mean any form resulting from mechanical
|
33 |
+
transformation or translation of a Source form, including but
|
34 |
+
not limited to compiled object code, generated documentation,
|
35 |
+
and conversions to other media types.
|
36 |
+
|
37 |
+
"Work" shall mean the work of authorship, whether in Source or
|
38 |
+
Object form, made available under the License, as indicated by a
|
39 |
+
copyright notice that is included in or attached to the work
|
40 |
+
(an example is provided in the Appendix below).
|
41 |
+
|
42 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
43 |
+
form, that is based on (or derived from) the Work and for which the
|
44 |
+
editorial revisions, annotations, elaborations, or other modifications
|
45 |
+
represent, as a whole, an original work of authorship. For the purposes
|
46 |
+
of this License, Derivative Works shall not include works that remain
|
47 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
48 |
+
the Work and Derivative Works thereof.
|
49 |
+
|
50 |
+
"Contribution" shall mean any work of authorship, including
|
51 |
+
the original version of the Work and any modifications or additions
|
52 |
+
to that Work or Derivative Works thereof, that is intentionally
|
53 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
54 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
55 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
56 |
+
means any form of electronic, verbal, or written communication sent
|
57 |
+
to the Licensor or its representatives, including but not limited to
|
58 |
+
communication on electronic mailing lists, source code control systems,
|
59 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
60 |
+
Licensor for the purpose of discussing and improving the Work, but
|
61 |
+
excluding communication that is conspicuously marked or otherwise
|
62 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
63 |
+
|
64 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
65 |
+
on behalf of whom a Contribution has been received by Licensor and
|
66 |
+
subsequently incorporated within the Work.
|
67 |
+
|
68 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
69 |
+
this License, each Contributor hereby grants to You a perpetual,
|
70 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
71 |
+
copyright license to reproduce, prepare Derivative Works of,
|
72 |
+
publicly display, publicly perform, sublicense, and distribute the
|
73 |
+
Work and such Derivative Works in Source or Object form.
|
74 |
+
|
75 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
76 |
+
this License, each Contributor hereby grants to You a perpetual,
|
77 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
78 |
+
(except as stated in this section) patent license to make, have made,
|
79 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
80 |
+
where such license applies only to those patent claims licensable
|
81 |
+
by such Contributor that are necessarily infringed by their
|
82 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
83 |
+
with the Work to which such Contribution(s) was submitted. If You
|
84 |
+
institute patent litigation against any entity (including a
|
85 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
86 |
+
or a Contribution incorporated within the Work constitutes direct
|
87 |
+
or contributory patent infringement, then any patent licenses
|
88 |
+
granted to You under this License for that Work shall terminate
|
89 |
+
as of the date such litigation is filed.
|
90 |
+
|
91 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
92 |
+
Work or Derivative Works thereof in any medium, with or without
|
93 |
+
modifications, and in Source or Object form, provided that You
|
94 |
+
meet the following conditions:
|
95 |
+
|
96 |
+
(a) You must give any other recipients of the Work or
|
97 |
+
Derivative Works a copy of this License; and
|
98 |
+
|
99 |
+
(b) You must cause any modified files to carry prominent notices
|
100 |
+
stating that You changed the files; and
|
101 |
+
|
102 |
+
(c) You must retain, in the Source form of any Derivative Works
|
103 |
+
that You distribute, all copyright, patent, trademark, and
|
104 |
+
attribution notices from the Source form of the Work,
|
105 |
+
excluding those notices that do not pertain to any part of
|
106 |
+
the Derivative Works; and
|
107 |
+
|
108 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
109 |
+
distribution, then any Derivative Works that You distribute must
|
110 |
+
include a readable copy of the attribution notices contained
|
111 |
+
within such NOTICE file, excluding those notices that do not
|
112 |
+
pertain to any part of the Derivative Works, in at least one
|
113 |
+
of the following places: within a NOTICE text file distributed
|
114 |
+
as part of the Derivative Works; within the Source form or
|
115 |
+
documentation, if provided along with the Derivative Works; or,
|
116 |
+
within a display generated by the Derivative Works, if and
|
117 |
+
wherever such third-party notices normally appear. The contents
|
118 |
+
of the NOTICE file are for informational purposes only and
|
119 |
+
do not modify the License. You may add Your own attribution
|
120 |
+
notices within Derivative Works that You distribute, alongside
|
121 |
+
or as an addendum to the NOTICE text from the Work, provided
|
122 |
+
that such additional attribution notices cannot be construed
|
123 |
+
as modifying the License.
|
124 |
+
|
125 |
+
You may add Your own copyright statement to Your modifications and
|
126 |
+
may provide additional or different license terms and conditions
|
127 |
+
for use, reproduction, or distribution of Your modifications, or
|
128 |
+
for any such Derivative Works as a whole, provided Your use,
|
129 |
+
reproduction, and distribution of the Work otherwise complies with
|
130 |
+
the conditions stated in this License.
|
131 |
+
|
132 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
133 |
+
any Contribution intentionally submitted for inclusion in the Work
|
134 |
+
by You to the Licensor shall be under the terms and conditions of
|
135 |
+
this License, without any additional terms or conditions.
|
136 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
137 |
+
the terms of any separate license agreement you may have executed
|
138 |
+
with Licensor regarding such Contributions.
|
139 |
+
|
140 |
+
6. Trademarks. This License does not grant permission to use the trade
|
141 |
+
names, trademarks, service marks, or product names of the Licensor,
|
142 |
+
except as required for reasonable and customary use in describing the
|
143 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
144 |
+
|
145 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
146 |
+
agreed to in writing, Licensor provides the Work (and each
|
147 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
148 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
149 |
+
implied, including, without limitation, any warranties or conditions
|
150 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
151 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
152 |
+
appropriateness of using or redistributing the Work and assume any
|
153 |
+
risks associated with Your exercise of permissions under this License.
|
154 |
+
|
155 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
156 |
+
whether in tort (including negligence), contract, or otherwise,
|
157 |
+
unless required by applicable law (such as deliberate and grossly
|
158 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
159 |
+
liable to You for damages, including any direct, indirect, special,
|
160 |
+
incidental, or consequential damages of any character arising as a
|
161 |
+
result of this License or out of the use or inability to use the
|
162 |
+
Work (including but not limited to damages for loss of goodwill,
|
163 |
+
work stoppage, computer failure or malfunction, or any and all
|
164 |
+
other commercial damages or losses), even if such Contributor
|
165 |
+
has been advised of the possibility of such damages.
|
166 |
+
|
167 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
168 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
169 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
170 |
+
or other liability obligations and/or rights consistent with this
|
171 |
+
License. However, in accepting such obligations, You may act only
|
172 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
173 |
+
of any other Contributor, and only if You agree to indemnify,
|
174 |
+
defend, and hold each Contributor harmless for any liability
|
175 |
+
incurred by, or claims asserted against, such Contributor by reason
|
176 |
+
of your accepting any such warranty or additional liability.
|
177 |
+
|
178 |
+
END OF TERMS AND CONDITIONS
|
179 |
+
|
180 |
+
APPENDIX: How to apply the Apache License to your work.
|
181 |
+
|
182 |
+
To apply the Apache License to your work, attach the following
|
183 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
184 |
+
replaced with your own identifying information. (Don't include
|
185 |
+
the brackets!) The text should be enclosed in the appropriate
|
186 |
+
comment syntax for the file format. We also recommend that a
|
187 |
+
file or class name and description of purpose be included on the
|
188 |
+
same "printed page" as the copyright notice for easier
|
189 |
+
identification within third-party archives.
|
190 |
+
|
191 |
+
Copyright 2018-2019 Open-MMLab.
|
192 |
+
|
193 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
194 |
+
you may not use this file except in compliance with the License.
|
195 |
+
You may obtain a copy of the License at
|
196 |
+
|
197 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
198 |
+
|
199 |
+
Unless required by applicable law or agreed to in writing, software
|
200 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
201 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
202 |
+
See the License for the specific language governing permissions and
|
203 |
+
limitations under the License.
|
204 |
+
|
205 |
+
|
206 |
+
======================================================================================
|
207 |
+
Swin-Transformer-Object-Detection Subcomponents:
|
208 |
+
|
209 |
+
The Swin-Transformer-Object-Detection project contains subcomponents with separate
|
210 |
+
copyright notices and license terms. Your use of the source code for the these
|
211 |
+
subcomponents is subject to the terms and conditions of the following licenses.
|
212 |
+
|
213 |
+
=======================================================================================
|
214 |
+
MIT license
|
215 |
+
=======================================================================================
|
216 |
+
|
217 |
+
The following components are provided under an MIT license.
|
218 |
+
|
219 |
+
1. swin_transformer.py - For details, mmdet/models/backbones/swin_transformer.py
|
220 |
+
Copyright (c) 2021 Microsoft
|
configs/_base_/datasets/cityscapes_detection.py
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
dataset_type = 'CityscapesDataset'
|
2 |
+
data_root = 'data/cityscapes/'
|
3 |
+
img_norm_cfg = dict(
|
4 |
+
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
|
5 |
+
train_pipeline = [
|
6 |
+
dict(type='LoadImageFromFile'),
|
7 |
+
dict(type='LoadAnnotations', with_bbox=True),
|
8 |
+
dict(
|
9 |
+
type='Resize', img_scale=[(2048, 800), (2048, 1024)], keep_ratio=True),
|
10 |
+
dict(type='RandomFlip', flip_ratio=0.5),
|
11 |
+
dict(type='Normalize', **img_norm_cfg),
|
12 |
+
dict(type='Pad', size_divisor=32),
|
13 |
+
dict(type='DefaultFormatBundle'),
|
14 |
+
dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels']),
|
15 |
+
]
|
16 |
+
test_pipeline = [
|
17 |
+
dict(type='LoadImageFromFile'),
|
18 |
+
dict(
|
19 |
+
type='MultiScaleFlipAug',
|
20 |
+
img_scale=(2048, 1024),
|
21 |
+
flip=False,
|
22 |
+
transforms=[
|
23 |
+
dict(type='Resize', keep_ratio=True),
|
24 |
+
dict(type='RandomFlip'),
|
25 |
+
dict(type='Normalize', **img_norm_cfg),
|
26 |
+
dict(type='Pad', size_divisor=32),
|
27 |
+
dict(type='ImageToTensor', keys=['img']),
|
28 |
+
dict(type='Collect', keys=['img']),
|
29 |
+
])
|
30 |
+
]
|
31 |
+
data = dict(
|
32 |
+
samples_per_gpu=1,
|
33 |
+
workers_per_gpu=2,
|
34 |
+
train=dict(
|
35 |
+
type='RepeatDataset',
|
36 |
+
times=8,
|
37 |
+
dataset=dict(
|
38 |
+
type=dataset_type,
|
39 |
+
ann_file=data_root +
|
40 |
+
'annotations/instancesonly_filtered_gtFine_train.json',
|
41 |
+
img_prefix=data_root + 'leftImg8bit/train/',
|
42 |
+
pipeline=train_pipeline)),
|
43 |
+
val=dict(
|
44 |
+
type=dataset_type,
|
45 |
+
ann_file=data_root +
|
46 |
+
'annotations/instancesonly_filtered_gtFine_val.json',
|
47 |
+
img_prefix=data_root + 'leftImg8bit/val/',
|
48 |
+
pipeline=test_pipeline),
|
49 |
+
test=dict(
|
50 |
+
type=dataset_type,
|
51 |
+
ann_file=data_root +
|
52 |
+
'annotations/instancesonly_filtered_gtFine_test.json',
|
53 |
+
img_prefix=data_root + 'leftImg8bit/test/',
|
54 |
+
pipeline=test_pipeline))
|
55 |
+
evaluation = dict(interval=1, metric='bbox')
|
configs/_base_/datasets/cityscapes_instance.py
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
dataset_type = 'CityscapesDataset'
|
2 |
+
data_root = 'data/cityscapes/'
|
3 |
+
img_norm_cfg = dict(
|
4 |
+
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
|
5 |
+
train_pipeline = [
|
6 |
+
dict(type='LoadImageFromFile'),
|
7 |
+
dict(type='LoadAnnotations', with_bbox=True, with_mask=True),
|
8 |
+
dict(
|
9 |
+
type='Resize', img_scale=[(2048, 800), (2048, 1024)], keep_ratio=True),
|
10 |
+
dict(type='RandomFlip', flip_ratio=0.5),
|
11 |
+
dict(type='Normalize', **img_norm_cfg),
|
12 |
+
dict(type='Pad', size_divisor=32),
|
13 |
+
dict(type='DefaultFormatBundle'),
|
14 |
+
dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels', 'gt_masks']),
|
15 |
+
]
|
16 |
+
test_pipeline = [
|
17 |
+
dict(type='LoadImageFromFile'),
|
18 |
+
dict(
|
19 |
+
type='MultiScaleFlipAug',
|
20 |
+
img_scale=(2048, 1024),
|
21 |
+
flip=False,
|
22 |
+
transforms=[
|
23 |
+
dict(type='Resize', keep_ratio=True),
|
24 |
+
dict(type='RandomFlip'),
|
25 |
+
dict(type='Normalize', **img_norm_cfg),
|
26 |
+
dict(type='Pad', size_divisor=32),
|
27 |
+
dict(type='ImageToTensor', keys=['img']),
|
28 |
+
dict(type='Collect', keys=['img']),
|
29 |
+
])
|
30 |
+
]
|
31 |
+
data = dict(
|
32 |
+
samples_per_gpu=1,
|
33 |
+
workers_per_gpu=2,
|
34 |
+
train=dict(
|
35 |
+
type='RepeatDataset',
|
36 |
+
times=8,
|
37 |
+
dataset=dict(
|
38 |
+
type=dataset_type,
|
39 |
+
ann_file=data_root +
|
40 |
+
'annotations/instancesonly_filtered_gtFine_train.json',
|
41 |
+
img_prefix=data_root + 'leftImg8bit/train/',
|
42 |
+
pipeline=train_pipeline)),
|
43 |
+
val=dict(
|
44 |
+
type=dataset_type,
|
45 |
+
ann_file=data_root +
|
46 |
+
'annotations/instancesonly_filtered_gtFine_val.json',
|
47 |
+
img_prefix=data_root + 'leftImg8bit/val/',
|
48 |
+
pipeline=test_pipeline),
|
49 |
+
test=dict(
|
50 |
+
type=dataset_type,
|
51 |
+
ann_file=data_root +
|
52 |
+
'annotations/instancesonly_filtered_gtFine_test.json',
|
53 |
+
img_prefix=data_root + 'leftImg8bit/test/',
|
54 |
+
pipeline=test_pipeline))
|
55 |
+
evaluation = dict(metric=['bbox', 'segm'])
|
configs/_base_/datasets/coco_detection.py
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""目标检测
|
2 |
+
路径/configs/base/datasets/coco_detection.py,
|
3 |
+
第2行的data_toot数据集根目录路径,
|
4 |
+
第8行的img_scale可以根据需要修改,
|
5 |
+
第39行的samples_per_gpu表示batch size大小,太大会内存溢出
|
6 |
+
第40行的workers_per_gpu表示每个GPU对应线程数,2、4、6、8按需修改
|
7 |
+
下面train、test、val数据集的具体路径ann_file根据自己数据集修改
|
8 |
+
"""
|
9 |
+
dataset_type = 'CocoDataset'
|
10 |
+
data_root = 'data/coco/'
|
11 |
+
img_norm_cfg = dict(
|
12 |
+
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
|
13 |
+
train_pipeline = [
|
14 |
+
dict(type='LoadImageFromFile'),
|
15 |
+
dict(type='LoadAnnotations', with_bbox=True), # , with_mask=False ,with_seg=False, poly2mask=False
|
16 |
+
dict(type='Resize', img_scale = [(224, 224)], keep_ratio=True),
|
17 |
+
dict(type='RandomFlip', flip_ratio=0.5),
|
18 |
+
dict(type='Normalize', **img_norm_cfg),
|
19 |
+
dict(type='Pad', size_divisor=32),
|
20 |
+
dict(type='DefaultFormatBundle'),
|
21 |
+
dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels']),
|
22 |
+
]
|
23 |
+
test_pipeline = [
|
24 |
+
dict(type='LoadImageFromFile'),
|
25 |
+
dict(
|
26 |
+
type='MultiScaleFlipAug',
|
27 |
+
img_scale = [(224, 224)],
|
28 |
+
flip=False,
|
29 |
+
transforms=[
|
30 |
+
dict(type='Resize', keep_ratio=True),
|
31 |
+
dict(type='RandomFlip'),
|
32 |
+
dict(type='Normalize', **img_norm_cfg),
|
33 |
+
dict(type='Pad', size_divisor=32),
|
34 |
+
dict(type='ImageToTensor', keys=['img']),
|
35 |
+
dict(type='Collect', keys=['img']),
|
36 |
+
])
|
37 |
+
]
|
38 |
+
data = dict(
|
39 |
+
samples_per_gpu=1,
|
40 |
+
workers_per_gpu=8,
|
41 |
+
train=dict(
|
42 |
+
type=dataset_type,
|
43 |
+
ann_file=data_root + 'annotations/train.json',
|
44 |
+
img_prefix=data_root + 'train/',
|
45 |
+
pipeline=train_pipeline),
|
46 |
+
val=dict(
|
47 |
+
type=dataset_type,
|
48 |
+
ann_file=data_root + 'annotations/val.json',
|
49 |
+
img_prefix=data_root + 'val/',
|
50 |
+
pipeline=test_pipeline),
|
51 |
+
test=dict(
|
52 |
+
type=dataset_type,
|
53 |
+
ann_file=data_root + 'annotations/val.json',
|
54 |
+
img_prefix=data_root + 'val/',
|
55 |
+
pipeline=test_pipeline))
|
56 |
+
evaluation = dict(interval=1, metric='bbox')
|
configs/_base_/datasets/coco_instance.py
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""实例分割"""
|
2 |
+
dataset_type = 'CocoDataset'
|
3 |
+
data_root = 'data/coco/'
|
4 |
+
img_norm_cfg = dict(
|
5 |
+
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
|
6 |
+
train_pipeline = [
|
7 |
+
dict(type='LoadImageFromFile'),
|
8 |
+
dict(type='LoadAnnotations', with_bbox=True, with_mask=True),
|
9 |
+
dict(type='Resize', img_scale = [(224, 224)], keep_ratio=True),
|
10 |
+
dict(type='RandomFlip', flip_ratio=0.5),
|
11 |
+
dict(type='Normalize', **img_norm_cfg),
|
12 |
+
dict(type='Pad', size_divisor=32),
|
13 |
+
dict(type='DefaultFormatBundle'),
|
14 |
+
dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels', 'gt_masks']),
|
15 |
+
]
|
16 |
+
test_pipeline = [
|
17 |
+
dict(type='LoadImageFromFile'),
|
18 |
+
dict(
|
19 |
+
type='MultiScaleFlipAug',
|
20 |
+
img_scale = [(224, 224)] ,
|
21 |
+
flip=False,
|
22 |
+
transforms=[
|
23 |
+
dict(type='Resize', keep_ratio=True),
|
24 |
+
dict(type='RandomFlip'),
|
25 |
+
dict(type='Normalize', **img_norm_cfg),
|
26 |
+
dict(type='Pad', size_divisor=32),
|
27 |
+
dict(type='ImageToTensor', keys=['img']),
|
28 |
+
dict(type='Collect', keys=['img']),
|
29 |
+
])
|
30 |
+
]
|
31 |
+
data = dict(
|
32 |
+
samples_per_gpu=1, # batch size
|
33 |
+
workers_per_gpu=2, # 每个GPU对应线程数 可以大一些
|
34 |
+
|
35 |
+
train=dict(
|
36 |
+
type=dataset_type,
|
37 |
+
ann_file=data_root + 'annotations/train.json',
|
38 |
+
img_prefix=data_root + 'train/',
|
39 |
+
pipeline=train_pipeline),
|
40 |
+
val=dict(
|
41 |
+
type=dataset_type,
|
42 |
+
ann_file=data_root + 'annotations/val.json',
|
43 |
+
img_prefix=data_root + 'val/',
|
44 |
+
pipeline=test_pipeline),
|
45 |
+
test=dict(
|
46 |
+
type=dataset_type,
|
47 |
+
ann_file=data_root + 'annotations/val.json',
|
48 |
+
img_prefix=data_root + 'val/',
|
49 |
+
pipeline=test_pipeline))
|
50 |
+
evaluation = dict(metric=['bbox', 'segm'])
|
configs/_base_/datasets/coco_instance_semantic.py
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
dataset_type = 'CocoDataset'
|
2 |
+
data_root = 'data/coco/'
|
3 |
+
img_norm_cfg = dict(
|
4 |
+
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
|
5 |
+
train_pipeline = [
|
6 |
+
dict(type='LoadImageFromFile'),
|
7 |
+
dict(
|
8 |
+
type='LoadAnnotations', with_bbox=True, with_mask=True, with_seg=True),
|
9 |
+
dict(type='Resize', img_scale=(1333, 800), keep_ratio=True),
|
10 |
+
dict(type='RandomFlip', flip_ratio=0.5),
|
11 |
+
dict(type='Normalize', **img_norm_cfg),
|
12 |
+
dict(type='Pad', size_divisor=32),
|
13 |
+
dict(type='SegRescale', scale_factor=1 / 8),
|
14 |
+
dict(type='DefaultFormatBundle'),
|
15 |
+
dict(
|
16 |
+
type='Collect',
|
17 |
+
keys=['img', 'gt_bboxes', 'gt_labels', 'gt_masks', 'gt_semantic_seg']),
|
18 |
+
]
|
19 |
+
test_pipeline = [
|
20 |
+
dict(type='LoadImageFromFile'),
|
21 |
+
dict(
|
22 |
+
type='MultiScaleFlipAug',
|
23 |
+
img_scale=(1333, 800),
|
24 |
+
flip=False,
|
25 |
+
transforms=[
|
26 |
+
dict(type='Resize', keep_ratio=True),
|
27 |
+
dict(type='RandomFlip', flip_ratio=0.5),
|
28 |
+
dict(type='Normalize', **img_norm_cfg),
|
29 |
+
dict(type='Pad', size_divisor=32),
|
30 |
+
dict(type='ImageToTensor', keys=['img']),
|
31 |
+
dict(type='Collect', keys=['img']),
|
32 |
+
])
|
33 |
+
]
|
34 |
+
data = dict(
|
35 |
+
samples_per_gpu=2,
|
36 |
+
workers_per_gpu=2,
|
37 |
+
train=dict(
|
38 |
+
type=dataset_type,
|
39 |
+
ann_file=data_root + 'annotations/instances_train2017.json',
|
40 |
+
img_prefix=data_root + 'train2017/',
|
41 |
+
seg_prefix=data_root + 'stuffthingmaps/train2017/',
|
42 |
+
pipeline=train_pipeline),
|
43 |
+
val=dict(
|
44 |
+
type=dataset_type,
|
45 |
+
ann_file=data_root + 'annotations/instances_val2017.json',
|
46 |
+
img_prefix=data_root + 'val2017/',
|
47 |
+
pipeline=test_pipeline),
|
48 |
+
test=dict(
|
49 |
+
type=dataset_type,
|
50 |
+
ann_file=data_root + 'annotations/instances_val2017.json',
|
51 |
+
img_prefix=data_root + 'val2017/',
|
52 |
+
pipeline=test_pipeline))
|
53 |
+
evaluation = dict(metric=['bbox', 'segm'])
|
configs/_base_/datasets/deepfashion.py
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# dataset settings
|
2 |
+
dataset_type = 'DeepFashionDataset'
|
3 |
+
data_root = 'data/DeepFashion/In-shop/'
|
4 |
+
img_norm_cfg = dict(
|
5 |
+
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
|
6 |
+
train_pipeline = [
|
7 |
+
dict(type='LoadImageFromFile'),
|
8 |
+
dict(type='LoadAnnotations', with_bbox=True, with_mask=True),
|
9 |
+
dict(type='Resize', img_scale=(750, 1101), keep_ratio=True),
|
10 |
+
dict(type='RandomFlip', flip_ratio=0.5),
|
11 |
+
dict(type='Normalize', **img_norm_cfg),
|
12 |
+
dict(type='Pad', size_divisor=32),
|
13 |
+
dict(type='DefaultFormatBundle'),
|
14 |
+
dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels', 'gt_masks']),
|
15 |
+
]
|
16 |
+
test_pipeline = [
|
17 |
+
dict(type='LoadImageFromFile'),
|
18 |
+
dict(
|
19 |
+
type='MultiScaleFlipAug',
|
20 |
+
img_scale=(750, 1101),
|
21 |
+
flip=False,
|
22 |
+
transforms=[
|
23 |
+
dict(type='Resize', keep_ratio=True),
|
24 |
+
dict(type='RandomFlip'),
|
25 |
+
dict(type='Normalize', **img_norm_cfg),
|
26 |
+
dict(type='Pad', size_divisor=32),
|
27 |
+
dict(type='ImageToTensor', keys=['img']),
|
28 |
+
dict(type='Collect', keys=['img']),
|
29 |
+
])
|
30 |
+
]
|
31 |
+
data = dict(
|
32 |
+
imgs_per_gpu=2,
|
33 |
+
workers_per_gpu=1,
|
34 |
+
train=dict(
|
35 |
+
type=dataset_type,
|
36 |
+
ann_file=data_root + 'annotations/DeepFashion_segmentation_query.json',
|
37 |
+
img_prefix=data_root + 'Img/',
|
38 |
+
pipeline=train_pipeline,
|
39 |
+
data_root=data_root),
|
40 |
+
val=dict(
|
41 |
+
type=dataset_type,
|
42 |
+
ann_file=data_root + 'annotations/DeepFashion_segmentation_query.json',
|
43 |
+
img_prefix=data_root + 'Img/',
|
44 |
+
pipeline=test_pipeline,
|
45 |
+
data_root=data_root),
|
46 |
+
test=dict(
|
47 |
+
type=dataset_type,
|
48 |
+
ann_file=data_root +
|
49 |
+
'annotations/DeepFashion_segmentation_gallery.json',
|
50 |
+
img_prefix=data_root + 'Img/',
|
51 |
+
pipeline=test_pipeline,
|
52 |
+
data_root=data_root))
|
53 |
+
evaluation = dict(interval=5, metric=['bbox', 'segm'])
|
configs/_base_/datasets/lvis_v0.5_instance.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
_base_ = 'coco_instance.py'
|
2 |
+
dataset_type = 'LVISV05Dataset'
|
3 |
+
data_root = 'data/lvis_v0.5/'
|
4 |
+
data = dict(
|
5 |
+
samples_per_gpu=2,
|
6 |
+
workers_per_gpu=2,
|
7 |
+
train=dict(
|
8 |
+
_delete_=True,
|
9 |
+
type='ClassBalancedDataset',
|
10 |
+
oversample_thr=1e-3,
|
11 |
+
dataset=dict(
|
12 |
+
type=dataset_type,
|
13 |
+
ann_file=data_root + 'annotations/lvis_v0.5_train.json',
|
14 |
+
img_prefix=data_root + 'train2017/')),
|
15 |
+
val=dict(
|
16 |
+
type=dataset_type,
|
17 |
+
ann_file=data_root + 'annotations/lvis_v0.5_val.json',
|
18 |
+
img_prefix=data_root + 'val2017/'),
|
19 |
+
test=dict(
|
20 |
+
type=dataset_type,
|
21 |
+
ann_file=data_root + 'annotations/lvis_v0.5_val.json',
|
22 |
+
img_prefix=data_root + 'val2017/'))
|
23 |
+
evaluation = dict(metric=['bbox', 'segm'])
|
configs/_base_/datasets/lvis_v1_instance.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
_base_ = 'coco_instance.py'
|
2 |
+
dataset_type = 'LVISV1Dataset'
|
3 |
+
data_root = 'data/lvis_v1/'
|
4 |
+
data = dict(
|
5 |
+
samples_per_gpu=2,
|
6 |
+
workers_per_gpu=2,
|
7 |
+
train=dict(
|
8 |
+
_delete_=True,
|
9 |
+
type='ClassBalancedDataset',
|
10 |
+
oversample_thr=1e-3,
|
11 |
+
dataset=dict(
|
12 |
+
type=dataset_type,
|
13 |
+
ann_file=data_root + 'annotations/lvis_v1_train.json',
|
14 |
+
img_prefix=data_root)),
|
15 |
+
val=dict(
|
16 |
+
type=dataset_type,
|
17 |
+
ann_file=data_root + 'annotations/lvis_v1_val.json',
|
18 |
+
img_prefix=data_root),
|
19 |
+
test=dict(
|
20 |
+
type=dataset_type,
|
21 |
+
ann_file=data_root + 'annotations/lvis_v1_val.json',
|
22 |
+
img_prefix=data_root))
|
23 |
+
evaluation = dict(metric=['bbox', 'segm'])
|
configs/_base_/datasets/voc0712.py
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# dataset settings
|
2 |
+
dataset_type = 'VOCDataset'
|
3 |
+
data_root = 'data/VOCdevkit/'
|
4 |
+
img_norm_cfg = dict(
|
5 |
+
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
|
6 |
+
train_pipeline = [
|
7 |
+
dict(type='LoadImageFromFile'),
|
8 |
+
dict(type='LoadAnnotations', with_bbox=True),
|
9 |
+
dict(type='Resize', img_scale=(1000, 600), keep_ratio=True),
|
10 |
+
dict(type='RandomFlip', flip_ratio=0.5),
|
11 |
+
dict(type='Normalize', **img_norm_cfg),
|
12 |
+
dict(type='Pad', size_divisor=32),
|
13 |
+
dict(type='DefaultFormatBundle'),
|
14 |
+
dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels']),
|
15 |
+
]
|
16 |
+
test_pipeline = [
|
17 |
+
dict(type='LoadImageFromFile'),
|
18 |
+
dict(
|
19 |
+
type='MultiScaleFlipAug',
|
20 |
+
img_scale=(1000, 600),
|
21 |
+
flip=False,
|
22 |
+
transforms=[
|
23 |
+
dict(type='Resize', keep_ratio=True),
|
24 |
+
dict(type='RandomFlip'),
|
25 |
+
dict(type='Normalize', **img_norm_cfg),
|
26 |
+
dict(type='Pad', size_divisor=32),
|
27 |
+
dict(type='ImageToTensor', keys=['img']),
|
28 |
+
dict(type='Collect', keys=['img']),
|
29 |
+
])
|
30 |
+
]
|
31 |
+
data = dict(
|
32 |
+
samples_per_gpu=2,
|
33 |
+
workers_per_gpu=2,
|
34 |
+
train=dict(
|
35 |
+
type='RepeatDataset',
|
36 |
+
times=3,
|
37 |
+
dataset=dict(
|
38 |
+
type=dataset_type,
|
39 |
+
ann_file=[
|
40 |
+
data_root + 'VOC2007/ImageSets/Main/trainval.txt',
|
41 |
+
data_root + 'VOC2012/ImageSets/Main/trainval.txt'
|
42 |
+
],
|
43 |
+
img_prefix=[data_root + 'VOC2007/', data_root + 'VOC2012/'],
|
44 |
+
pipeline=train_pipeline)),
|
45 |
+
val=dict(
|
46 |
+
type=dataset_type,
|
47 |
+
ann_file=data_root + 'VOC2007/ImageSets/Main/test.txt',
|
48 |
+
img_prefix=data_root + 'VOC2007/',
|
49 |
+
pipeline=test_pipeline),
|
50 |
+
test=dict(
|
51 |
+
type=dataset_type,
|
52 |
+
ann_file=data_root + 'VOC2007/ImageSets/Main/test.txt',
|
53 |
+
img_prefix=data_root + 'VOC2007/',
|
54 |
+
pipeline=test_pipeline))
|
55 |
+
evaluation = dict(interval=1, metric='mAP')
|
configs/_base_/datasets/wider_face.py
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# dataset settings
|
2 |
+
dataset_type = 'WIDERFaceDataset'
|
3 |
+
data_root = 'data/WIDERFace/'
|
4 |
+
img_norm_cfg = dict(mean=[123.675, 116.28, 103.53], std=[1, 1, 1], to_rgb=True)
|
5 |
+
train_pipeline = [
|
6 |
+
dict(type='LoadImageFromFile', to_float32=True),
|
7 |
+
dict(type='LoadAnnotations', with_bbox=True),
|
8 |
+
dict(
|
9 |
+
type='PhotoMetricDistortion',
|
10 |
+
brightness_delta=32,
|
11 |
+
contrast_range=(0.5, 1.5),
|
12 |
+
saturation_range=(0.5, 1.5),
|
13 |
+
hue_delta=18),
|
14 |
+
dict(
|
15 |
+
type='Expand',
|
16 |
+
mean=img_norm_cfg['mean'],
|
17 |
+
to_rgb=img_norm_cfg['to_rgb'],
|
18 |
+
ratio_range=(1, 4)),
|
19 |
+
dict(
|
20 |
+
type='MinIoURandomCrop',
|
21 |
+
min_ious=(0.1, 0.3, 0.5, 0.7, 0.9),
|
22 |
+
min_crop_size=0.3),
|
23 |
+
dict(type='Resize', img_scale=(300, 300), keep_ratio=False),
|
24 |
+
dict(type='Normalize', **img_norm_cfg),
|
25 |
+
dict(type='RandomFlip', flip_ratio=0.5),
|
26 |
+
dict(type='DefaultFormatBundle'),
|
27 |
+
dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels']),
|
28 |
+
]
|
29 |
+
test_pipeline = [
|
30 |
+
dict(type='LoadImageFromFile'),
|
31 |
+
dict(
|
32 |
+
type='MultiScaleFlipAug',
|
33 |
+
img_scale=(300, 300),
|
34 |
+
flip=False,
|
35 |
+
transforms=[
|
36 |
+
dict(type='Resize', keep_ratio=False),
|
37 |
+
dict(type='Normalize', **img_norm_cfg),
|
38 |
+
dict(type='ImageToTensor', keys=['img']),
|
39 |
+
dict(type='Collect', keys=['img']),
|
40 |
+
])
|
41 |
+
]
|
42 |
+
data = dict(
|
43 |
+
samples_per_gpu=60,
|
44 |
+
workers_per_gpu=2,
|
45 |
+
train=dict(
|
46 |
+
type='RepeatDataset',
|
47 |
+
times=2,
|
48 |
+
dataset=dict(
|
49 |
+
type=dataset_type,
|
50 |
+
ann_file=data_root + 'train.txt',
|
51 |
+
img_prefix=data_root + 'WIDER_train/',
|
52 |
+
min_size=17,
|
53 |
+
pipeline=train_pipeline)),
|
54 |
+
val=dict(
|
55 |
+
type=dataset_type,
|
56 |
+
ann_file=data_root + 'val.txt',
|
57 |
+
img_prefix=data_root + 'WIDER_val/',
|
58 |
+
pipeline=test_pipeline),
|
59 |
+
test=dict(
|
60 |
+
type=dataset_type,
|
61 |
+
ann_file=data_root + 'val.txt',
|
62 |
+
img_prefix=data_root + 'WIDER_val/',
|
63 |
+
pipeline=test_pipeline))
|
configs/_base_/default_runtime.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
路径/configs/base/default_runtime.py中:
|
3 |
+
第1行interval=1表示每1个epoch保存一次权重信息
|
4 |
+
第4行interval=50表示每50次打印一次日志信息
|
5 |
+
第14行load_from表示加载训练好的权重路径,可以不设置,在训练时终端中给定
|
6 |
+
"""
|
7 |
+
# 表示多少个 epoch 验证一次,然后保存一次权重信息
|
8 |
+
# interval=1 表示每1个epoch保存一次权重信息
|
9 |
+
checkpoint_config = dict(interval=25)
|
10 |
+
# yapf:disable
|
11 |
+
|
12 |
+
log_config = dict(
|
13 |
+
interval=20, # 表示20个 epoch 打印一次日志信息
|
14 |
+
hooks=[
|
15 |
+
dict(type='TextLoggerHook'),
|
16 |
+
# dict(type='TensorboardLoggerHook')
|
17 |
+
])
|
18 |
+
# yapf:enable
|
19 |
+
custom_hooks = [dict(type='NumClassCheckHook')]
|
20 |
+
|
21 |
+
dist_params = dict(backend='nccl')
|
22 |
+
log_level = 'INFO'
|
23 |
+
# loadfrom:表示加载哪一个训练好的权重
|
24 |
+
load_from = None
|
25 |
+
# load_from = r"checkpoints/latest.pth"
|
26 |
+
# load_from = r"checkpoints/mask_rcnn_swin_tiny_patch4_window7.pth"
|
27 |
+
# load_from = r"D:\Coding\University Course Study\CV project\Swin-Transformer-Object-Detection\mask_rcnn_swin_tiny_patch4_window7.pth"
|
28 |
+
resume_from = None
|
29 |
+
workflow = [('train', 1)]
|
configs/_base_/models/cascade_mask_rcnn_r50_fpn.py
ADDED
@@ -0,0 +1,196 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# model settings
|
2 |
+
model = dict(
|
3 |
+
type='CascadeRCNN',
|
4 |
+
pretrained='torchvision://resnet50',
|
5 |
+
backbone=dict(
|
6 |
+
type='ResNet',
|
7 |
+
depth=50,
|
8 |
+
num_stages=4,
|
9 |
+
out_indices=(0, 1, 2, 3),
|
10 |
+
frozen_stages=1,
|
11 |
+
norm_cfg=dict(type='BN', requires_grad=True),
|
12 |
+
norm_eval=True,
|
13 |
+
style='pytorch'),
|
14 |
+
neck=dict(
|
15 |
+
type='FPN',
|
16 |
+
in_channels=[256, 512, 1024, 2048],
|
17 |
+
out_channels=256,
|
18 |
+
num_outs=5),
|
19 |
+
rpn_head=dict(
|
20 |
+
type='RPNHead',
|
21 |
+
in_channels=256,
|
22 |
+
feat_channels=256,
|
23 |
+
anchor_generator=dict(
|
24 |
+
type='AnchorGenerator',
|
25 |
+
scales=[8],
|
26 |
+
ratios=[0.5, 1.0, 2.0],
|
27 |
+
strides=[4, 8, 16, 32, 64]),
|
28 |
+
bbox_coder=dict(
|
29 |
+
type='DeltaXYWHBBoxCoder',
|
30 |
+
target_means=[.0, .0, .0, .0],
|
31 |
+
target_stds=[1.0, 1.0, 1.0, 1.0]),
|
32 |
+
loss_cls=dict(
|
33 |
+
type='CrossEntropyLoss', use_sigmoid=True, loss_weight=1.0),
|
34 |
+
loss_bbox=dict(type='SmoothL1Loss', beta=1.0 / 9.0, loss_weight=1.0)),
|
35 |
+
roi_head=dict(
|
36 |
+
type='CascadeRoIHead',
|
37 |
+
num_stages=3,
|
38 |
+
stage_loss_weights=[1, 0.5, 0.25],
|
39 |
+
bbox_roi_extractor=dict(
|
40 |
+
type='SingleRoIExtractor',
|
41 |
+
roi_layer=dict(type='RoIAlign', output_size=7, sampling_ratio=0),
|
42 |
+
out_channels=256,
|
43 |
+
featmap_strides=[4, 8, 16, 32]),
|
44 |
+
bbox_head=[
|
45 |
+
dict(
|
46 |
+
type='Shared2FCBBoxHead',
|
47 |
+
in_channels=256,
|
48 |
+
fc_out_channels=1024,
|
49 |
+
roi_feat_size=7,
|
50 |
+
num_classes=80,
|
51 |
+
bbox_coder=dict(
|
52 |
+
type='DeltaXYWHBBoxCoder',
|
53 |
+
target_means=[0., 0., 0., 0.],
|
54 |
+
target_stds=[0.1, 0.1, 0.2, 0.2]),
|
55 |
+
reg_class_agnostic=True,
|
56 |
+
loss_cls=dict(
|
57 |
+
type='CrossEntropyLoss',
|
58 |
+
use_sigmoid=False,
|
59 |
+
loss_weight=1.0),
|
60 |
+
loss_bbox=dict(type='SmoothL1Loss', beta=1.0,
|
61 |
+
loss_weight=1.0)),
|
62 |
+
dict(
|
63 |
+
type='Shared2FCBBoxHead',
|
64 |
+
in_channels=256,
|
65 |
+
fc_out_channels=1024,
|
66 |
+
roi_feat_size=7,
|
67 |
+
num_classes=80,
|
68 |
+
bbox_coder=dict(
|
69 |
+
type='DeltaXYWHBBoxCoder',
|
70 |
+
target_means=[0., 0., 0., 0.],
|
71 |
+
target_stds=[0.05, 0.05, 0.1, 0.1]),
|
72 |
+
reg_class_agnostic=True,
|
73 |
+
loss_cls=dict(
|
74 |
+
type='CrossEntropyLoss',
|
75 |
+
use_sigmoid=False,
|
76 |
+
loss_weight=1.0),
|
77 |
+
loss_bbox=dict(type='SmoothL1Loss', beta=1.0,
|
78 |
+
loss_weight=1.0)),
|
79 |
+
dict(
|
80 |
+
type='Shared2FCBBoxHead',
|
81 |
+
in_channels=256,
|
82 |
+
fc_out_channels=1024,
|
83 |
+
roi_feat_size=7,
|
84 |
+
num_classes=80,
|
85 |
+
bbox_coder=dict(
|
86 |
+
type='DeltaXYWHBBoxCoder',
|
87 |
+
target_means=[0., 0., 0., 0.],
|
88 |
+
target_stds=[0.033, 0.033, 0.067, 0.067]),
|
89 |
+
reg_class_agnostic=True,
|
90 |
+
loss_cls=dict(
|
91 |
+
type='CrossEntropyLoss',
|
92 |
+
use_sigmoid=False,
|
93 |
+
loss_weight=1.0),
|
94 |
+
loss_bbox=dict(type='SmoothL1Loss', beta=1.0, loss_weight=1.0))
|
95 |
+
],
|
96 |
+
mask_roi_extractor=dict(
|
97 |
+
type='SingleRoIExtractor',
|
98 |
+
roi_layer=dict(type='RoIAlign', output_size=14, sampling_ratio=0),
|
99 |
+
out_channels=256,
|
100 |
+
featmap_strides=[4, 8, 16, 32]),
|
101 |
+
mask_head=dict(
|
102 |
+
type='FCNMaskHead',
|
103 |
+
num_convs=4,
|
104 |
+
in_channels=256,
|
105 |
+
conv_out_channels=256,
|
106 |
+
num_classes=80,
|
107 |
+
loss_mask=dict(
|
108 |
+
type='CrossEntropyLoss', use_mask=True, loss_weight=1.0))),
|
109 |
+
# model training and testing settings
|
110 |
+
train_cfg=dict(
|
111 |
+
rpn=dict(
|
112 |
+
assigner=dict(
|
113 |
+
type='MaxIoUAssigner',
|
114 |
+
pos_iou_thr=0.7,
|
115 |
+
neg_iou_thr=0.3,
|
116 |
+
min_pos_iou=0.3,
|
117 |
+
match_low_quality=True,
|
118 |
+
ignore_iof_thr=-1),
|
119 |
+
sampler=dict(
|
120 |
+
type='RandomSampler',
|
121 |
+
num=256,
|
122 |
+
pos_fraction=0.5,
|
123 |
+
neg_pos_ub=-1,
|
124 |
+
add_gt_as_proposals=False),
|
125 |
+
allowed_border=0,
|
126 |
+
pos_weight=-1,
|
127 |
+
debug=False),
|
128 |
+
rpn_proposal=dict(
|
129 |
+
nms_pre=2000,
|
130 |
+
max_per_img=2000,
|
131 |
+
nms=dict(type='nms', iou_threshold=0.7),
|
132 |
+
min_bbox_size=0),
|
133 |
+
rcnn=[
|
134 |
+
dict(
|
135 |
+
assigner=dict(
|
136 |
+
type='MaxIoUAssigner',
|
137 |
+
pos_iou_thr=0.5,
|
138 |
+
neg_iou_thr=0.5,
|
139 |
+
min_pos_iou=0.5,
|
140 |
+
match_low_quality=False,
|
141 |
+
ignore_iof_thr=-1),
|
142 |
+
sampler=dict(
|
143 |
+
type='RandomSampler',
|
144 |
+
num=512,
|
145 |
+
pos_fraction=0.25,
|
146 |
+
neg_pos_ub=-1,
|
147 |
+
add_gt_as_proposals=True),
|
148 |
+
mask_size=28,
|
149 |
+
pos_weight=-1,
|
150 |
+
debug=False),
|
151 |
+
dict(
|
152 |
+
assigner=dict(
|
153 |
+
type='MaxIoUAssigner',
|
154 |
+
pos_iou_thr=0.6,
|
155 |
+
neg_iou_thr=0.6,
|
156 |
+
min_pos_iou=0.6,
|
157 |
+
match_low_quality=False,
|
158 |
+
ignore_iof_thr=-1),
|
159 |
+
sampler=dict(
|
160 |
+
type='RandomSampler',
|
161 |
+
num=512,
|
162 |
+
pos_fraction=0.25,
|
163 |
+
neg_pos_ub=-1,
|
164 |
+
add_gt_as_proposals=True),
|
165 |
+
mask_size=28,
|
166 |
+
pos_weight=-1,
|
167 |
+
debug=False),
|
168 |
+
dict(
|
169 |
+
assigner=dict(
|
170 |
+
type='MaxIoUAssigner',
|
171 |
+
pos_iou_thr=0.7,
|
172 |
+
neg_iou_thr=0.7,
|
173 |
+
min_pos_iou=0.7,
|
174 |
+
match_low_quality=False,
|
175 |
+
ignore_iof_thr=-1),
|
176 |
+
sampler=dict(
|
177 |
+
type='RandomSampler',
|
178 |
+
num=512,
|
179 |
+
pos_fraction=0.25,
|
180 |
+
neg_pos_ub=-1,
|
181 |
+
add_gt_as_proposals=True),
|
182 |
+
mask_size=28,
|
183 |
+
pos_weight=-1,
|
184 |
+
debug=False)
|
185 |
+
]),
|
186 |
+
test_cfg=dict(
|
187 |
+
rpn=dict(
|
188 |
+
nms_pre=1000,
|
189 |
+
max_per_img=1000,
|
190 |
+
nms=dict(type='nms', iou_threshold=0.7),
|
191 |
+
min_bbox_size=0),
|
192 |
+
rcnn=dict(
|
193 |
+
score_thr=0.05,
|
194 |
+
nms=dict(type='nms', iou_threshold=0.5),
|
195 |
+
max_per_img=100,
|
196 |
+
mask_thr_binary=0.5)))
|
configs/_base_/models/cascade_mask_rcnn_swin_fpn.py
ADDED
@@ -0,0 +1,207 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# model settings
|
2 |
+
model = dict(
|
3 |
+
type='CascadeRCNN',
|
4 |
+
pretrained=None,
|
5 |
+
backbone=dict(
|
6 |
+
type='SwinTransformer',
|
7 |
+
embed_dim=96,
|
8 |
+
depths=[2, 2, 6, 2],
|
9 |
+
num_heads=[3, 6, 12, 24],
|
10 |
+
window_size=7,
|
11 |
+
mlp_ratio=4.,
|
12 |
+
qkv_bias=True,
|
13 |
+
qk_scale=None,
|
14 |
+
drop_rate=0.,
|
15 |
+
attn_drop_rate=0.,
|
16 |
+
drop_path_rate=0.2,
|
17 |
+
ape=False,
|
18 |
+
patch_norm=True,
|
19 |
+
out_indices=(0, 1, 2, 3),
|
20 |
+
use_checkpoint=False),
|
21 |
+
neck=dict(
|
22 |
+
type='FPN',
|
23 |
+
in_channels=[96, 192, 384, 768],
|
24 |
+
out_channels=256,
|
25 |
+
num_outs=5),
|
26 |
+
rpn_head=dict(
|
27 |
+
type='RPNHead',
|
28 |
+
in_channels=256,
|
29 |
+
feat_channels=256,
|
30 |
+
anchor_generator=dict(
|
31 |
+
type='AnchorGenerator',
|
32 |
+
scales=[8],
|
33 |
+
ratios=[0.5, 1.0, 2.0],
|
34 |
+
strides=[4, 8, 16, 32, 64]),
|
35 |
+
bbox_coder=dict(
|
36 |
+
type='DeltaXYWHBBoxCoder',
|
37 |
+
target_means=[.0, .0, .0, .0],
|
38 |
+
target_stds=[1.0, 1.0, 1.0, 1.0]),
|
39 |
+
loss_cls=dict(
|
40 |
+
type='CrossEntropyLoss', use_sigmoid=True, loss_weight=1.0),
|
41 |
+
loss_bbox=dict(type='SmoothL1Loss', beta=1.0 / 9.0, loss_weight=1.0)),
|
42 |
+
roi_head=dict(
|
43 |
+
type='CascadeRoIHead',
|
44 |
+
num_stages=3,
|
45 |
+
stage_loss_weights=[1, 0.5, 0.25],
|
46 |
+
bbox_roi_extractor=dict(
|
47 |
+
type='SingleRoIExtractor',
|
48 |
+
roi_layer=dict(type='RoIAlign', output_size=7, sampling_ratio=0),
|
49 |
+
out_channels=256,
|
50 |
+
featmap_strides=[4, 8, 16, 32]),
|
51 |
+
bbox_head=[
|
52 |
+
dict(
|
53 |
+
type='Shared2FCBBoxHead',
|
54 |
+
in_channels=256,
|
55 |
+
fc_out_channels=1024,
|
56 |
+
roi_feat_size=7,
|
57 |
+
num_classes=80,
|
58 |
+
bbox_coder=dict(
|
59 |
+
type='DeltaXYWHBBoxCoder',
|
60 |
+
target_means=[0., 0., 0., 0.],
|
61 |
+
target_stds=[0.1, 0.1, 0.2, 0.2]),
|
62 |
+
reg_class_agnostic=True,
|
63 |
+
loss_cls=dict(
|
64 |
+
type='CrossEntropyLoss',
|
65 |
+
use_sigmoid=False,
|
66 |
+
loss_weight=1.0),
|
67 |
+
loss_bbox=dict(type='SmoothL1Loss', beta=1.0,
|
68 |
+
loss_weight=1.0)),
|
69 |
+
dict(
|
70 |
+
type='Shared2FCBBoxHead',
|
71 |
+
in_channels=256,
|
72 |
+
fc_out_channels=1024,
|
73 |
+
roi_feat_size=7,
|
74 |
+
num_classes=80,
|
75 |
+
bbox_coder=dict(
|
76 |
+
type='DeltaXYWHBBoxCoder',
|
77 |
+
target_means=[0., 0., 0., 0.],
|
78 |
+
target_stds=[0.05, 0.05, 0.1, 0.1]),
|
79 |
+
reg_class_agnostic=True,
|
80 |
+
loss_cls=dict(
|
81 |
+
type='CrossEntropyLoss',
|
82 |
+
use_sigmoid=False,
|
83 |
+
loss_weight=1.0),
|
84 |
+
loss_bbox=dict(type='SmoothL1Loss', beta=1.0,
|
85 |
+
loss_weight=1.0)),
|
86 |
+
dict(
|
87 |
+
type='Shared2FCBBoxHead',
|
88 |
+
in_channels=256,
|
89 |
+
fc_out_channels=1024,
|
90 |
+
roi_feat_size=7,
|
91 |
+
num_classes=80,
|
92 |
+
bbox_coder=dict(
|
93 |
+
type='DeltaXYWHBBoxCoder',
|
94 |
+
target_means=[0., 0., 0., 0.],
|
95 |
+
target_stds=[0.033, 0.033, 0.067, 0.067]),
|
96 |
+
reg_class_agnostic=True,
|
97 |
+
loss_cls=dict(
|
98 |
+
type='CrossEntropyLoss',
|
99 |
+
use_sigmoid=False,
|
100 |
+
loss_weight=1.0),
|
101 |
+
loss_bbox=dict(type='SmoothL1Loss', beta=1.0, loss_weight=1.0))
|
102 |
+
],
|
103 |
+
mask_roi_extractor=dict(
|
104 |
+
type='SingleRoIExtractor',
|
105 |
+
roi_layer=dict(type='RoIAlign', output_size=14, sampling_ratio=0),
|
106 |
+
out_channels=256,
|
107 |
+
featmap_strides=[4, 8, 16, 32]),
|
108 |
+
mask_head=dict(
|
109 |
+
type='FCNMaskHead',
|
110 |
+
num_convs=4,
|
111 |
+
in_channels=256,
|
112 |
+
conv_out_channels=256,
|
113 |
+
num_classes=80,
|
114 |
+
loss_mask=dict(
|
115 |
+
type='CrossEntropyLoss', use_mask=True, loss_weight=1.0))),
|
116 |
+
# model training and testing settings
|
117 |
+
train_cfg = dict(
|
118 |
+
rpn=dict(
|
119 |
+
assigner=dict(
|
120 |
+
type='MaxIoUAssigner',
|
121 |
+
pos_iou_thr=0.7,
|
122 |
+
neg_iou_thr=0.3,
|
123 |
+
min_pos_iou=0.3,
|
124 |
+
match_low_quality=True,
|
125 |
+
ignore_iof_thr=-1),
|
126 |
+
sampler=dict(
|
127 |
+
type='RandomSampler',
|
128 |
+
num=256,
|
129 |
+
pos_fraction=0.5,
|
130 |
+
neg_pos_ub=-1,
|
131 |
+
add_gt_as_proposals=False),
|
132 |
+
allowed_border=0,
|
133 |
+
pos_weight=-1,
|
134 |
+
debug=False),
|
135 |
+
rpn_proposal=dict(
|
136 |
+
nms_across_levels=False,
|
137 |
+
nms_pre=2000,
|
138 |
+
nms_post=2000,
|
139 |
+
max_per_img=2000,
|
140 |
+
nms=dict(type='nms', iou_threshold=0.7),
|
141 |
+
min_bbox_size=0),
|
142 |
+
rcnn=[
|
143 |
+
dict(
|
144 |
+
assigner=dict(
|
145 |
+
type='MaxIoUAssigner',
|
146 |
+
pos_iou_thr=0.5,
|
147 |
+
neg_iou_thr=0.5,
|
148 |
+
min_pos_iou=0.5,
|
149 |
+
match_low_quality=False,
|
150 |
+
ignore_iof_thr=-1),
|
151 |
+
sampler=dict(
|
152 |
+
type='RandomSampler',
|
153 |
+
num=512,
|
154 |
+
pos_fraction=0.25,
|
155 |
+
neg_pos_ub=-1,
|
156 |
+
add_gt_as_proposals=True),
|
157 |
+
mask_size=28,
|
158 |
+
pos_weight=-1,
|
159 |
+
debug=False),
|
160 |
+
dict(
|
161 |
+
assigner=dict(
|
162 |
+
type='MaxIoUAssigner',
|
163 |
+
pos_iou_thr=0.6,
|
164 |
+
neg_iou_thr=0.6,
|
165 |
+
min_pos_iou=0.6,
|
166 |
+
match_low_quality=False,
|
167 |
+
ignore_iof_thr=-1),
|
168 |
+
sampler=dict(
|
169 |
+
type='RandomSampler',
|
170 |
+
num=512,
|
171 |
+
pos_fraction=0.25,
|
172 |
+
neg_pos_ub=-1,
|
173 |
+
add_gt_as_proposals=True),
|
174 |
+
mask_size=28,
|
175 |
+
pos_weight=-1,
|
176 |
+
debug=False),
|
177 |
+
dict(
|
178 |
+
assigner=dict(
|
179 |
+
type='MaxIoUAssigner',
|
180 |
+
pos_iou_thr=0.7,
|
181 |
+
neg_iou_thr=0.7,
|
182 |
+
min_pos_iou=0.7,
|
183 |
+
match_low_quality=False,
|
184 |
+
ignore_iof_thr=-1),
|
185 |
+
sampler=dict(
|
186 |
+
type='RandomSampler',
|
187 |
+
num=512,
|
188 |
+
pos_fraction=0.25,
|
189 |
+
neg_pos_ub=-1,
|
190 |
+
add_gt_as_proposals=True),
|
191 |
+
mask_size=28,
|
192 |
+
pos_weight=-1,
|
193 |
+
debug=False)
|
194 |
+
]),
|
195 |
+
test_cfg = dict(
|
196 |
+
rpn=dict(
|
197 |
+
nms_across_levels=False,
|
198 |
+
nms_pre=1000,
|
199 |
+
nms_post=1000,
|
200 |
+
max_per_img=1000,
|
201 |
+
nms=dict(type='nms', iou_threshold=0.7),
|
202 |
+
min_bbox_size=0),
|
203 |
+
rcnn=dict(
|
204 |
+
score_thr=0.05,
|
205 |
+
nms=dict(type='nms', iou_threshold=0.5),
|
206 |
+
max_per_img=100,
|
207 |
+
mask_thr_binary=0.5)))
|
configs/_base_/models/cascade_rcnn_r50_fpn.py
ADDED
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# model settings
|
2 |
+
model = dict(
|
3 |
+
type='CascadeRCNN',
|
4 |
+
pretrained='torchvision://resnet50',
|
5 |
+
backbone=dict(
|
6 |
+
type='ResNet',
|
7 |
+
depth=50,
|
8 |
+
num_stages=4,
|
9 |
+
out_indices=(0, 1, 2, 3),
|
10 |
+
frozen_stages=1,
|
11 |
+
norm_cfg=dict(type='BN', requires_grad=True),
|
12 |
+
norm_eval=True,
|
13 |
+
style='pytorch'),
|
14 |
+
neck=dict(
|
15 |
+
type='FPN',
|
16 |
+
in_channels=[256, 512, 1024, 2048],
|
17 |
+
out_channels=256,
|
18 |
+
num_outs=5),
|
19 |
+
rpn_head=dict(
|
20 |
+
type='RPNHead',
|
21 |
+
in_channels=256,
|
22 |
+
feat_channels=256,
|
23 |
+
anchor_generator=dict(
|
24 |
+
type='AnchorGenerator',
|
25 |
+
scales=[8],
|
26 |
+
ratios=[0.5, 1.0, 2.0],
|
27 |
+
strides=[4, 8, 16, 32, 64]),
|
28 |
+
bbox_coder=dict(
|
29 |
+
type='DeltaXYWHBBoxCoder',
|
30 |
+
target_means=[.0, .0, .0, .0],
|
31 |
+
target_stds=[1.0, 1.0, 1.0, 1.0]),
|
32 |
+
loss_cls=dict(
|
33 |
+
type='CrossEntropyLoss', use_sigmoid=True, loss_weight=1.0),
|
34 |
+
loss_bbox=dict(type='SmoothL1Loss', beta=1.0 / 9.0, loss_weight=1.0)),
|
35 |
+
roi_head=dict(
|
36 |
+
type='CascadeRoIHead',
|
37 |
+
num_stages=3,
|
38 |
+
stage_loss_weights=[1, 0.5, 0.25],
|
39 |
+
bbox_roi_extractor=dict(
|
40 |
+
type='SingleRoIExtractor',
|
41 |
+
roi_layer=dict(type='RoIAlign', output_size=7, sampling_ratio=0),
|
42 |
+
out_channels=256,
|
43 |
+
featmap_strides=[4, 8, 16, 32]),
|
44 |
+
bbox_head=[
|
45 |
+
dict(
|
46 |
+
type='Shared2FCBBoxHead',
|
47 |
+
in_channels=256,
|
48 |
+
fc_out_channels=1024,
|
49 |
+
roi_feat_size=7,
|
50 |
+
num_classes=80,
|
51 |
+
bbox_coder=dict(
|
52 |
+
type='DeltaXYWHBBoxCoder',
|
53 |
+
target_means=[0., 0., 0., 0.],
|
54 |
+
target_stds=[0.1, 0.1, 0.2, 0.2]),
|
55 |
+
reg_class_agnostic=True,
|
56 |
+
loss_cls=dict(
|
57 |
+
type='CrossEntropyLoss',
|
58 |
+
use_sigmoid=False,
|
59 |
+
loss_weight=1.0),
|
60 |
+
loss_bbox=dict(type='SmoothL1Loss', beta=1.0,
|
61 |
+
loss_weight=1.0)),
|
62 |
+
dict(
|
63 |
+
type='Shared2FCBBoxHead',
|
64 |
+
in_channels=256,
|
65 |
+
fc_out_channels=1024,
|
66 |
+
roi_feat_size=7,
|
67 |
+
num_classes=80,
|
68 |
+
bbox_coder=dict(
|
69 |
+
type='DeltaXYWHBBoxCoder',
|
70 |
+
target_means=[0., 0., 0., 0.],
|
71 |
+
target_stds=[0.05, 0.05, 0.1, 0.1]),
|
72 |
+
reg_class_agnostic=True,
|
73 |
+
loss_cls=dict(
|
74 |
+
type='CrossEntropyLoss',
|
75 |
+
use_sigmoid=False,
|
76 |
+
loss_weight=1.0),
|
77 |
+
loss_bbox=dict(type='SmoothL1Loss', beta=1.0,
|
78 |
+
loss_weight=1.0)),
|
79 |
+
dict(
|
80 |
+
type='Shared2FCBBoxHead',
|
81 |
+
in_channels=256,
|
82 |
+
fc_out_channels=1024,
|
83 |
+
roi_feat_size=7,
|
84 |
+
num_classes=80,
|
85 |
+
bbox_coder=dict(
|
86 |
+
type='DeltaXYWHBBoxCoder',
|
87 |
+
target_means=[0., 0., 0., 0.],
|
88 |
+
target_stds=[0.033, 0.033, 0.067, 0.067]),
|
89 |
+
reg_class_agnostic=True,
|
90 |
+
loss_cls=dict(
|
91 |
+
type='CrossEntropyLoss',
|
92 |
+
use_sigmoid=False,
|
93 |
+
loss_weight=1.0),
|
94 |
+
loss_bbox=dict(type='SmoothL1Loss', beta=1.0, loss_weight=1.0))
|
95 |
+
]),
|
96 |
+
# model training and testing settings
|
97 |
+
train_cfg=dict(
|
98 |
+
rpn=dict(
|
99 |
+
assigner=dict(
|
100 |
+
type='MaxIoUAssigner',
|
101 |
+
pos_iou_thr=0.7,
|
102 |
+
neg_iou_thr=0.3,
|
103 |
+
min_pos_iou=0.3,
|
104 |
+
match_low_quality=True,
|
105 |
+
ignore_iof_thr=-1),
|
106 |
+
sampler=dict(
|
107 |
+
type='RandomSampler',
|
108 |
+
num=256,
|
109 |
+
pos_fraction=0.5,
|
110 |
+
neg_pos_ub=-1,
|
111 |
+
add_gt_as_proposals=False),
|
112 |
+
allowed_border=0,
|
113 |
+
pos_weight=-1,
|
114 |
+
debug=False),
|
115 |
+
rpn_proposal=dict(
|
116 |
+
nms_pre=2000,
|
117 |
+
max_per_img=2000,
|
118 |
+
nms=dict(type='nms', iou_threshold=0.7),
|
119 |
+
min_bbox_size=0),
|
120 |
+
rcnn=[
|
121 |
+
dict(
|
122 |
+
assigner=dict(
|
123 |
+
type='MaxIoUAssigner',
|
124 |
+
pos_iou_thr=0.5,
|
125 |
+
neg_iou_thr=0.5,
|
126 |
+
min_pos_iou=0.5,
|
127 |
+
match_low_quality=False,
|
128 |
+
ignore_iof_thr=-1),
|
129 |
+
sampler=dict(
|
130 |
+
type='RandomSampler',
|
131 |
+
num=512,
|
132 |
+
pos_fraction=0.25,
|
133 |
+
neg_pos_ub=-1,
|
134 |
+
add_gt_as_proposals=True),
|
135 |
+
pos_weight=-1,
|
136 |
+
debug=False),
|
137 |
+
dict(
|
138 |
+
assigner=dict(
|
139 |
+
type='MaxIoUAssigner',
|
140 |
+
pos_iou_thr=0.6,
|
141 |
+
neg_iou_thr=0.6,
|
142 |
+
min_pos_iou=0.6,
|
143 |
+
match_low_quality=False,
|
144 |
+
ignore_iof_thr=-1),
|
145 |
+
sampler=dict(
|
146 |
+
type='RandomSampler',
|
147 |
+
num=512,
|
148 |
+
pos_fraction=0.25,
|
149 |
+
neg_pos_ub=-1,
|
150 |
+
add_gt_as_proposals=True),
|
151 |
+
pos_weight=-1,
|
152 |
+
debug=False),
|
153 |
+
dict(
|
154 |
+
assigner=dict(
|
155 |
+
type='MaxIoUAssigner',
|
156 |
+
pos_iou_thr=0.7,
|
157 |
+
neg_iou_thr=0.7,
|
158 |
+
min_pos_iou=0.7,
|
159 |
+
match_low_quality=False,
|
160 |
+
ignore_iof_thr=-1),
|
161 |
+
sampler=dict(
|
162 |
+
type='RandomSampler',
|
163 |
+
num=512,
|
164 |
+
pos_fraction=0.25,
|
165 |
+
neg_pos_ub=-1,
|
166 |
+
add_gt_as_proposals=True),
|
167 |
+
pos_weight=-1,
|
168 |
+
debug=False)
|
169 |
+
]),
|
170 |
+
test_cfg=dict(
|
171 |
+
rpn=dict(
|
172 |
+
nms_pre=1000,
|
173 |
+
max_per_img=1000,
|
174 |
+
nms=dict(type='nms', iou_threshold=0.7),
|
175 |
+
min_bbox_size=0),
|
176 |
+
rcnn=dict(
|
177 |
+
score_thr=0.05,
|
178 |
+
nms=dict(type='nms', iou_threshold=0.5),
|
179 |
+
max_per_img=100)))
|
configs/_base_/models/fast_rcnn_r50_fpn.py
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# model settings
|
2 |
+
model = dict(
|
3 |
+
type='FastRCNN',
|
4 |
+
pretrained='torchvision://resnet50',
|
5 |
+
backbone=dict(
|
6 |
+
type='ResNet',
|
7 |
+
depth=50,
|
8 |
+
num_stages=4,
|
9 |
+
out_indices=(0, 1, 2, 3),
|
10 |
+
frozen_stages=1,
|
11 |
+
norm_cfg=dict(type='BN', requires_grad=True),
|
12 |
+
norm_eval=True,
|
13 |
+
style='pytorch'),
|
14 |
+
neck=dict(
|
15 |
+
type='FPN',
|
16 |
+
in_channels=[256, 512, 1024, 2048],
|
17 |
+
out_channels=256,
|
18 |
+
num_outs=5),
|
19 |
+
roi_head=dict(
|
20 |
+
type='StandardRoIHead',
|
21 |
+
bbox_roi_extractor=dict(
|
22 |
+
type='SingleRoIExtractor',
|
23 |
+
roi_layer=dict(type='RoIAlign', output_size=7, sampling_ratio=0),
|
24 |
+
out_channels=256,
|
25 |
+
featmap_strides=[4, 8, 16, 32]),
|
26 |
+
bbox_head=dict(
|
27 |
+
type='Shared2FCBBoxHead',
|
28 |
+
in_channels=256,
|
29 |
+
fc_out_channels=1024,
|
30 |
+
roi_feat_size=7,
|
31 |
+
num_classes=80,
|
32 |
+
bbox_coder=dict(
|
33 |
+
type='DeltaXYWHBBoxCoder',
|
34 |
+
target_means=[0., 0., 0., 0.],
|
35 |
+
target_stds=[0.1, 0.1, 0.2, 0.2]),
|
36 |
+
reg_class_agnostic=False,
|
37 |
+
loss_cls=dict(
|
38 |
+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0),
|
39 |
+
loss_bbox=dict(type='L1Loss', loss_weight=1.0))),
|
40 |
+
# model training and testing settings
|
41 |
+
train_cfg=dict(
|
42 |
+
rcnn=dict(
|
43 |
+
assigner=dict(
|
44 |
+
type='MaxIoUAssigner',
|
45 |
+
pos_iou_thr=0.5,
|
46 |
+
neg_iou_thr=0.5,
|
47 |
+
min_pos_iou=0.5,
|
48 |
+
match_low_quality=False,
|
49 |
+
ignore_iof_thr=-1),
|
50 |
+
sampler=dict(
|
51 |
+
type='RandomSampler',
|
52 |
+
num=512,
|
53 |
+
pos_fraction=0.25,
|
54 |
+
neg_pos_ub=-1,
|
55 |
+
add_gt_as_proposals=True),
|
56 |
+
pos_weight=-1,
|
57 |
+
debug=False)),
|
58 |
+
test_cfg=dict(
|
59 |
+
rcnn=dict(
|
60 |
+
score_thr=0.05,
|
61 |
+
nms=dict(type='nms', iou_threshold=0.5),
|
62 |
+
max_per_img=100)))
|
configs/_base_/models/faster_rcnn_r50_caffe_c4.py
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# model settings
|
2 |
+
norm_cfg = dict(type='BN', requires_grad=False)
|
3 |
+
model = dict(
|
4 |
+
type='FasterRCNN',
|
5 |
+
pretrained='open-mmlab://detectron2/resnet50_caffe',
|
6 |
+
backbone=dict(
|
7 |
+
type='ResNet',
|
8 |
+
depth=50,
|
9 |
+
num_stages=3,
|
10 |
+
strides=(1, 2, 2),
|
11 |
+
dilations=(1, 1, 1),
|
12 |
+
out_indices=(2, ),
|
13 |
+
frozen_stages=1,
|
14 |
+
norm_cfg=norm_cfg,
|
15 |
+
norm_eval=True,
|
16 |
+
style='caffe'),
|
17 |
+
rpn_head=dict(
|
18 |
+
type='RPNHead',
|
19 |
+
in_channels=1024,
|
20 |
+
feat_channels=1024,
|
21 |
+
anchor_generator=dict(
|
22 |
+
type='AnchorGenerator',
|
23 |
+
scales=[2, 4, 8, 16, 32],
|
24 |
+
ratios=[0.5, 1.0, 2.0],
|
25 |
+
strides=[16]),
|
26 |
+
bbox_coder=dict(
|
27 |
+
type='DeltaXYWHBBoxCoder',
|
28 |
+
target_means=[.0, .0, .0, .0],
|
29 |
+
target_stds=[1.0, 1.0, 1.0, 1.0]),
|
30 |
+
loss_cls=dict(
|
31 |
+
type='CrossEntropyLoss', use_sigmoid=True, loss_weight=1.0),
|
32 |
+
loss_bbox=dict(type='L1Loss', loss_weight=1.0)),
|
33 |
+
roi_head=dict(
|
34 |
+
type='StandardRoIHead',
|
35 |
+
shared_head=dict(
|
36 |
+
type='ResLayer',
|
37 |
+
depth=50,
|
38 |
+
stage=3,
|
39 |
+
stride=2,
|
40 |
+
dilation=1,
|
41 |
+
style='caffe',
|
42 |
+
norm_cfg=norm_cfg,
|
43 |
+
norm_eval=True),
|
44 |
+
bbox_roi_extractor=dict(
|
45 |
+
type='SingleRoIExtractor',
|
46 |
+
roi_layer=dict(type='RoIAlign', output_size=14, sampling_ratio=0),
|
47 |
+
out_channels=1024,
|
48 |
+
featmap_strides=[16]),
|
49 |
+
bbox_head=dict(
|
50 |
+
type='BBoxHead',
|
51 |
+
with_avg_pool=True,
|
52 |
+
roi_feat_size=7,
|
53 |
+
in_channels=2048,
|
54 |
+
num_classes=80,
|
55 |
+
bbox_coder=dict(
|
56 |
+
type='DeltaXYWHBBoxCoder',
|
57 |
+
target_means=[0., 0., 0., 0.],
|
58 |
+
target_stds=[0.1, 0.1, 0.2, 0.2]),
|
59 |
+
reg_class_agnostic=False,
|
60 |
+
loss_cls=dict(
|
61 |
+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0),
|
62 |
+
loss_bbox=dict(type='L1Loss', loss_weight=1.0))),
|
63 |
+
# model training and testing settings
|
64 |
+
train_cfg=dict(
|
65 |
+
rpn=dict(
|
66 |
+
assigner=dict(
|
67 |
+
type='MaxIoUAssigner',
|
68 |
+
pos_iou_thr=0.7,
|
69 |
+
neg_iou_thr=0.3,
|
70 |
+
min_pos_iou=0.3,
|
71 |
+
match_low_quality=True,
|
72 |
+
ignore_iof_thr=-1),
|
73 |
+
sampler=dict(
|
74 |
+
type='RandomSampler',
|
75 |
+
num=256,
|
76 |
+
pos_fraction=0.5,
|
77 |
+
neg_pos_ub=-1,
|
78 |
+
add_gt_as_proposals=False),
|
79 |
+
allowed_border=0,
|
80 |
+
pos_weight=-1,
|
81 |
+
debug=False),
|
82 |
+
rpn_proposal=dict(
|
83 |
+
nms_pre=12000,
|
84 |
+
max_per_img=2000,
|
85 |
+
nms=dict(type='nms', iou_threshold=0.7),
|
86 |
+
min_bbox_size=0),
|
87 |
+
rcnn=dict(
|
88 |
+
assigner=dict(
|
89 |
+
type='MaxIoUAssigner',
|
90 |
+
pos_iou_thr=0.5,
|
91 |
+
neg_iou_thr=0.5,
|
92 |
+
min_pos_iou=0.5,
|
93 |
+
match_low_quality=False,
|
94 |
+
ignore_iof_thr=-1),
|
95 |
+
sampler=dict(
|
96 |
+
type='RandomSampler',
|
97 |
+
num=512,
|
98 |
+
pos_fraction=0.25,
|
99 |
+
neg_pos_ub=-1,
|
100 |
+
add_gt_as_proposals=True),
|
101 |
+
pos_weight=-1,
|
102 |
+
debug=False)),
|
103 |
+
test_cfg=dict(
|
104 |
+
rpn=dict(
|
105 |
+
nms_pre=6000,
|
106 |
+
max_per_img=1000,
|
107 |
+
nms=dict(type='nms', iou_threshold=0.7),
|
108 |
+
min_bbox_size=0),
|
109 |
+
rcnn=dict(
|
110 |
+
score_thr=0.05,
|
111 |
+
nms=dict(type='nms', iou_threshold=0.5),
|
112 |
+
max_per_img=100)))
|
configs/_base_/models/faster_rcnn_r50_caffe_dc5.py
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# model settings
|
2 |
+
norm_cfg = dict(type='BN', requires_grad=False)
|
3 |
+
model = dict(
|
4 |
+
type='FasterRCNN',
|
5 |
+
pretrained='open-mmlab://detectron2/resnet50_caffe',
|
6 |
+
backbone=dict(
|
7 |
+
type='ResNet',
|
8 |
+
depth=50,
|
9 |
+
num_stages=4,
|
10 |
+
strides=(1, 2, 2, 1),
|
11 |
+
dilations=(1, 1, 1, 2),
|
12 |
+
out_indices=(3, ),
|
13 |
+
frozen_stages=1,
|
14 |
+
norm_cfg=norm_cfg,
|
15 |
+
norm_eval=True,
|
16 |
+
style='caffe'),
|
17 |
+
rpn_head=dict(
|
18 |
+
type='RPNHead',
|
19 |
+
in_channels=2048,
|
20 |
+
feat_channels=2048,
|
21 |
+
anchor_generator=dict(
|
22 |
+
type='AnchorGenerator',
|
23 |
+
scales=[2, 4, 8, 16, 32],
|
24 |
+
ratios=[0.5, 1.0, 2.0],
|
25 |
+
strides=[16]),
|
26 |
+
bbox_coder=dict(
|
27 |
+
type='DeltaXYWHBBoxCoder',
|
28 |
+
target_means=[.0, .0, .0, .0],
|
29 |
+
target_stds=[1.0, 1.0, 1.0, 1.0]),
|
30 |
+
loss_cls=dict(
|
31 |
+
type='CrossEntropyLoss', use_sigmoid=True, loss_weight=1.0),
|
32 |
+
loss_bbox=dict(type='L1Loss', loss_weight=1.0)),
|
33 |
+
roi_head=dict(
|
34 |
+
type='StandardRoIHead',
|
35 |
+
bbox_roi_extractor=dict(
|
36 |
+
type='SingleRoIExtractor',
|
37 |
+
roi_layer=dict(type='RoIAlign', output_size=7, sampling_ratio=0),
|
38 |
+
out_channels=2048,
|
39 |
+
featmap_strides=[16]),
|
40 |
+
bbox_head=dict(
|
41 |
+
type='Shared2FCBBoxHead',
|
42 |
+
in_channels=2048,
|
43 |
+
fc_out_channels=1024,
|
44 |
+
roi_feat_size=7,
|
45 |
+
num_classes=80,
|
46 |
+
bbox_coder=dict(
|
47 |
+
type='DeltaXYWHBBoxCoder',
|
48 |
+
target_means=[0., 0., 0., 0.],
|
49 |
+
target_stds=[0.1, 0.1, 0.2, 0.2]),
|
50 |
+
reg_class_agnostic=False,
|
51 |
+
loss_cls=dict(
|
52 |
+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0),
|
53 |
+
loss_bbox=dict(type='L1Loss', loss_weight=1.0))),
|
54 |
+
# model training and testing settings
|
55 |
+
train_cfg=dict(
|
56 |
+
rpn=dict(
|
57 |
+
assigner=dict(
|
58 |
+
type='MaxIoUAssigner',
|
59 |
+
pos_iou_thr=0.7,
|
60 |
+
neg_iou_thr=0.3,
|
61 |
+
min_pos_iou=0.3,
|
62 |
+
match_low_quality=True,
|
63 |
+
ignore_iof_thr=-1),
|
64 |
+
sampler=dict(
|
65 |
+
type='RandomSampler',
|
66 |
+
num=256,
|
67 |
+
pos_fraction=0.5,
|
68 |
+
neg_pos_ub=-1,
|
69 |
+
add_gt_as_proposals=False),
|
70 |
+
allowed_border=0,
|
71 |
+
pos_weight=-1,
|
72 |
+
debug=False),
|
73 |
+
rpn_proposal=dict(
|
74 |
+
nms_pre=12000,
|
75 |
+
max_per_img=2000,
|
76 |
+
nms=dict(type='nms', iou_threshold=0.7),
|
77 |
+
min_bbox_size=0),
|
78 |
+
rcnn=dict(
|
79 |
+
assigner=dict(
|
80 |
+
type='MaxIoUAssigner',
|
81 |
+
pos_iou_thr=0.5,
|
82 |
+
neg_iou_thr=0.5,
|
83 |
+
min_pos_iou=0.5,
|
84 |
+
match_low_quality=False,
|
85 |
+
ignore_iof_thr=-1),
|
86 |
+
sampler=dict(
|
87 |
+
type='RandomSampler',
|
88 |
+
num=512,
|
89 |
+
pos_fraction=0.25,
|
90 |
+
neg_pos_ub=-1,
|
91 |
+
add_gt_as_proposals=True),
|
92 |
+
pos_weight=-1,
|
93 |
+
debug=False)),
|
94 |
+
test_cfg=dict(
|
95 |
+
rpn=dict(
|
96 |
+
nms=dict(type='nms', iou_threshold=0.7),
|
97 |
+
nms_pre=6000,
|
98 |
+
max_per_img=1000,
|
99 |
+
min_bbox_size=0),
|
100 |
+
rcnn=dict(
|
101 |
+
score_thr=0.05,
|
102 |
+
nms=dict(type='nms', iou_threshold=0.5),
|
103 |
+
max_per_img=100)))
|
configs/_base_/models/faster_rcnn_r50_fpn.py
ADDED
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
model = dict(
|
2 |
+
type='FasterRCNN',
|
3 |
+
pretrained='torchvision://resnet50',
|
4 |
+
backbone=dict(
|
5 |
+
type='ResNet',
|
6 |
+
depth=50,
|
7 |
+
num_stages=4,
|
8 |
+
out_indices=(0, 1, 2, 3),
|
9 |
+
frozen_stages=1,
|
10 |
+
norm_cfg=dict(type='BN', requires_grad=True),
|
11 |
+
norm_eval=True,
|
12 |
+
style='pytorch'),
|
13 |
+
neck=dict(
|
14 |
+
type='FPN',
|
15 |
+
in_channels=[256, 512, 1024, 2048],
|
16 |
+
out_channels=256,
|
17 |
+
num_outs=5),
|
18 |
+
rpn_head=dict(
|
19 |
+
type='RPNHead',
|
20 |
+
in_channels=256,
|
21 |
+
feat_channels=256,
|
22 |
+
anchor_generator=dict(
|
23 |
+
type='AnchorGenerator',
|
24 |
+
scales=[8],
|
25 |
+
ratios=[0.5, 1.0, 2.0],
|
26 |
+
strides=[4, 8, 16, 32, 64]),
|
27 |
+
bbox_coder=dict(
|
28 |
+
type='DeltaXYWHBBoxCoder',
|
29 |
+
target_means=[.0, .0, .0, .0],
|
30 |
+
target_stds=[1.0, 1.0, 1.0, 1.0]),
|
31 |
+
loss_cls=dict(
|
32 |
+
type='CrossEntropyLoss', use_sigmoid=True, loss_weight=1.0),
|
33 |
+
loss_bbox=dict(type='L1Loss', loss_weight=1.0)),
|
34 |
+
roi_head=dict(
|
35 |
+
type='StandardRoIHead',
|
36 |
+
bbox_roi_extractor=dict(
|
37 |
+
type='SingleRoIExtractor',
|
38 |
+
roi_layer=dict(type='RoIAlign', output_size=7, sampling_ratio=0),
|
39 |
+
out_channels=256,
|
40 |
+
featmap_strides=[4, 8, 16, 32]),
|
41 |
+
bbox_head=dict(
|
42 |
+
type='Shared2FCBBoxHead',
|
43 |
+
in_channels=256,
|
44 |
+
fc_out_channels=1024,
|
45 |
+
roi_feat_size=7,
|
46 |
+
num_classes=80,
|
47 |
+
bbox_coder=dict(
|
48 |
+
type='DeltaXYWHBBoxCoder',
|
49 |
+
target_means=[0., 0., 0., 0.],
|
50 |
+
target_stds=[0.1, 0.1, 0.2, 0.2]),
|
51 |
+
reg_class_agnostic=False,
|
52 |
+
loss_cls=dict(
|
53 |
+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0),
|
54 |
+
loss_bbox=dict(type='L1Loss', loss_weight=1.0))),
|
55 |
+
# model training and testing settings
|
56 |
+
train_cfg=dict(
|
57 |
+
rpn=dict(
|
58 |
+
assigner=dict(
|
59 |
+
type='MaxIoUAssigner',
|
60 |
+
pos_iou_thr=0.7,
|
61 |
+
neg_iou_thr=0.3,
|
62 |
+
min_pos_iou=0.3,
|
63 |
+
match_low_quality=True,
|
64 |
+
ignore_iof_thr=-1),
|
65 |
+
sampler=dict(
|
66 |
+
type='RandomSampler',
|
67 |
+
num=256,
|
68 |
+
pos_fraction=0.5,
|
69 |
+
neg_pos_ub=-1,
|
70 |
+
add_gt_as_proposals=False),
|
71 |
+
allowed_border=-1,
|
72 |
+
pos_weight=-1,
|
73 |
+
debug=False),
|
74 |
+
rpn_proposal=dict(
|
75 |
+
nms_pre=2000,
|
76 |
+
max_per_img=1000,
|
77 |
+
nms=dict(type='nms', iou_threshold=0.7),
|
78 |
+
min_bbox_size=0),
|
79 |
+
rcnn=dict(
|
80 |
+
assigner=dict(
|
81 |
+
type='MaxIoUAssigner',
|
82 |
+
pos_iou_thr=0.5,
|
83 |
+
neg_iou_thr=0.5,
|
84 |
+
min_pos_iou=0.5,
|
85 |
+
match_low_quality=False,
|
86 |
+
ignore_iof_thr=-1),
|
87 |
+
sampler=dict(
|
88 |
+
type='RandomSampler',
|
89 |
+
num=512,
|
90 |
+
pos_fraction=0.25,
|
91 |
+
neg_pos_ub=-1,
|
92 |
+
add_gt_as_proposals=True),
|
93 |
+
pos_weight=-1,
|
94 |
+
debug=False)),
|
95 |
+
test_cfg=dict(
|
96 |
+
rpn=dict(
|
97 |
+
nms_pre=1000,
|
98 |
+
max_per_img=1000,
|
99 |
+
nms=dict(type='nms', iou_threshold=0.7),
|
100 |
+
min_bbox_size=0),
|
101 |
+
rcnn=dict(
|
102 |
+
score_thr=0.05,
|
103 |
+
nms=dict(type='nms', iou_threshold=0.5),
|
104 |
+
max_per_img=100)
|
105 |
+
# soft-nms is also supported for rcnn testing
|
106 |
+
# e.g., nms=dict(type='soft_nms', iou_threshold=0.5, min_score=0.05)
|
107 |
+
))
|
configs/_base_/models/mask_rcnn_r50_caffe_c4.py
ADDED
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# model settings
|
2 |
+
norm_cfg = dict(type='BN', requires_grad=False)
|
3 |
+
model = dict(
|
4 |
+
type='MaskRCNN',
|
5 |
+
pretrained='open-mmlab://detectron2/resnet50_caffe',
|
6 |
+
backbone=dict(
|
7 |
+
type='ResNet',
|
8 |
+
depth=50,
|
9 |
+
num_stages=3,
|
10 |
+
strides=(1, 2, 2),
|
11 |
+
dilations=(1, 1, 1),
|
12 |
+
out_indices=(2, ),
|
13 |
+
frozen_stages=1,
|
14 |
+
norm_cfg=norm_cfg,
|
15 |
+
norm_eval=True,
|
16 |
+
style='caffe'),
|
17 |
+
rpn_head=dict(
|
18 |
+
type='RPNHead',
|
19 |
+
in_channels=1024,
|
20 |
+
feat_channels=1024,
|
21 |
+
anchor_generator=dict(
|
22 |
+
type='AnchorGenerator',
|
23 |
+
scales=[2, 4, 8, 16, 32],
|
24 |
+
ratios=[0.5, 1.0, 2.0],
|
25 |
+
strides=[16]),
|
26 |
+
bbox_coder=dict(
|
27 |
+
type='DeltaXYWHBBoxCoder',
|
28 |
+
target_means=[.0, .0, .0, .0],
|
29 |
+
target_stds=[1.0, 1.0, 1.0, 1.0]),
|
30 |
+
loss_cls=dict(
|
31 |
+
type='CrossEntropyLoss', use_sigmoid=True, loss_weight=1.0),
|
32 |
+
loss_bbox=dict(type='L1Loss', loss_weight=1.0)),
|
33 |
+
roi_head=dict(
|
34 |
+
type='StandardRoIHead',
|
35 |
+
shared_head=dict(
|
36 |
+
type='ResLayer',
|
37 |
+
depth=50,
|
38 |
+
stage=3,
|
39 |
+
stride=2,
|
40 |
+
dilation=1,
|
41 |
+
style='caffe',
|
42 |
+
norm_cfg=norm_cfg,
|
43 |
+
norm_eval=True),
|
44 |
+
bbox_roi_extractor=dict(
|
45 |
+
type='SingleRoIExtractor',
|
46 |
+
roi_layer=dict(type='RoIAlign', output_size=14, sampling_ratio=0),
|
47 |
+
out_channels=1024,
|
48 |
+
featmap_strides=[16]),
|
49 |
+
bbox_head=dict(
|
50 |
+
type='BBoxHead',
|
51 |
+
with_avg_pool=True,
|
52 |
+
roi_feat_size=7,
|
53 |
+
in_channels=2048,
|
54 |
+
num_classes=80,
|
55 |
+
bbox_coder=dict(
|
56 |
+
type='DeltaXYWHBBoxCoder',
|
57 |
+
target_means=[0., 0., 0., 0.],
|
58 |
+
target_stds=[0.1, 0.1, 0.2, 0.2]),
|
59 |
+
reg_class_agnostic=False,
|
60 |
+
loss_cls=dict(
|
61 |
+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0),
|
62 |
+
loss_bbox=dict(type='L1Loss', loss_weight=1.0)),
|
63 |
+
mask_roi_extractor=None,
|
64 |
+
mask_head=dict(
|
65 |
+
type='FCNMaskHead',
|
66 |
+
num_convs=0,
|
67 |
+
in_channels=2048,
|
68 |
+
conv_out_channels=256,
|
69 |
+
num_classes=80,
|
70 |
+
loss_mask=dict(
|
71 |
+
type='CrossEntropyLoss', use_mask=True, loss_weight=1.0))),
|
72 |
+
# model training and testing settings
|
73 |
+
train_cfg=dict(
|
74 |
+
rpn=dict(
|
75 |
+
assigner=dict(
|
76 |
+
type='MaxIoUAssigner',
|
77 |
+
pos_iou_thr=0.7,
|
78 |
+
neg_iou_thr=0.3,
|
79 |
+
min_pos_iou=0.3,
|
80 |
+
match_low_quality=True,
|
81 |
+
ignore_iof_thr=-1),
|
82 |
+
sampler=dict(
|
83 |
+
type='RandomSampler',
|
84 |
+
num=256,
|
85 |
+
pos_fraction=0.5,
|
86 |
+
neg_pos_ub=-1,
|
87 |
+
add_gt_as_proposals=False),
|
88 |
+
allowed_border=0,
|
89 |
+
pos_weight=-1,
|
90 |
+
debug=False),
|
91 |
+
rpn_proposal=dict(
|
92 |
+
nms_pre=12000,
|
93 |
+
max_per_img=2000,
|
94 |
+
nms=dict(type='nms', iou_threshold=0.7),
|
95 |
+
min_bbox_size=0),
|
96 |
+
rcnn=dict(
|
97 |
+
assigner=dict(
|
98 |
+
type='MaxIoUAssigner',
|
99 |
+
pos_iou_thr=0.5,
|
100 |
+
neg_iou_thr=0.5,
|
101 |
+
min_pos_iou=0.5,
|
102 |
+
match_low_quality=False,
|
103 |
+
ignore_iof_thr=-1),
|
104 |
+
sampler=dict(
|
105 |
+
type='RandomSampler',
|
106 |
+
num=512,
|
107 |
+
pos_fraction=0.25,
|
108 |
+
neg_pos_ub=-1,
|
109 |
+
add_gt_as_proposals=True),
|
110 |
+
mask_size=14,
|
111 |
+
pos_weight=-1,
|
112 |
+
debug=False)),
|
113 |
+
test_cfg=dict(
|
114 |
+
rpn=dict(
|
115 |
+
nms_pre=6000,
|
116 |
+
nms=dict(type='nms', iou_threshold=0.7),
|
117 |
+
max_per_img=1000,
|
118 |
+
min_bbox_size=0),
|
119 |
+
rcnn=dict(
|
120 |
+
score_thr=0.05,
|
121 |
+
nms=dict(type='nms', iou_threshold=0.5),
|
122 |
+
max_per_img=100,
|
123 |
+
mask_thr_binary=0.5)))
|
configs/_base_/models/mask_rcnn_r50_fpn.py
ADDED
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# model settings
|
2 |
+
model = dict(
|
3 |
+
type='MaskRCNN',
|
4 |
+
pretrained='torchvision://resnet50',
|
5 |
+
backbone=dict(
|
6 |
+
type='ResNet',
|
7 |
+
depth=50,
|
8 |
+
num_stages=4,
|
9 |
+
out_indices=(0, 1, 2, 3),
|
10 |
+
frozen_stages=1,
|
11 |
+
norm_cfg=dict(type='BN', requires_grad=True),
|
12 |
+
norm_eval=True,
|
13 |
+
style='pytorch'),
|
14 |
+
neck=dict(
|
15 |
+
type='FPN',
|
16 |
+
in_channels=[256, 512, 1024, 2048],
|
17 |
+
out_channels=256,
|
18 |
+
num_outs=5),
|
19 |
+
rpn_head=dict(
|
20 |
+
type='RPNHead',
|
21 |
+
in_channels=256,
|
22 |
+
feat_channels=256,
|
23 |
+
anchor_generator=dict(
|
24 |
+
type='AnchorGenerator',
|
25 |
+
scales=[8],
|
26 |
+
ratios=[0.5, 1.0, 2.0],
|
27 |
+
strides=[4, 8, 16, 32, 64]),
|
28 |
+
bbox_coder=dict(
|
29 |
+
type='DeltaXYWHBBoxCoder',
|
30 |
+
target_means=[.0, .0, .0, .0],
|
31 |
+
target_stds=[1.0, 1.0, 1.0, 1.0]),
|
32 |
+
loss_cls=dict(
|
33 |
+
type='CrossEntropyLoss', use_sigmoid=True, loss_weight=1.0),
|
34 |
+
loss_bbox=dict(type='L1Loss', loss_weight=1.0)),
|
35 |
+
roi_head=dict(
|
36 |
+
type='StandardRoIHead',
|
37 |
+
bbox_roi_extractor=dict(
|
38 |
+
type='SingleRoIExtractor',
|
39 |
+
roi_layer=dict(type='RoIAlign', output_size=7, sampling_ratio=0),
|
40 |
+
out_channels=256,
|
41 |
+
featmap_strides=[4, 8, 16, 32]),
|
42 |
+
bbox_head=dict(
|
43 |
+
type='Shared2FCBBoxHead',
|
44 |
+
in_channels=256,
|
45 |
+
fc_out_channels=1024,
|
46 |
+
roi_feat_size=7,
|
47 |
+
num_classes=80,
|
48 |
+
bbox_coder=dict(
|
49 |
+
type='DeltaXYWHBBoxCoder',
|
50 |
+
target_means=[0., 0., 0., 0.],
|
51 |
+
target_stds=[0.1, 0.1, 0.2, 0.2]),
|
52 |
+
reg_class_agnostic=False,
|
53 |
+
loss_cls=dict(
|
54 |
+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0),
|
55 |
+
loss_bbox=dict(type='L1Loss', loss_weight=1.0)),
|
56 |
+
mask_roi_extractor=dict(
|
57 |
+
type='SingleRoIExtractor',
|
58 |
+
roi_layer=dict(type='RoIAlign', output_size=14, sampling_ratio=0),
|
59 |
+
out_channels=256,
|
60 |
+
featmap_strides=[4, 8, 16, 32]),
|
61 |
+
mask_head=dict(
|
62 |
+
type='FCNMaskHead',
|
63 |
+
num_convs=4,
|
64 |
+
in_channels=256,
|
65 |
+
conv_out_channels=256,
|
66 |
+
num_classes=80,
|
67 |
+
loss_mask=dict(
|
68 |
+
type='CrossEntropyLoss', use_mask=True, loss_weight=1.0))),
|
69 |
+
# model training and testing settings
|
70 |
+
train_cfg=dict(
|
71 |
+
rpn=dict(
|
72 |
+
assigner=dict(
|
73 |
+
type='MaxIoUAssigner',
|
74 |
+
pos_iou_thr=0.7,
|
75 |
+
neg_iou_thr=0.3,
|
76 |
+
min_pos_iou=0.3,
|
77 |
+
match_low_quality=True,
|
78 |
+
ignore_iof_thr=-1),
|
79 |
+
sampler=dict(
|
80 |
+
type='RandomSampler',
|
81 |
+
num=256,
|
82 |
+
pos_fraction=0.5,
|
83 |
+
neg_pos_ub=-1,
|
84 |
+
add_gt_as_proposals=False),
|
85 |
+
allowed_border=-1,
|
86 |
+
pos_weight=-1,
|
87 |
+
debug=False),
|
88 |
+
rpn_proposal=dict(
|
89 |
+
nms_pre=2000,
|
90 |
+
max_per_img=1000,
|
91 |
+
nms=dict(type='nms', iou_threshold=0.7),
|
92 |
+
min_bbox_size=0),
|
93 |
+
rcnn=dict(
|
94 |
+
assigner=dict(
|
95 |
+
type='MaxIoUAssigner',
|
96 |
+
pos_iou_thr=0.5,
|
97 |
+
neg_iou_thr=0.5,
|
98 |
+
min_pos_iou=0.5,
|
99 |
+
match_low_quality=True,
|
100 |
+
ignore_iof_thr=-1),
|
101 |
+
sampler=dict(
|
102 |
+
type='RandomSampler',
|
103 |
+
num=512,
|
104 |
+
pos_fraction=0.25,
|
105 |
+
neg_pos_ub=-1,
|
106 |
+
add_gt_as_proposals=True),
|
107 |
+
mask_size=28,
|
108 |
+
pos_weight=-1,
|
109 |
+
debug=False)),
|
110 |
+
test_cfg=dict(
|
111 |
+
rpn=dict(
|
112 |
+
nms_pre=1000,
|
113 |
+
max_per_img=1000,
|
114 |
+
nms=dict(type='nms', iou_threshold=0.7),
|
115 |
+
min_bbox_size=0),
|
116 |
+
rcnn=dict(
|
117 |
+
score_thr=0.05,
|
118 |
+
nms=dict(type='nms', iou_threshold=0.5),
|
119 |
+
max_per_img=100,
|
120 |
+
mask_thr_binary=0.5)))
|
configs/_base_/models/mask_rcnn_swin_fpn.py
ADDED
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# model settings
|
2 |
+
"""
|
3 |
+
路径./configs/base/models/mask_rcnn_swin_fpn.py中第75行use_mask=True 修改为use_mask=False
|
4 |
+
还需要删除mask_roi_extractor和mask_head两个变量,大概在第63行和68行,
|
5 |
+
这里删除之后注意末尾的逗号和小括号的格式匹配问题
|
6 |
+
改num_classes=12
|
7 |
+
"""
|
8 |
+
|
9 |
+
model = dict(
|
10 |
+
type='MaskRCNN',
|
11 |
+
pretrained=None,
|
12 |
+
backbone=dict(
|
13 |
+
type='SwinTransformer',
|
14 |
+
embed_dim=96,
|
15 |
+
depths=[2, 2, 6, 2],
|
16 |
+
num_heads=[3, 6, 12, 24],
|
17 |
+
window_size=7,
|
18 |
+
mlp_ratio=4.,
|
19 |
+
qkv_bias=True,
|
20 |
+
qk_scale=None,
|
21 |
+
drop_rate=0.,
|
22 |
+
attn_drop_rate=0.,
|
23 |
+
drop_path_rate=0.2,
|
24 |
+
ape=False,
|
25 |
+
patch_norm=True,
|
26 |
+
out_indices=(0, 1, 2, 3),
|
27 |
+
use_checkpoint=False),
|
28 |
+
neck=dict(
|
29 |
+
type='FPN',
|
30 |
+
in_channels=[96, 192, 384, 768],
|
31 |
+
out_channels=256,
|
32 |
+
num_outs=5),
|
33 |
+
rpn_head=dict(
|
34 |
+
type='RPNHead',
|
35 |
+
in_channels=256,
|
36 |
+
feat_channels=256,
|
37 |
+
anchor_generator=dict(
|
38 |
+
type='AnchorGenerator',
|
39 |
+
scales=[8],
|
40 |
+
ratios=[0.5, 1.0, 2.0],
|
41 |
+
strides=[4, 8, 16, 32, 64]),
|
42 |
+
bbox_coder=dict(
|
43 |
+
type='DeltaXYWHBBoxCoder',
|
44 |
+
target_means=[.0, .0, .0, .0],
|
45 |
+
target_stds=[1.0, 1.0, 1.0, 1.0]),
|
46 |
+
loss_cls=dict(
|
47 |
+
type='CrossEntropyLoss', use_sigmoid=True, loss_weight=1.0),
|
48 |
+
loss_bbox=dict(type='L1Loss', loss_weight=1.0)),
|
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 |
+
bbox_head=dict(
|
57 |
+
type='Shared2FCBBoxHead',
|
58 |
+
in_channels=256,
|
59 |
+
fc_out_channels=1024,
|
60 |
+
roi_feat_size=7,
|
61 |
+
num_classes=12,
|
62 |
+
bbox_coder=dict(
|
63 |
+
type='DeltaXYWHBBoxCoder',
|
64 |
+
target_means=[0., 0., 0., 0.],
|
65 |
+
target_stds=[0.1, 0.1, 0.2, 0.2]),
|
66 |
+
reg_class_agnostic=False,
|
67 |
+
loss_cls=dict(
|
68 |
+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0),
|
69 |
+
loss_bbox=dict(type='L1Loss', loss_weight=1.0)),
|
70 |
+
# 删除mask,让实例分割变成目标检测
|
71 |
+
#mask_roi_extractor=dict(
|
72 |
+
# type='SingleRoIExtractor',
|
73 |
+
# roi_layer=dict(type='RoIAlign', output_size=14, sampling_ratio=0),
|
74 |
+
# out_channels=256,
|
75 |
+
# featmap_strides=[4, 8, 16, 32]),
|
76 |
+
#mask_head=dict(
|
77 |
+
# type='FCNMaskHead',
|
78 |
+
# num_convs=4,
|
79 |
+
# in_channels=256,
|
80 |
+
# conv_out_channels=256,
|
81 |
+
# num_classes=12,
|
82 |
+
# loss_mask=dict(
|
83 |
+
# type='CrossEntropyLoss', use_mask=False, loss_weight=1.0))
|
84 |
+
),
|
85 |
+
# model training and testing settings
|
86 |
+
train_cfg=dict(
|
87 |
+
rpn=dict(
|
88 |
+
assigner=dict(
|
89 |
+
type='MaxIoUAssigner',
|
90 |
+
pos_iou_thr=0.7,
|
91 |
+
neg_iou_thr=0.3,
|
92 |
+
min_pos_iou=0.3,
|
93 |
+
match_low_quality=True,
|
94 |
+
ignore_iof_thr=-1),
|
95 |
+
sampler=dict(
|
96 |
+
type='RandomSampler',
|
97 |
+
num=256,
|
98 |
+
pos_fraction=0.5,
|
99 |
+
neg_pos_ub=-1,
|
100 |
+
add_gt_as_proposals=False),
|
101 |
+
allowed_border=-1,
|
102 |
+
pos_weight=-1,
|
103 |
+
debug=False),
|
104 |
+
rpn_proposal=dict(
|
105 |
+
nms_pre=2000,
|
106 |
+
max_per_img=1000,
|
107 |
+
nms=dict(type='nms', iou_threshold=0.7),
|
108 |
+
min_bbox_size=0),
|
109 |
+
rcnn=dict(
|
110 |
+
assigner=dict(
|
111 |
+
type='MaxIoUAssigner',
|
112 |
+
pos_iou_thr=0.5,
|
113 |
+
neg_iou_thr=0.5,
|
114 |
+
min_pos_iou=0.5,
|
115 |
+
match_low_quality=True,
|
116 |
+
ignore_iof_thr=-1),
|
117 |
+
sampler=dict(
|
118 |
+
type='RandomSampler',
|
119 |
+
num=512,
|
120 |
+
pos_fraction=0.25,
|
121 |
+
neg_pos_ub=-1,
|
122 |
+
add_gt_as_proposals=True),
|
123 |
+
mask_size=28,
|
124 |
+
pos_weight=-1,
|
125 |
+
debug=False)),
|
126 |
+
test_cfg=dict(
|
127 |
+
rpn=dict(
|
128 |
+
nms_pre=1000,
|
129 |
+
max_per_img=1000,
|
130 |
+
nms=dict(type='nms', iou_threshold=0.7),
|
131 |
+
min_bbox_size=0),
|
132 |
+
rcnn=dict(
|
133 |
+
score_thr=0.05,
|
134 |
+
nms=dict(type='nms', iou_threshold=0.5),
|
135 |
+
max_per_img=100,
|
136 |
+
mask_thr_binary=0.5)))
|
configs/_base_/models/mask_reppointsv2_swin_bifpn.py
ADDED
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# model settings
|
2 |
+
norm_cfg = dict(type='GN', num_groups=32, requires_grad=True)
|
3 |
+
model = dict(
|
4 |
+
type='RepPointsV2MaskDetector',
|
5 |
+
pretrained=None,
|
6 |
+
backbone=dict(
|
7 |
+
type='SwinTransformer',
|
8 |
+
embed_dim=96,
|
9 |
+
depths=[2, 2, 6, 2],
|
10 |
+
num_heads=[3, 6, 12, 24],
|
11 |
+
window_size=7,
|
12 |
+
mlp_ratio=4.,
|
13 |
+
qkv_bias=True,
|
14 |
+
qk_scale=None,
|
15 |
+
drop_rate=0.,
|
16 |
+
attn_drop_rate=0.,
|
17 |
+
drop_path_rate=0.2,
|
18 |
+
ape=False,
|
19 |
+
patch_norm=True,
|
20 |
+
out_indices=(1, 2, 3),
|
21 |
+
use_checkpoint=False),
|
22 |
+
neck=dict(
|
23 |
+
type='BiFPN',
|
24 |
+
in_channels=[192, 384, 768],
|
25 |
+
out_channels=256,
|
26 |
+
start_level=0,
|
27 |
+
add_extra_convs=False,
|
28 |
+
num_outs=5,
|
29 |
+
no_norm_on_lateral=False,
|
30 |
+
num_repeat=2,
|
31 |
+
norm_cfg=norm_cfg
|
32 |
+
),
|
33 |
+
bbox_head=dict(
|
34 |
+
type='RepPointsV2Head',
|
35 |
+
num_classes=80,
|
36 |
+
in_channels=256,
|
37 |
+
feat_channels=256,
|
38 |
+
point_feat_channels=256,
|
39 |
+
stacked_convs=3,
|
40 |
+
shared_stacked_convs=1,
|
41 |
+
first_kernel_size=3,
|
42 |
+
kernel_size=1,
|
43 |
+
corner_dim=64,
|
44 |
+
num_points=9,
|
45 |
+
gradient_mul=0.1,
|
46 |
+
point_strides=[8, 16, 32, 64, 128],
|
47 |
+
point_base_scale=4,
|
48 |
+
norm_cfg=norm_cfg,
|
49 |
+
loss_cls=dict(
|
50 |
+
type='RPDQualityFocalLoss',
|
51 |
+
use_sigmoid=True,
|
52 |
+
beta=2.0,
|
53 |
+
loss_weight=1.0),
|
54 |
+
loss_bbox_init=dict(type='RPDGIoULoss', loss_weight=1.0),
|
55 |
+
loss_bbox_refine=dict(type='RPDGIoULoss', loss_weight=2.0),
|
56 |
+
loss_heatmap=dict(
|
57 |
+
type='GaussianFocalLoss',
|
58 |
+
alpha=2.0,
|
59 |
+
gamma=4.0,
|
60 |
+
loss_weight=0.25),
|
61 |
+
loss_offset=dict(type='SmoothL1Loss', beta=1.0 / 9.0, loss_weight=1.0),
|
62 |
+
loss_sem=dict(
|
63 |
+
type='SEPFocalLoss',
|
64 |
+
gamma=2.0,
|
65 |
+
alpha=0.25,
|
66 |
+
loss_weight=0.1),
|
67 |
+
transform_method='exact_minmax',
|
68 |
+
# new for condconv
|
69 |
+
coord_pos='center',
|
70 |
+
mask_head=dict(
|
71 |
+
type='CondConvMaskHead',
|
72 |
+
branch_cfg=dict(
|
73 |
+
in_channels=256, # == neck out channels
|
74 |
+
channels=128,
|
75 |
+
in_features=[0,1,2],
|
76 |
+
out_stride=[8,16,32], # p3, p4, p5
|
77 |
+
norm=dict(type='BN', requires_grad=True),
|
78 |
+
num_convs=4,
|
79 |
+
out_channels=8,
|
80 |
+
semantic_loss_on=False,
|
81 |
+
num_classes=80,
|
82 |
+
loss_sem=dict(
|
83 |
+
type='FocalLoss',
|
84 |
+
use_sigmoid=True,
|
85 |
+
gamma=2.0,
|
86 |
+
alpha=0.25,
|
87 |
+
loss_weight=1.0,
|
88 |
+
prior_prob=0.01)
|
89 |
+
),
|
90 |
+
head_cfg=dict(
|
91 |
+
channels=8,
|
92 |
+
disable_rel_coords=False,
|
93 |
+
num_layers=3,
|
94 |
+
use_fp16=False,
|
95 |
+
mask_out_stride=4,
|
96 |
+
max_proposals=500,
|
97 |
+
aux_loss=True,
|
98 |
+
mask_loss_weight=[0.,0.6,1.],
|
99 |
+
sizes_of_interest=[64, 128, 256, 512, 1024]
|
100 |
+
),
|
101 |
+
)),
|
102 |
+
train_cfg = dict(
|
103 |
+
init=dict(
|
104 |
+
assigner=dict(type='PointAssignerV2', scale=4, pos_num=1, mask_center_sample=True, use_center=True),
|
105 |
+
allowed_border=-1,
|
106 |
+
pos_weight=-1,
|
107 |
+
debug=False),
|
108 |
+
heatmap=dict(
|
109 |
+
assigner=dict(type='PointHMAssigner', gaussian_bump=True, gaussian_iou=0.7),
|
110 |
+
allowed_border=-1,
|
111 |
+
pos_weight=-1,
|
112 |
+
debug=False),
|
113 |
+
refine=dict(
|
114 |
+
assigner=dict(type='ATSSAssignerV2', topk=9, mask_center_sample=True),
|
115 |
+
allowed_border=-1,
|
116 |
+
pos_weight=-1,
|
117 |
+
debug=False)),
|
118 |
+
test_cfg = dict(
|
119 |
+
nms_pre=1000,
|
120 |
+
min_bbox_size=0,
|
121 |
+
score_thr=0.05,
|
122 |
+
nms=dict(type='nms', iou_threshold=0.6),
|
123 |
+
max_per_img=100)
|
124 |
+
)
|
configs/_base_/models/reppointsv2_swin_bifpn.py
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# model settings
|
2 |
+
norm_cfg = dict(type='GN', num_groups=32, requires_grad=True)
|
3 |
+
model = dict(
|
4 |
+
type='RepPointsV2Detector',
|
5 |
+
pretrained=None,
|
6 |
+
backbone=dict(
|
7 |
+
type='SwinTransformer',
|
8 |
+
embed_dim=96,
|
9 |
+
depths=[2, 2, 6, 2],
|
10 |
+
num_heads=[3, 6, 12, 24],
|
11 |
+
window_size=7,
|
12 |
+
mlp_ratio=4.,
|
13 |
+
qkv_bias=True,
|
14 |
+
qk_scale=None,
|
15 |
+
drop_rate=0.,
|
16 |
+
attn_drop_rate=0.,
|
17 |
+
drop_path_rate=0.2,
|
18 |
+
ape=False,
|
19 |
+
patch_norm=True,
|
20 |
+
out_indices=(1, 2, 3),
|
21 |
+
use_checkpoint=False),
|
22 |
+
neck=dict(
|
23 |
+
type='BiFPN',
|
24 |
+
in_channels=[192, 384, 768],
|
25 |
+
out_channels=256,
|
26 |
+
start_level=0,
|
27 |
+
add_extra_convs=False,
|
28 |
+
num_outs=5,
|
29 |
+
no_norm_on_lateral=False,
|
30 |
+
num_repeat=2,
|
31 |
+
norm_cfg=norm_cfg
|
32 |
+
),
|
33 |
+
bbox_head=dict(
|
34 |
+
type='RepPointsV2Head',
|
35 |
+
num_classes=80,
|
36 |
+
in_channels=256,
|
37 |
+
feat_channels=256,
|
38 |
+
point_feat_channels=256,
|
39 |
+
stacked_convs=3,
|
40 |
+
shared_stacked_convs=1,
|
41 |
+
first_kernel_size=3,
|
42 |
+
kernel_size=1,
|
43 |
+
corner_dim=64,
|
44 |
+
num_points=9,
|
45 |
+
gradient_mul=0.1,
|
46 |
+
point_strides=[8, 16, 32, 64, 128],
|
47 |
+
point_base_scale=4,
|
48 |
+
norm_cfg=norm_cfg,
|
49 |
+
loss_cls=dict(
|
50 |
+
type='RPDQualityFocalLoss',
|
51 |
+
use_sigmoid=True,
|
52 |
+
beta=2.0,
|
53 |
+
loss_weight=1.0),
|
54 |
+
loss_bbox_init=dict(type='RPDGIoULoss', loss_weight=1.0),
|
55 |
+
loss_bbox_refine=dict(type='RPDGIoULoss', loss_weight=2.0),
|
56 |
+
loss_heatmap=dict(
|
57 |
+
type='GaussianFocalLoss',
|
58 |
+
alpha=2.0,
|
59 |
+
gamma=4.0,
|
60 |
+
loss_weight=0.25),
|
61 |
+
loss_offset=dict(type='SmoothL1Loss', beta=1.0 / 9.0, loss_weight=1.0),
|
62 |
+
loss_sem=dict(
|
63 |
+
type='SEPFocalLoss',
|
64 |
+
gamma=2.0,
|
65 |
+
alpha=0.25,
|
66 |
+
loss_weight=0.1),
|
67 |
+
transform_method='exact_minmax'),
|
68 |
+
# training and testing settings
|
69 |
+
train_cfg = dict(
|
70 |
+
init=dict(
|
71 |
+
assigner=dict(type='PointAssignerV2', scale=4, pos_num=1),
|
72 |
+
allowed_border=-1,
|
73 |
+
pos_weight=-1,
|
74 |
+
debug=False),
|
75 |
+
heatmap=dict(
|
76 |
+
assigner=dict(type='PointHMAssigner', gaussian_bump=True, gaussian_iou=0.7),
|
77 |
+
allowed_border=-1,
|
78 |
+
pos_weight=-1,
|
79 |
+
debug=False),
|
80 |
+
refine=dict(
|
81 |
+
assigner=dict(type='ATSSAssignerV2', topk=9),
|
82 |
+
allowed_border=-1,
|
83 |
+
pos_weight=-1,
|
84 |
+
debug=False)),
|
85 |
+
test_cfg = dict(
|
86 |
+
nms_pre=1000,
|
87 |
+
min_bbox_size=0,
|
88 |
+
score_thr=0.05,
|
89 |
+
nms=dict(type='nms', iou_threshold=0.6),
|
90 |
+
max_per_img=100),
|
91 |
+
)
|
configs/_base_/models/retinanet_r50_fpn.py
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# model settings
|
2 |
+
model = dict(
|
3 |
+
type='RetinaNet',
|
4 |
+
pretrained='torchvision://resnet50',
|
5 |
+
backbone=dict(
|
6 |
+
type='ResNet',
|
7 |
+
depth=50,
|
8 |
+
num_stages=4,
|
9 |
+
out_indices=(0, 1, 2, 3),
|
10 |
+
frozen_stages=1,
|
11 |
+
norm_cfg=dict(type='BN', requires_grad=True),
|
12 |
+
norm_eval=True,
|
13 |
+
style='pytorch'),
|
14 |
+
neck=dict(
|
15 |
+
type='FPN',
|
16 |
+
in_channels=[256, 512, 1024, 2048],
|
17 |
+
out_channels=256,
|
18 |
+
start_level=1,
|
19 |
+
add_extra_convs='on_input',
|
20 |
+
num_outs=5),
|
21 |
+
bbox_head=dict(
|
22 |
+
type='RetinaHead',
|
23 |
+
num_classes=80,
|
24 |
+
in_channels=256,
|
25 |
+
stacked_convs=4,
|
26 |
+
feat_channels=256,
|
27 |
+
anchor_generator=dict(
|
28 |
+
type='AnchorGenerator',
|
29 |
+
octave_base_scale=4,
|
30 |
+
scales_per_octave=3,
|
31 |
+
ratios=[0.5, 1.0, 2.0],
|
32 |
+
strides=[8, 16, 32, 64, 128]),
|
33 |
+
bbox_coder=dict(
|
34 |
+
type='DeltaXYWHBBoxCoder',
|
35 |
+
target_means=[.0, .0, .0, .0],
|
36 |
+
target_stds=[1.0, 1.0, 1.0, 1.0]),
|
37 |
+
loss_cls=dict(
|
38 |
+
type='FocalLoss',
|
39 |
+
use_sigmoid=True,
|
40 |
+
gamma=2.0,
|
41 |
+
alpha=0.25,
|
42 |
+
loss_weight=1.0),
|
43 |
+
loss_bbox=dict(type='L1Loss', loss_weight=1.0)),
|
44 |
+
# training and testing settings
|
45 |
+
train_cfg=dict(
|
46 |
+
assigner=dict(
|
47 |
+
type='MaxIoUAssigner',
|
48 |
+
pos_iou_thr=0.5,
|
49 |
+
neg_iou_thr=0.4,
|
50 |
+
min_pos_iou=0,
|
51 |
+
ignore_iof_thr=-1),
|
52 |
+
allowed_border=-1,
|
53 |
+
pos_weight=-1,
|
54 |
+
debug=False),
|
55 |
+
test_cfg=dict(
|
56 |
+
nms_pre=1000,
|
57 |
+
min_bbox_size=0,
|
58 |
+
score_thr=0.05,
|
59 |
+
nms=dict(type='nms', iou_threshold=0.5),
|
60 |
+
max_per_img=100))
|
configs/_base_/models/rpn_r50_caffe_c4.py
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# model settings
|
2 |
+
model = dict(
|
3 |
+
type='RPN',
|
4 |
+
pretrained='open-mmlab://detectron2/resnet50_caffe',
|
5 |
+
backbone=dict(
|
6 |
+
type='ResNet',
|
7 |
+
depth=50,
|
8 |
+
num_stages=3,
|
9 |
+
strides=(1, 2, 2),
|
10 |
+
dilations=(1, 1, 1),
|
11 |
+
out_indices=(2, ),
|
12 |
+
frozen_stages=1,
|
13 |
+
norm_cfg=dict(type='BN', requires_grad=False),
|
14 |
+
norm_eval=True,
|
15 |
+
style='caffe'),
|
16 |
+
neck=None,
|
17 |
+
rpn_head=dict(
|
18 |
+
type='RPNHead',
|
19 |
+
in_channels=1024,
|
20 |
+
feat_channels=1024,
|
21 |
+
anchor_generator=dict(
|
22 |
+
type='AnchorGenerator',
|
23 |
+
scales=[2, 4, 8, 16, 32],
|
24 |
+
ratios=[0.5, 1.0, 2.0],
|
25 |
+
strides=[16]),
|
26 |
+
bbox_coder=dict(
|
27 |
+
type='DeltaXYWHBBoxCoder',
|
28 |
+
target_means=[.0, .0, .0, .0],
|
29 |
+
target_stds=[1.0, 1.0, 1.0, 1.0]),
|
30 |
+
loss_cls=dict(
|
31 |
+
type='CrossEntropyLoss', use_sigmoid=True, loss_weight=1.0),
|
32 |
+
loss_bbox=dict(type='L1Loss', loss_weight=1.0)),
|
33 |
+
# model training and testing settings
|
34 |
+
train_cfg=dict(
|
35 |
+
rpn=dict(
|
36 |
+
assigner=dict(
|
37 |
+
type='MaxIoUAssigner',
|
38 |
+
pos_iou_thr=0.7,
|
39 |
+
neg_iou_thr=0.3,
|
40 |
+
min_pos_iou=0.3,
|
41 |
+
ignore_iof_thr=-1),
|
42 |
+
sampler=dict(
|
43 |
+
type='RandomSampler',
|
44 |
+
num=256,
|
45 |
+
pos_fraction=0.5,
|
46 |
+
neg_pos_ub=-1,
|
47 |
+
add_gt_as_proposals=False),
|
48 |
+
allowed_border=0,
|
49 |
+
pos_weight=-1,
|
50 |
+
debug=False)),
|
51 |
+
test_cfg=dict(
|
52 |
+
rpn=dict(
|
53 |
+
nms_pre=12000,
|
54 |
+
max_per_img=2000,
|
55 |
+
nms=dict(type='nms', iou_threshold=0.7),
|
56 |
+
min_bbox_size=0)))
|
configs/_base_/models/rpn_r50_fpn.py
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# model settings
|
2 |
+
|
3 |
+
model = dict(
|
4 |
+
type='RPN',
|
5 |
+
pretrained='torchvision://resnet50',
|
6 |
+
backbone=dict(
|
7 |
+
type='ResNet',
|
8 |
+
depth=50,
|
9 |
+
num_stages=4,
|
10 |
+
out_indices=(0, 1, 2, 3),
|
11 |
+
frozen_stages=1,
|
12 |
+
norm_cfg=dict(type='BN', requires_grad=True),
|
13 |
+
norm_eval=True,
|
14 |
+
style='pytorch'),
|
15 |
+
neck=dict(
|
16 |
+
type='FPN',
|
17 |
+
in_channels=[256, 512, 1024, 2048],
|
18 |
+
out_channels=256,
|
19 |
+
num_outs=5),
|
20 |
+
rpn_head=dict(
|
21 |
+
type='RPNHead',
|
22 |
+
in_channels=256,
|
23 |
+
feat_channels=256,
|
24 |
+
anchor_generator=dict(
|
25 |
+
type='AnchorGenerator',
|
26 |
+
scales=[8],
|
27 |
+
ratios=[0.5, 1.0, 2.0],
|
28 |
+
strides=[4, 8, 16, 32, 64]),
|
29 |
+
bbox_coder=dict(
|
30 |
+
type='DeltaXYWHBBoxCoder',
|
31 |
+
target_means=[.0, .0, .0, .0],
|
32 |
+
target_stds=[1.0, 1.0, 1.0, 1.0]),
|
33 |
+
loss_cls=dict(
|
34 |
+
type='CrossEntropyLoss', use_sigmoid=True, loss_weight=1.0),
|
35 |
+
loss_bbox=dict(type='L1Loss', loss_weight=1.0)),
|
36 |
+
# model training and testing settings
|
37 |
+
train_cfg=dict(
|
38 |
+
rpn=dict(
|
39 |
+
assigner=dict(
|
40 |
+
type='MaxIoUAssigner',
|
41 |
+
pos_iou_thr=0.7,
|
42 |
+
neg_iou_thr=0.3,
|
43 |
+
min_pos_iou=0.3,
|
44 |
+
ignore_iof_thr=-1),
|
45 |
+
sampler=dict(
|
46 |
+
type='RandomSampler',
|
47 |
+
num=256,
|
48 |
+
pos_fraction=0.5,
|
49 |
+
neg_pos_ub=-1,
|
50 |
+
add_gt_as_proposals=False),
|
51 |
+
allowed_border=0,
|
52 |
+
pos_weight=-1,
|
53 |
+
debug=False)),
|
54 |
+
test_cfg=dict(
|
55 |
+
rpn=dict(
|
56 |
+
nms_pre=2000,
|
57 |
+
max_per_img=1000,
|
58 |
+
nms=dict(type='nms', iou_threshold=0.7),
|
59 |
+
min_bbox_size=0)))
|
configs/_base_/models/ssd300.py
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# model settings
|
2 |
+
input_size = 300
|
3 |
+
model = dict(
|
4 |
+
type='SingleStageDetector',
|
5 |
+
pretrained='open-mmlab://vgg16_caffe',
|
6 |
+
backbone=dict(
|
7 |
+
type='SSDVGG',
|
8 |
+
input_size=input_size,
|
9 |
+
depth=16,
|
10 |
+
with_last_pool=False,
|
11 |
+
ceil_mode=True,
|
12 |
+
out_indices=(3, 4),
|
13 |
+
out_feature_indices=(22, 34),
|
14 |
+
l2_norm_scale=20),
|
15 |
+
neck=None,
|
16 |
+
bbox_head=dict(
|
17 |
+
type='SSDHead',
|
18 |
+
in_channels=(512, 1024, 512, 256, 256, 256),
|
19 |
+
num_classes=80,
|
20 |
+
anchor_generator=dict(
|
21 |
+
type='SSDAnchorGenerator',
|
22 |
+
scale_major=False,
|
23 |
+
input_size=input_size,
|
24 |
+
basesize_ratio_range=(0.15, 0.9),
|
25 |
+
strides=[8, 16, 32, 64, 100, 300],
|
26 |
+
ratios=[[2], [2, 3], [2, 3], [2, 3], [2], [2]]),
|
27 |
+
bbox_coder=dict(
|
28 |
+
type='DeltaXYWHBBoxCoder',
|
29 |
+
target_means=[.0, .0, .0, .0],
|
30 |
+
target_stds=[0.1, 0.1, 0.2, 0.2])),
|
31 |
+
train_cfg=dict(
|
32 |
+
assigner=dict(
|
33 |
+
type='MaxIoUAssigner',
|
34 |
+
pos_iou_thr=0.5,
|
35 |
+
neg_iou_thr=0.5,
|
36 |
+
min_pos_iou=0.,
|
37 |
+
ignore_iof_thr=-1,
|
38 |
+
gt_max_assign_all=False),
|
39 |
+
smoothl1_beta=1.,
|
40 |
+
allowed_border=-1,
|
41 |
+
pos_weight=-1,
|
42 |
+
neg_pos_ratio=3,
|
43 |
+
debug=False),
|
44 |
+
test_cfg=dict(
|
45 |
+
nms_pre=1000,
|
46 |
+
nms=dict(type='nms', iou_threshold=0.45),
|
47 |
+
min_bbox_size=0,
|
48 |
+
score_thr=0.02,
|
49 |
+
max_per_img=200))
|
50 |
+
cudnn_benchmark = True
|
configs/_base_/schedules/schedule_1x.py
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# optimizer
|
2 |
+
optimizer = dict(type='SGD', lr=0.02, momentum=0.9, weight_decay=0.0001)
|
3 |
+
optimizer_config = dict(grad_clip=None)
|
4 |
+
# learning policy
|
5 |
+
lr_config = dict(
|
6 |
+
policy='step',
|
7 |
+
warmup='linear',
|
8 |
+
warmup_iters=500,
|
9 |
+
warmup_ratio=0.001,
|
10 |
+
step=[8, 11])
|
11 |
+
runner = dict(type='EpochBasedRunner', max_epochs=12)
|
configs/_base_/schedules/schedule_20e.py
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# optimizer
|
2 |
+
optimizer = dict(type='SGD', lr=0.02, momentum=0.9, weight_decay=0.0001)
|
3 |
+
optimizer_config = dict(grad_clip=None)
|
4 |
+
# learning policy
|
5 |
+
lr_config = dict(
|
6 |
+
policy='step',
|
7 |
+
warmup='linear',
|
8 |
+
warmup_iters=500,
|
9 |
+
warmup_ratio=0.001,
|
10 |
+
step=[16, 19])
|
11 |
+
runner = dict(type='EpochBasedRunner', max_epochs=20)
|