-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
29 lines (23 loc) · 784 Bytes
/
run.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
import argparse
import cv2
from model import Model
model = Model()
image = cv2.imread('./your_image.jpg')
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
label = model.predict(image=image)['label']
print('Image label is: ', label)
def argument_parser():
parser = argparse.ArgumentParser(description="Violence detection")
parser.add_argument('--image-path', type=str,
default='./data/7.jpg',
help='path to your image')
args = parser.parse_args()
return args
if __name__ == '__main__':
args = argument_parser()
model = Model()
image = cv2.imread(args.image_path)
label = model.predict(image=image)['label']
print('predicted label: ', label)
cv2.imshow(label.title(), image)
cv2.waitKey(0)