-
Notifications
You must be signed in to change notification settings - Fork 1
/
detector.py
52 lines (43 loc) · 1.43 KB
/
detector.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
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='System options')
parser.add_argument(
'source',
metavar='source type',
choices=['demo', 'cam', 'detect'],
type=str,
help='options: demo (video), cam (live cam), detect (image)',
)
parser.add_argument(
'system',
metavar='system type',
choices=['mask', 'distance'],
type=str,
help='options: mask, distance (social distancing)',
)
parser.add_argument(
'path',
metavar='source path',
type=str,
help='image path, video path, or cam source',
)
parser.add_argument(
'--tiny',
help='Set true to detect using YOLOv4-tiny',
default=False,
action='store_true'
)
args = vars(parser.parse_args())
if args['system'] == 'mask':
from yolo.yolo_mask import YoloMask
detector = YoloMask(args['tiny'])
if args['system'] == 'distance':
from yolo.yolo_social_distance import YoloSocialDistance
detector = YoloSocialDistance(args['tiny'])
if args['source'] == 'detect':
detector.detect_from_image(args['path'])
elif args['source'] == 'demo':
detector.detect_from_video(args['path'])
elif args['source'] == 'cam':
args['path'] = int(args['path'])
detector.detect_from_video(args['path'])