-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdetect_images.py
executable file
·57 lines (44 loc) · 1.59 KB
/
detect_images.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
import time
from argparse import ArgumentParser
from utils import parse_args_from_txt
from images import imwrite
def arg_builder():
arg_parser = ArgumentParser()
arg_parser.add_argument('-ncs', '--use_ncs',
help='whether to infer on the Intels\'NCS\
(default to False)',
default=False,
type=bool)
arg_parser.add_argument('-c', '--config',
help='path to the model config file\
(default to data/config/yolov3_full_416.cfg)',
default='data/config/yolov3_full_416.cfg',
type=str)
arg_parser.add_argument('-p', '--image_path',
help='path to image or directory of images to predict\
(default to data/images/)',
default='data/images/',
type=str)
return arg_parser.parse_args()
args = arg_builder()
model_args = parse_args_from_txt(args.config)
input_sz = model_args['width'], model_args['height']
if args.use_ncs:
from yolow_ncs import YolowNCS
yl = YolowNCS(model_args['model_name_path'],
input_sz,
model_args['labels'])
yl.set_input(args.image_path)
else:
from yolow import Yolow
yl = Yolow(model_args['type'],
model_args['model'],
model_args['anchors'],
model_args['num_classes'],
input_sz,
model_args['labels'])
yl.set_input(args.image_path)
start = time.time()
outs = yl.predict()
print('prediction takes {}s'.format(time.time() - start))
imwrite(outs)