-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobjD.py
More file actions
26 lines (20 loc) · 717 Bytes
/
objD.py
File metadata and controls
26 lines (20 loc) · 717 Bytes
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
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt
from imageai.Detection import ObjectDetection
import os
workdir = os.getcwd()
find_objects = ObjectDetection()
find_objects.setModelTypeAsRetinaNet()
# Use a pre-trained model.
# Don't reinvent the wheel. Either use it, or improve it.
find_objects.setModelPath(
os.path.join(
workdir,
"resnet50_coco_best_v2.1.0.h5"))
find_objects.loadModel()
objects_found = find_objects.detectObjectsFromImage(
input_image=os.path.join(workdir, "ilia.jpg"),
output_image_path=os.path.join(workdir, "iliaRevealed.jpg"))
for objects in objects_found:
print(objects["name"] + " : " + str(objects["percentage_probability"]))