Skip to content

Commit 285675b

Browse files
committed
Add files
1 parent 31c19f8 commit 285675b

File tree

9 files changed

+563
-0
lines changed

9 files changed

+563
-0
lines changed

MANIFEST.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include LICENSE
2+
include README.md
3+
include requirements.txt
4+
recursive-include configs *.py

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
# Anime Face Detector
22

3+
This is an anime face detector using
4+
[mmdetection](https://github.com/open-mmlab/mmdetection)
5+
and [mmpose](https://github.com/open-mmlab/mmpose).

anime_face_detector/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import pathlib
2+
3+
from .detector import LandmarkDetector
4+
5+
6+
def get_config_path(model_name: str) -> pathlib.Path:
7+
assert model_name in ['faster-rcnn', 'yolov3', 'hrnetv2']
8+
9+
package_path = pathlib.Path(__file__).parent.resolve()
10+
if model_name in ['faster-rcnn', 'yolov3']:
11+
config_dir = package_path / 'configs' / 'mmdet'
12+
else:
13+
config_dir = package_path / 'configs' / 'mmpose'
14+
return config_dir / f'{model_name}.py'
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
model = dict(type='FasterRCNN',
2+
backbone=dict(type='ResNet',
3+
depth=50,
4+
num_stages=4,
5+
out_indices=(0, 1, 2, 3),
6+
frozen_stages=1,
7+
norm_cfg=dict(type='BN', requires_grad=True),
8+
norm_eval=True,
9+
style='pytorch'),
10+
neck=dict(type='FPN',
11+
in_channels=[256, 512, 1024, 2048],
12+
out_channels=256,
13+
num_outs=5),
14+
rpn_head=dict(type='RPNHead',
15+
in_channels=256,
16+
feat_channels=256,
17+
anchor_generator=dict(type='AnchorGenerator',
18+
scales=[8],
19+
ratios=[0.5, 1.0, 2.0],
20+
strides=[4, 8, 16, 32, 64]),
21+
bbox_coder=dict(type='DeltaXYWHBBoxCoder',
22+
target_means=[0.0, 0.0, 0.0, 0.0],
23+
target_stds=[1.0, 1.0, 1.0, 1.0])),
24+
roi_head=dict(
25+
type='StandardRoIHead',
26+
bbox_roi_extractor=dict(type='SingleRoIExtractor',
27+
roi_layer=dict(type='RoIAlign',
28+
output_size=7,
29+
sampling_ratio=0),
30+
out_channels=256,
31+
featmap_strides=[4, 8, 16, 32]),
32+
bbox_head=dict(type='Shared2FCBBoxHead',
33+
in_channels=256,
34+
fc_out_channels=1024,
35+
roi_feat_size=7,
36+
num_classes=1,
37+
bbox_coder=dict(
38+
type='DeltaXYWHBBoxCoder',
39+
target_means=[0.0, 0.0, 0.0, 0.0],
40+
target_stds=[0.1, 0.1, 0.2, 0.2]),
41+
reg_class_agnostic=False)),
42+
test_cfg=dict(rpn=dict(nms_pre=1000,
43+
max_per_img=1000,
44+
nms=dict(type='nms', iou_threshold=0.7),
45+
min_bbox_size=0),
46+
rcnn=dict(score_thr=0.05,
47+
nms=dict(type='nms', iou_threshold=0.5),
48+
max_per_img=100)))
49+
test_pipeline = [
50+
dict(type='LoadImageFromFile'),
51+
dict(type='MultiScaleFlipAug',
52+
img_scale=(1333, 800),
53+
flip=False,
54+
transforms=[
55+
dict(type='Resize', keep_ratio=True),
56+
dict(type='RandomFlip'),
57+
dict(type='Normalize',
58+
mean=[123.675, 116.28, 103.53],
59+
std=[58.395, 57.12, 57.375],
60+
to_rgb=True),
61+
dict(type='Pad', size_divisor=32),
62+
dict(type='ImageToTensor', keys=['img']),
63+
dict(type='Collect', keys=['img'])
64+
])
65+
]
66+
data = dict(test=dict(pipeline=test_pipeline))
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
model = dict(type='YOLOV3',
2+
backbone=dict(type='Darknet', depth=53, out_indices=(3, 4, 5)),
3+
neck=dict(type='YOLOV3Neck',
4+
num_scales=3,
5+
in_channels=[1024, 512, 256],
6+
out_channels=[512, 256, 128]),
7+
bbox_head=dict(type='YOLOV3Head',
8+
num_classes=1,
9+
in_channels=[512, 256, 128],
10+
out_channels=[1024, 512, 256],
11+
anchor_generator=dict(type='YOLOAnchorGenerator',
12+
base_sizes=[[(116, 90),
13+
(156, 198),
14+
(373, 326)],
15+
[(30, 61),
16+
(62, 45),
17+
(59, 119)],
18+
[(10, 13),
19+
(16, 30),
20+
(33, 23)]],
21+
strides=[32, 16, 8]),
22+
bbox_coder=dict(type='YOLOBBoxCoder'),
23+
featmap_strides=[32, 16, 8]),
24+
test_cfg=dict(nms_pre=1000,
25+
min_bbox_size=0,
26+
score_thr=0.05,
27+
conf_thr=0.005,
28+
nms=dict(type='nms', iou_threshold=0.45),
29+
max_per_img=100))
30+
test_pipeline = [
31+
dict(type='LoadImageFromFile'),
32+
dict(type='MultiScaleFlipAug',
33+
img_scale=(608, 608),
34+
flip=False,
35+
transforms=[
36+
dict(type='Resize', keep_ratio=True),
37+
dict(type='RandomFlip'),
38+
dict(type='Normalize',
39+
mean=[0, 0, 0],
40+
std=[255.0, 255.0, 255.0],
41+
to_rgb=True),
42+
dict(type='Pad', size_divisor=32),
43+
dict(type='ImageToTensor', keys=['img']),
44+
dict(type='Collect', keys=['img'])
45+
])
46+
]
47+
data = dict(test=dict(pipeline=test_pipeline))
Lines changed: 250 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,250 @@
1+
channel_cfg = dict(num_output_channels=28,
2+
dataset_joints=28,
3+
dataset_channel=[
4+
list(range(28)),
5+
],
6+
inference_channel=list(range(28)))
7+
8+
model = dict(
9+
type='TopDown',
10+
backbone=dict(type='HRNet',
11+
in_channels=3,
12+
extra=dict(stage1=dict(num_modules=1,
13+
num_branches=1,
14+
block='BOTTLENECK',
15+
num_blocks=(4, ),
16+
num_channels=(64, )),
17+
stage2=dict(num_modules=1,
18+
num_branches=2,
19+
block='BASIC',
20+
num_blocks=(4, 4),
21+
num_channels=(18, 36)),
22+
stage3=dict(num_modules=4,
23+
num_branches=3,
24+
block='BASIC',
25+
num_blocks=(4, 4, 4),
26+
num_channels=(18, 36, 72)),
27+
stage4=dict(num_modules=3,
28+
num_branches=4,
29+
block='BASIC',
30+
num_blocks=(4, 4, 4, 4),
31+
num_channels=(18, 36, 72, 144),
32+
multiscale_output=True),
33+
upsample=dict(mode='bilinear',
34+
align_corners=False))),
35+
keypoint_head=dict(type='TopdownHeatmapSimpleHead',
36+
in_channels=[18, 36, 72, 144],
37+
in_index=(0, 1, 2, 3),
38+
input_transform='resize_concat',
39+
out_channels=channel_cfg['num_output_channels'],
40+
num_deconv_layers=0,
41+
extra=dict(final_conv_kernel=1,
42+
num_conv_layers=1,
43+
num_conv_kernels=(1, )),
44+
loss_keypoint=dict(type='JointsMSELoss',
45+
use_target_weight=True)),
46+
test_cfg=dict(flip_test=True,
47+
post_process='unbiased',
48+
shift_heatmap=True,
49+
modulate_kernel=11))
50+
51+
data_cfg = dict(image_size=[256, 256],
52+
heatmap_size=[64, 64],
53+
num_output_channels=channel_cfg['num_output_channels'],
54+
num_joints=channel_cfg['dataset_joints'],
55+
dataset_channel=channel_cfg['dataset_channel'],
56+
inference_channel=channel_cfg['inference_channel'])
57+
58+
test_pipeline = [
59+
dict(type='LoadImageFromFile'),
60+
dict(type='TopDownAffine'),
61+
dict(type='ToTensor'),
62+
dict(type='NormalizeTensor',
63+
mean=[0.485, 0.456, 0.406],
64+
std=[0.229, 0.224, 0.225]),
65+
dict(type='Collect',
66+
keys=['img'],
67+
meta_keys=['image_file', 'center', 'scale', 'rotation',
68+
'flip_pairs']),
69+
]
70+
71+
dataset_info = dict(dataset_name='anime_face',
72+
paper_info=dict(),
73+
keypoint_info={
74+
0:
75+
dict(name='kpt-0',
76+
id=0,
77+
color=[255, 255, 255],
78+
type='',
79+
swap='kpt-4'),
80+
1:
81+
dict(name='kpt-1',
82+
id=1,
83+
color=[255, 255, 255],
84+
type='',
85+
swap='kpt-3'),
86+
2:
87+
dict(name='kpt-2',
88+
id=2,
89+
color=[255, 255, 255],
90+
type='',
91+
swap=''),
92+
3:
93+
dict(name='kpt-3',
94+
id=3,
95+
color=[255, 255, 255],
96+
type='',
97+
swap='kpt-1'),
98+
4:
99+
dict(name='kpt-4',
100+
id=4,
101+
color=[255, 255, 255],
102+
type='',
103+
swap='kpt-0'),
104+
5:
105+
dict(name='kpt-5',
106+
id=5,
107+
color=[255, 255, 255],
108+
type='',
109+
swap='kpt-10'),
110+
6:
111+
dict(name='kpt-6',
112+
id=6,
113+
color=[255, 255, 255],
114+
type='',
115+
swap='kpt-9'),
116+
7:
117+
dict(name='kpt-7',
118+
id=7,
119+
color=[255, 255, 255],
120+
type='',
121+
swap='kpt-8'),
122+
8:
123+
dict(name='kpt-8',
124+
id=8,
125+
color=[255, 255, 255],
126+
type='',
127+
swap='kpt-7'),
128+
9:
129+
dict(name='kpt-9',
130+
id=9,
131+
color=[255, 255, 255],
132+
type='',
133+
swap='kpt-6'),
134+
10:
135+
dict(name='kpt-10',
136+
id=10,
137+
color=[255, 255, 255],
138+
type='',
139+
swap='kpt-5'),
140+
11:
141+
dict(name='kpt-11',
142+
id=11,
143+
color=[255, 255, 255],
144+
type='',
145+
swap='kpt-19'),
146+
12:
147+
dict(name='kpt-12',
148+
id=12,
149+
color=[255, 255, 255],
150+
type='',
151+
swap='kpt-18'),
152+
13:
153+
dict(name='kpt-13',
154+
id=13,
155+
color=[255, 255, 255],
156+
type='',
157+
swap='kpt-17'),
158+
14:
159+
dict(name='kpt-14',
160+
id=14,
161+
color=[255, 255, 255],
162+
type='',
163+
swap='kpt-22'),
164+
15:
165+
dict(name='kpt-15',
166+
id=15,
167+
color=[255, 255, 255],
168+
type='',
169+
swap='kpt-21'),
170+
16:
171+
dict(name='kpt-16',
172+
id=16,
173+
color=[255, 255, 255],
174+
type='',
175+
swap='kpt-20'),
176+
17:
177+
dict(name='kpt-17',
178+
id=17,
179+
color=[255, 255, 255],
180+
type='',
181+
swap='kpt-13'),
182+
18:
183+
dict(name='kpt-18',
184+
id=18,
185+
color=[255, 255, 255],
186+
type='',
187+
swap='kpt-12'),
188+
19:
189+
dict(name='kpt-19',
190+
id=19,
191+
color=[255, 255, 255],
192+
type='',
193+
swap='kpt-11'),
194+
20:
195+
dict(name='kpt-20',
196+
id=20,
197+
color=[255, 255, 255],
198+
type='',
199+
swap='kpt-16'),
200+
21:
201+
dict(name='kpt-21',
202+
id=21,
203+
color=[255, 255, 255],
204+
type='',
205+
swap='kpt-15'),
206+
22:
207+
dict(name='kpt-22',
208+
id=22,
209+
color=[255, 255, 255],
210+
type='',
211+
swap='kpt-14'),
212+
23:
213+
dict(name='kpt-23',
214+
id=23,
215+
color=[255, 255, 255],
216+
type='',
217+
swap=''),
218+
24:
219+
dict(name='kpt-24',
220+
id=24,
221+
color=[255, 255, 255],
222+
type='',
223+
swap='kpt-26'),
224+
25:
225+
dict(name='kpt-25',
226+
id=25,
227+
color=[255, 255, 255],
228+
type='',
229+
swap=''),
230+
26:
231+
dict(name='kpt-26',
232+
id=26,
233+
color=[255, 255, 255],
234+
type='',
235+
swap='kpt-24'),
236+
27:
237+
dict(name='kpt-27',
238+
id=27,
239+
color=[255, 255, 255],
240+
type='',
241+
swap='')
242+
},
243+
skeleton_info={},
244+
joint_weights=[1.] * 28,
245+
sigmas=[])
246+
247+
data = dict(test=dict(type='',
248+
data_cfg=data_cfg,
249+
pipeline=test_pipeline,
250+
dataset_info=dataset_info), )

0 commit comments

Comments
 (0)