点击上方“计算机视觉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)
图像
运行输出:
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("--------------------------------")
运行输出:
github地址
https://github.com/OlafenwaMoses/ImageAI/
交流群
欢迎加入公众号读者群一起和同行交流,目前有SLAM、检测分割识别、三维视觉、医学影像、GAN、自动驾驶、计算摄影、算法竞赛等微信群(以后会逐渐细分),请扫描下面微信号加群,备注:”昵称+学校/公司+研究方向“,例如:”张三 + 上海交大 + 视觉SLAM“。请按照格式备注,否则不予通过。添加成功后会根据研究方向邀请进入相关微信群。请勿在群内发送广告,否则会请出群,谢谢理解~
投稿、合作也欢迎联系:simiter@126.com
长按关注计算机视觉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干货,我在看