10行代码实现目标检测

10行代码实现目标检测

原文地址:
1.https://blog.youkuaiyun.com/jiangjiang_jian/article/details/80781063
2.https://towardsdatascience.com/object-detection-with-10-lines-of-code-d6cb4d86f606
github地址:https://github.com/OlafenwaMoses/ImageAI


环境要求
库包名称下载
pythonhttps://www.anaconda.com/distribution/#download-section(anaconda下载地址)
Tensorflowpip install tensorflow
NumPypip install numpy
SciPypip install scipy
OpenCVpip install opencv-python
Pillowpip install pillow
Matplotlibpip install matplotlib
H5pypip install h5py
Keraspip install keras
ImageAIpip install https://github.com/OlafenwaMoses/ImageAI/releases/download/2.0.1/imageai-2.0.1-py3-none-any.whl
下载RetinaNet 模型文件

https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/resnet50_coco_best_v2.0.1.h5

运行代码
from imageai.Detection import ObjectDetection
import os
 
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.jpg"), output_image_path=os.path.join(execution_path , "imagenew.jpg"))
 
for eachObject in detections:
    print(eachObject["name"] + " : " + eachObject["percentage_probability"] )
测试图片

在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值