Skip to content

Commit 9035d52

Browse files
committed
migrate to mmdetection
1 parent f327b2a commit 9035d52

28 files changed

+3549
-0
lines changed

.gitignore

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
MANIFEST
27+
28+
# PyInstaller
29+
# Usually these files are written by a python script from a template
30+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
31+
*.manifest
32+
*.spec
33+
34+
# Installer logs
35+
pip-log.txt
36+
pip-delete-this-directory.txt
37+
38+
# Unit test / coverage reports
39+
htmlcov/
40+
.tox/
41+
.coverage
42+
.coverage.*
43+
.cache
44+
nosetests.xml
45+
coverage.xml
46+
*.cover
47+
.hypothesis/
48+
.pytest_cache/
49+
50+
# Translations
51+
*.mo
52+
*.pot
53+
54+
# Django stuff:
55+
*.log
56+
local_settings.py
57+
db.sqlite3
58+
59+
# Flask stuff:
60+
instance/
61+
.webassets-cache
62+
63+
# Scrapy stuff:
64+
.scrapy
65+
66+
# Sphinx documentation
67+
docs/_build/
68+
69+
# PyBuilder
70+
target/
71+
72+
# Jupyter Notebook
73+
.ipynb_checkpoints
74+
75+
# pyenv
76+
.python-version
77+
78+
# celery beat schedule file
79+
celerybeat-schedule
80+
81+
# SageMath parsed files
82+
*.sage.py
83+
84+
# Environments
85+
.env
86+
.venv
87+
env/
88+
venv/
89+
ENV/
90+
env.bak/
91+
venv.bak/
92+
93+
# Spyder project settings
94+
.spyderproject
95+
.spyproject
96+
97+
# Rope project settings
98+
.ropeproject
99+
100+
# mkdocs documentation
101+
/site
102+
103+
# mypy
104+
.mypy_cache/
105+
106+
# cython generated cpp
107+
mmdet/ops/nms/*.cpp
108+
mmdet/version.py
109+
data
110+
.vscode
111+
.idea
112+
113+
work_dirs/

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "mmdetection"]
2+
path = mmdetection
3+
url = https://github.com/open-mmlab/mmdetection.git

compile.sh

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env bash
2+
3+
PYTHON=${PYTHON:-"python"}
4+
5+
echo "Building roi align op..."
6+
cd mmdet/ops/roi_align
7+
if [ -d "build" ]; then
8+
rm -r build
9+
fi
10+
$PYTHON setup.py build_ext --inplace
11+
12+
echo "Building roi pool op..."
13+
cd ../roi_pool
14+
if [ -d "build" ]; then
15+
rm -r build
16+
fi
17+
$PYTHON setup.py build_ext --inplace
18+
19+
echo "Building nms op..."
20+
cd ../nms
21+
make clean
22+
make PYTHON=${PYTHON}
23+
24+
echo "Building dcn..."
25+
cd ../dcn
26+
if [ -d "build" ]; then
27+
rm -r build
28+
fi
29+
$PYTHON setup.py build_ext --inplace
30+
31+
echo "Building corner pooling..."
32+
cd ../_cpools
33+
if [ -d "build" ]; then
34+
rm -r build
35+
fi
36+
$PYTHON setup.py build_ext --inplace

configs/centripetalnet_mask_hg104.py

+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
#model settings
2+
model = dict(
3+
type='CentripetalNet',
4+
backbone=dict(
5+
type='Hourglass',
6+
n=5,
7+
nstack=2,
8+
dims=[256, 256, 384, 384, 384, 512],
9+
modules=[2, 2, 2, 2, 2, 4],
10+
out_dim=80,),
11+
neck=None,
12+
bbox_head=dict(
13+
type='Centripetal_mask',
14+
num_classes=81,
15+
in_channels=256,
16+
with_mask=False,
17+
))
18+
# training and testing settings
19+
train_cfg = dict(
20+
assigner=dict(
21+
type='MaxIoUAssigner',
22+
pos_iou_thr=0.5,
23+
neg_iou_thr=0.4,
24+
min_pos_iou=0,
25+
ignore_iof_thr=-1),
26+
smoothl1_beta=0.11,
27+
gamma=2.0,
28+
alpha=0.25,
29+
allowed_border=-1,
30+
pos_weight=-1,
31+
debug=False)
32+
test_cfg = dict(
33+
nms_pre=1000,
34+
min_bbox_size=0,
35+
score_thr=0.05,
36+
nms=dict(type='nms', iou_thr=0.5),
37+
max_per_img=100)
38+
# dataset settings
39+
dataset_type = 'CocoDataset'
40+
#data_root = 'data/mscoco2017/'
41+
data_root = '/mnt/lustre/share/DSK/datasets/mscoco2017/'
42+
img_norm_cfg = dict(
43+
mean=[103.53, 116.28, 123.675], std=[57.375, 57.12, 58.395], to_rgb=False)
44+
45+
cornernet_mode = True
46+
47+
data = dict(
48+
imgs_per_gpu=6,#3
49+
workers_per_gpu=3,#3
50+
train=dict(
51+
type=dataset_type,
52+
ann_file=data_root + 'annotations/instances_train2017.json',
53+
img_prefix=data_root + 'train2017/',
54+
img_scale=(511, 511),
55+
img_norm_cfg=img_norm_cfg,
56+
size_divisor=None,
57+
flip_ratio=0.5,
58+
with_mask=True,
59+
with_crowd=False,
60+
with_label=True,
61+
resize_keep_ratio=False,
62+
cornernet_mode=cornernet_mode,
63+
extra_aug=dict(
64+
photo_metric_distortion=dict(
65+
brightness_delta=32,
66+
contrast_range=(0.5, 1.5),
67+
saturation_range=(0.5, 1.5),
68+
hue_delta=18),
69+
expand=dict(
70+
mean=img_norm_cfg['mean'],
71+
to_rgb=img_norm_cfg['to_rgb'],
72+
ratio_range=(1, 4)),
73+
random_crop=dict(
74+
min_ious=(0.1, 0.3, 0.5, 0.7, 0.9), min_crop_size=0.3))),
75+
val=dict(
76+
type=dataset_type,
77+
ann_file=data_root + 'annotations/instances_val2017.json',
78+
img_prefix=data_root + 'val2017/',
79+
img_scale=(511, 511),
80+
img_norm_cfg=img_norm_cfg,
81+
size_divisor=None,
82+
flip_ratio=1,
83+
with_mask=False,
84+
with_crowd=False,
85+
with_label=True,
86+
cornernet_mode=cornernet_mode,
87+
resize_keep_ratio=False),
88+
test=dict(
89+
type=dataset_type,
90+
ann_file=data_root + 'annotations/image_info_test-dev2017.json',
91+
img_prefix=data_root + 'test2017/',
92+
img_scale=(511, 511),
93+
img_norm_cfg=img_norm_cfg,
94+
size_divisor=None,
95+
flip_ratio=1,
96+
with_mask=False,
97+
with_crowd=False,
98+
with_label=False,
99+
test_mode=True,
100+
cornernet_mode=cornernet_mode,
101+
resize_keep_ratio=False))
102+
# optimizer
103+
optimizer = dict(type='Adam', lr=0.00005)
104+
optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2))
105+
106+
# learning policy
107+
# policy='fixed'
108+
lr_config = dict(
109+
policy='step',
110+
warmup='linear',
111+
warmup_iters=500,
112+
warmup_ratio=1.0 / 3,
113+
step=[190])
114+
checkpoint_config = dict(interval=1)
115+
# yapf:disable
116+
log_config = dict(
117+
interval=50,
118+
hooks=[
119+
dict(type='TextLoggerHook'),
120+
# dict(type='TensorboardLoggerHook')
121+
])
122+
# yapf:enable
123+
# runtime settings
124+
total_epochs = 210
125+
device_ids = range(8)
126+
dist_params = dict(backend='nccl')
127+
log_level = 'INFO'
128+
work_dir = './work_dirs/centripetalnet_mask_hg104'
129+
resume_from = None
130+
load_from = None
131+
workflow = [('train', 1)]
132+

init.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
PYTHON=${PYTHON:-"python"}
4+
5+
# copy files
6+
cp compile.sh mmdetection/
7+
cp -r src/core/* mmdetection/mmdet/core/
8+
cp -r src/datasets/* mmdetection/mmdet/datasets/
9+
cp -r src/models/* mmdetection/mmdet/models/
10+
cp -r src/ops/* mmdetection/mmdet/ops/
11+
12+
# compile and setup
13+
cd mmdetection
14+
./compile.sh
15+
$PYTHON setup.py install --user

mmdetection

Submodule mmdetection added at 6d83f89

src/core/__init__.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from .anchor import * # noqa: F401, F403
2+
from .bbox import * # noqa: F401, F403
3+
from .corner import *
4+
from .mask import *
5+
from .loss import * # noqa: F401, F403
6+
from .evaluation import * # noqa: F401, F403
7+
from .post_processing import * # noqa: F401, F403
8+
from .utils import * # noqa: F401, F403

src/core/corner/__init__.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from .corner_target import corner_target
2+
from .kp_utils import _gather_feat,_nms,_tranpose_and_gather_feat,_topk,_neg_loss,_sigmoid,_ae_loss,_regr_loss,gaussian2D,draw_gaussian,gaussian_radius, _decode_center
3+
4+
__all__ = ['corner_target','_gather_feat','_nms','_tranpose_and_gather_feat','_topk','_decode_center','_neg_loss','_sigmoid','_ae_loss','_regr_loss','gaussian2D','draw_gaussian','gaussian_radius']
5+

0 commit comments

Comments
 (0)