-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathObjectDetection.py
More file actions
23 lines (17 loc) · 1.09 KB
/
Copy pathObjectDetection.py
File metadata and controls
23 lines (17 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import test_simple
from imageai.Detection import ObjectDetection
import os
execution_path = os.getcwd()
detector = ObjectDetection()
detector.setModelTypeAsRetinaNet()
detector.setModelPath( os.path.join(execution_path + '\\models' , "resnet50_coco_best_v2.0.1.h5"))
detector.loadModel()
pictureName = 'image1'
detections = detector.detectObjectsFromImage(input_image=os.path.join(execution_path + '\\assets', pictureName + ".jpg"), output_image_path=os.path.join(execution_path + '\\assets', pictureName + "new.jpg"))
pictureName = 'image2'
detections = detector.detectObjectsFromImage(input_image=os.path.join(execution_path + '\\assets', pictureName + ".jpg"), output_image_path=os.path.join(execution_path + '\\assets', pictureName + "new.jpg"))
pictureName = 'image3'
detections = detector.detectObjectsFromImage(input_image=os.path.join(execution_path + '\\assets', pictureName + ".jpg"), output_image_path=os.path.join(execution_path + '\\assets', pictureName + "new.jpg"))
for eachObject in detections:
print(eachObject["name"] , " : " , eachObject["percentage_probability"] )
print(detections)