imageAI基本使用
1、通过imageai.Detection做对象检测
其中, resnet50_coco_best_v2.0.1.h5 可通过 http://link.zhihu.com/?target=https%3A//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()
# 设置检测器的网络类型为resnet
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, 'test.jpg'),output_image_path=os.path.join(execution_path, 'result.jpg'))
# 输出检测到的对象及相应的置信度
for object in detections:print('name:' + object['name'] + " " + 'probability:' + object['percentage_probability'])
原图:
结果:
name:person probability:80.5445909500122
name:person probability:90.69478511810303
name:car probability:95.79920172691345
2、通过imageai.Prediction做对象检测
其中, resnet50_weights_tf_dim_ordering_tf_kernels.h5 可通过https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/resnet50_weights_tf_dim_ordering_tf_kernels.h5进行下载。
示例代码:
from imageai.Prediction import ImagePrediction
import os# 获取当前路径
execution_path = os.getcwd()
# 初始化预测器
predictor = ImagePrediction()
# 设置预测器的网络类型为resnet
predictor.setModelTypeAsResNet()
# 导入模型权值文件
predictor.setModelPath(os.path.join(execution_path, 'resnet50_weights_tf_dim_ordering_tf_kernels.h5'))
# 加载模型
predictor.loadModel()
# 对图片进行测试并输出测试结果
predictions, probabilities = predictor.predictImage(os.path.join(execution_path, 'test.jpg'), result_count=5)
# 输出预测到的对象及相应的置信度
for prediction, probability in zip(predictions, probabilities):print('name:' + prediction + " " + 'probability:' + probability)
原图:
结果:
name:sports_car probability:72.6273238658905
name:tow_truck probability:7.000575959682465
name:racer probability:4.8392243683338165
name:convertible probability:4.6900734305381775
name:car_wheel probability:3.936982899904251
识别网络:
- SqueezeNet(预测速度最快 正确率中等)
- ResNet50 (预测速度快 正确率较高)
- InceptionV3(预测速度慢 正确率高)
DenseNet121(预测速度更慢 正确率最高)
欢迎关注我的公众号:
编程技术与生活(ID:hw_cchang)
imageAI基本使用相关推荐
- GitHub开源的ImageAI 库:几行代码可实现目标对象识别
目录 1.图像预测 2.物体检测 3.视频对象检测和跟踪 ImageAI是一个Python库,旨在使开发人员能够使用简单的几行代码构建具有自包含深度学习和计算机视觉功能的应用程序和系统. ...
- 深度学习和目标检测系列教程 2-300:小试牛刀,使用 ImageAI 进行对象检测
@Author:Runsen 对象检测是一种属于更广泛的计算机视觉领域的技术.它处理识别和跟踪图像和视频中存在的对象.目标检测有多种应用,如人脸检测.车辆检测.行人计数.自动驾驶汽车.安全系统等.Im ...
- python目标识别代码_利用ImageAI库只需几行python代码超简实现目标检测
什么是目标检测 目标检测关注图像中特定的物体目标,需要同时解决解决定位(localization) + 识别(Recognition).相比分类,检测给出的是对图片前景和背景的理解,我们需要从背景中分 ...
- 利用 ImageAI 在 COCO 上学习目标检测
ImageAI是一个python库,旨在使开发人员能够使用简单的几行代码构建具有包含深度学习和计算机视觉功能的应用程序和系统. 这个 AI Commons 项目https://commons.spec ...
- tensorflow+imageai环境搭建到图像预测和图像侦测
下载 1.Anaconda和Pycharm的安装和配置https://www.cnblogs.com/yuxuefeng/articles/9235431.html 2.Conda update -a ...
- 如何借助ImageAI轻松实现目标检测(只需十行代码)
知乎转载https://www.zhihu.com/question/26483508/answer/447708695 只需10行Python代码,我们就能实现计算机视觉中目标检测. from im ...
- Colab下Imageai自定义模型训练和目标检测
本文运行再colab环境下 目录 本文运行再colab环境下 1.准备 a.库的安装 b.colab环境的准备 2.模型的训练 a.准备数据集 b.训练 3.通过模型进行目标检测 4.注意: 1.准备 ...
- ImageAI(1)——10行Python即可实现深度学习的识别和检测任务
这里写目录标题 1.什么是ImageAI 2.ImageAI安装 3.图像识别--Image Prediction 4.目标检测--Object Detection 5.实时检测--VideoObje ...
- 用ImageAI将普通视频转换为带目标检测的视频
之前我发表过一篇博客,是使用opencv将普通视频转为带人脸检测效果的视频 https://blog.csdn.net/luohualiushui1/article/details/86661501 ...
- 基于ImageAI的图像识别
博主简介 博主是一名大二学生,主攻人工智能研究.感谢让我们在CSDN相遇,博主致力于在这里分享关于人工智能,c++,Python,爬虫等方面知识的分享. 如果有需要的小伙伴可以关注博主,博主会继续更新 ...
最新文章
- 4月3日 尤金.卡巴斯基在北大精彩演讲
- Fail2ban初识
- 实操《深入浅出React和Redux》第二期—Flux
- jdk只有一个java进程_JDK 10:从Java访问Java应用程序的进程ID
- php感悟1500,《苏菲的世界》读书笔记及心得感悟1500字
- windows10 搜索桌面搜索功能失效的解决
- 2018年预测:GPU数据库或是未来的数据库统治者!
- stochastic noise and deterministic noise
- 天锐绿盾解密_天锐绿盾签约兴威 助力食品行业信息防泄漏
- 怎么取消linux ssh互信,[系统-linux] ssh互信操作
- 小白鼠测试---VR头戴设备-暴风魔镜4
- 《Android开发艺术探索》之Activity的生命周期和启动模式(一)
- 2d游戏中角色动画解决方案
- 支付宝出安全漏洞,买了账户安全险的也要小心
- 2010-04-20 代码复用、使用率情况分析
- android 电池监测工具,Battery Monitor Widget Pro(电池监测器)
- 阿里云——专有网络VPC
- 【Unity Shader编程】之十四 边缘发光Shader Rim Shader 的两种实现形态
- 中职组网络安全C模块全漏洞脚本讲解包含4个漏洞的脚本
- 《Adobe Acrobat DC经典教程》—第1章1.7节使用工具栏
热门文章
- 5步完成物联网小程序开发
- origin绘图过程的一些经验
- SIPp 安装及使用
- oracle临时表空间组
- 映美精相机(the imaging source)在树莓派(Raspberry Pi )中的使用(一)
- AD学习之旅(1)— Altium Designer 16 软件下载与安装
- 程序员必备75道逻辑思维题(附答案)之二
- 《我喜欢生命本来的样子》周国平 .mobi .epub .pdf .azw3 电子版下载 读书笔记
- matlab取平均值不含nan,在Matlab计算中忽略包含NaN条目的向量
- Python编写的疲劳检测系统(实时摄像头检测)