-
Notifications
You must be signed in to change notification settings - Fork 4
/
face_agender.py
executable file
·83 lines (79 loc) · 2.27 KB
/
face_agender.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
import argparse
import platform
if platform.system() == 'Linux': # RaspberryPi
DEFAULT_HFLIP = True
DEFAULT_VFLIP = True
elif platform.system() == 'Darwin': # MacOS X
DEFAULT_HFLIP = False
DEFAULT_VFLIP = False
else:
raise NotImplementedError()
from src.config import Config
from src.detector import DetectorAgender
def main() -> None:
parser = argparse.ArgumentParser(
description="detect face and estimate age, gender"
)
parser.add_argument(
'--media', type=str, default=None,
help=(
'filename of image/video'
' (if not set, use streaming video from camera)'
)
)
parser.add_argument(
'--height', type=int, default=720,
help='camera image height'
)
parser.add_argument(
'--width', type=int, default=1280,
help='camera image width'
)
parser.add_argument(
'--hflip',
action='store_false' if DEFAULT_HFLIP else 'store_true',
help='flip horizontally'
)
parser.add_argument(
'--vflip',
action='store_false' if DEFAULT_VFLIP else 'store_true',
help='flip vertically'
)
parser.add_argument(
'--quant', type=str, default='fp32',
choices=['fp32', 'tpu'],
help='quantization mode (or use EdgeTPU)'
)
parser.add_argument(
'--target', type=str, default='all',
help='the target type of detecting object (default: all)'
)
parser.add_argument(
'--conf-threshold', type=float, default=0.5,
help='the confidence score threshold of NMS'
)
parser.add_argument(
'--fontsize', type=int, default=20,
help='fontsize to display'
)
parser.add_argument(
'--fastforward', type=int, default=1,
help=(
'frame interval for object detection'
' (default: 1 = detect every frame)'
)
)
args = parser.parse_args()
setattr(args, 'model', 'face')
config_detect = Config(**vars(args))
setattr(args, 'model', 'agender')
config_predict = Config(**vars(args))
detector = DetectorAgender(
config_detect=config_detect, config_predict=config_predict
)
detector.run()
return
if __name__ == '__main__':
main()