Skip to content

Commit 5d57c7f

Browse files
authored
Create test_detector-01.py
1 parent c162328 commit 5d57c7f

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Created on Mon Jul 26 14:26:27 2021
4+
@author: xiuzhang
5+
"""
6+
7+
from imageai.Detection import ObjectDetection
8+
9+
#实例化
10+
detector = ObjectDetection()
11+
12+
#路径定义
13+
model_path = "./models/yolo-tiny.h5"
14+
input_path = "./input/person-02.png"
15+
output_path = "./output/person-02.png"
16+
17+
#预训练模式
18+
detector.setModelTypeAsTinyYOLOv3()
19+
20+
#设置预训练模型路径
21+
detector.setModelPath(model_path)
22+
23+
#加载模型
24+
detector.loadModel()
25+
26+
#创建对象
27+
detection = detector.detectObjectsFromImage(input_image=input_path,
28+
output_image_path=output_path)
29+
30+
#检测结果
31+
for eachItem in detection:
32+
print(eachItem["name"] , " : ", eachItem["percentage_probability"])
33+
34+

0 commit comments

Comments
 (0)