opencv 4快速入门_使用ImageAI快速构建常见对象检测应用

点击上方“计算机视觉life”,选择“星标”

快速获得最新干货

ImageAI介绍

纯Python的快速对象检测训练与测试平台,基于tensorflow+opencv构建,支持

  • RetinaNet

  • YOLOv3

  • TinyYOLOv3

在COCO数据集上预训练模型的调用,同时支持自定义对象训练与导出。支持

  • 图像分类

  • 对象检测

  • 视频对象检测与跟踪

安装ImageAI

ImageAI的后台依赖tensorflow框架与keras,所以需要首先安装tensoflow,当前还不支持tensorflow2.0版本

  • tensorflow 1.4.x以上版本

  • opencv-python

安装imageai,只需要执行如下命令行即可

pip install imageai

代码演示

1. 图像分类

from imageai.Prediction import ImagePrediction
import os

execution_path = os.getcwd()

prediction = ImagePrediction()
prediction.setModelTypeAsResNet()
prediction.setModelPath(os.path.join(execution_path, "resnet50_weights_tf_dim_ordering_tf_kernels.h5"))
prediction.loadModel()

predictions, probabilities = prediction.predictImage(os.path.join(execution_path, "1.jpg"), result_count=5 )
for eachPrediction, eachProbability in zip(predictions, probabilities):
    print(eachPrediction , " : " , eachProbability)

图像

b8ca989130a6f431d83419f005e6abd9.png

运行输出:

convertible : 52.459555864334106
sports_car : 37.61284649372101
pickup : 3.1751200556755066
car_wheel : 1.817505806684494
minivan : 1.7487050965428352

2. 对象检测

from imageai.Detection import ObjectDetection
import os

execution_path = os.getcwd()

detector = ObjectDetection()
detector.setModelTypeAsYOLOv3()
detector.setModelPath( os.path.join(execution_path , "yolo.h5"))
detector.loadModel()
detections = detector.detectObjectsFromImage(input_image=os.path.join(execution_path , "image2.jpg"), output_image_path=os.path.join(execution_path , "image2new.jpg"), minimum_percentage_probability=30)

for eachObject in detections:
    print(eachObject["name"] , " : ", eachObject["percentage_probability"], " : ", eachObject["box_points"] )
    print("--------------------------------")

运行输出:

0aa625a38903a708d32ac1d993cd6f51.png

github地址

https://github.com/OlafenwaMoses/ImageAI/

交流群

欢迎加入公众号读者群一起和同行交流,目前有SLAM、检测分割识别、三维视觉、医学影像、GAN、自动驾驶、计算摄影、算法竞赛等微信群(以后会逐渐细分),请扫描下面微信号加群,备注:”昵称+学校/公司+研究方向“,例如:”张三 + 上海交大 + 视觉SLAM“。请按照格式备注,否则不予通过。添加成功后会根据研究方向邀请进入相关微信群。请勿在群内发送广告,否则会请出群,谢谢理解~

aea21780de58586f2331355d60e850b5.png

投稿、合作也欢迎联系:simiter@126.com

3592eb4123784d6df72417c665209248.png

长按关注计算机视觉life

推荐阅读

实战 | 相机标定

实战 | 图像矫正技术

实战 | Unity下ARKit与OpenCV的结晶

实战 | 基于SegNet和U-Net的遥感图像语义分割

实战 | 文字定位与切割

实战 | 源码入门之Faster RCNN

实战 | 自己实现扫描全能王

实战 | 用OpenCV轻松生成微信国庆版头像

实战 | OpenCV 实现多张图像拼接

实战 | OpenCV相机标定与畸变校正

实战 | 教你自动查找拍糊的图

实战 | 用 Python 给照片换色

我用MATLAB撸了一个2D LiDAR SLAM

实战 | 哪个瞬间让你突然觉得CV技术真有用?

干货 | 史上最全 OpenCV 活体检测教程

解决方案 | 如何用普通手机准确测量物体体积?

Mask-RCNN模型的实现自定义对象(无人机)检测

scikit-image图像处理入门

还在用肉眼找不同吗?这个技术轻松搞定

OpenCV测量物体的尺寸技能 get~

超详讲解图像拼接/全景图原理和应用 | 附源码

如何在实际中计划和执行一个机器/深度学习项目

8个计算机视觉深度学习中常见的Bug

最新AI干货,我在看  944019df18f521b68ca8688f43200a9d.gif

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值