python ImageAI 物体检测

1.安装依赖
yum install mesa-libGL.x86_64

pip3 install tensorflow==2.4.0
pip3 install keras
pip3 install pandas
pip3 install numpy
pip3 install pillow
pip3 install scipy
pip3 install h5py
pip3 install matplotlib
pip3 install opencv-python
pip3 install keras-resnet
pip3 install imageai --upgrade
2.下载模型
# 下载一张图片
# wget -O image3.jpg  https://xxx/example.png
wget https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/yolo.h5
3.参考示例
from imageai.Detection import ObjectDetection
import os
import time

execution_path = os.getcwd()

detector = ObjectDetection()
# detector.setModelTypeAsRetinaNet()
detector.setModelTypeAsYOLOv3()

# 载入已训练好的文件
# detector.setModelPath( os.path.join(execution_path , "resnet50_coco_best_v2.1.0.h5"))
detector.setModelPath(os.path.join(execution_path, "yolo.h5"))
detector.loadModel()

# 将检测后的结果保存为新图片
detections = detector.detectObjectsFromImage(input_image=os.path.join(execution_path, "image1.jpg"),
                                             output_image_path=os.path.join(execution_path, "image3new.jpg"))


for eachObject in detections:
    print(eachObject["name"], " : ", eachObject["percentage_probability"], " : ",
          eachObject["box_points"])  ##预测物体名:预测概率:物体两点坐标(左上,右下)
    print("--------------------------------")

在这里插入图片描述
参考:https://blog.csdn.net/qingfengxd1/article/details/108203954
参考:https://imageai.readthedocs.io/en/latest/detection/
参考:https://blog.csdn.net/zkt286468541/article/details/81040274

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Cocktail_py

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值