-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFirstdetection.py
More file actions
22 lines (16 loc) · 810 Bytes
/
Firstdetection.py
File metadata and controls
22 lines (16 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from imageai.Detection import ObjectDetection
import os
import numpy as np
import matplotlib.pyplot
execution_path = os.getcwd()
detector = ObjectDetection()
detector.setModelTypeAsRetinaNet()
detector.setModelPath( os.path.join(execution_path , "resnet50_coco_best_v2.0.1.h5"))
detector.loadModel()
detections = detector.detectObjectsFromImage(input_image=os.path.join(execution_path , "image.jpeg"), output_image_path=os.path.join(execution_path , "imagenew.jpg"))
#print(detector.detectObjectsFromImage(input_image=os.path.join(execution_path , "image.jpeg"), output_image_path=os.path.join(execution_path , "imagenew.jpg")))
ct=0
for eachObject in detections:
print(eachObject["name"] , " : " , eachObject["percentage_probability"] )
# print(eachObject["percentage_probability"])
#print(list)