tensorflow根据pb多bitch size去推导物体
with self.detection_graph.as_default():
with tf.Session(graph=self.detection_graph) as sess:
# Expand dimensions since the model expects images to have shape: [1, None, None, 3]
image_np_expanded = np.expand_dims(imageSerialized, axis=0)
image_tensor = self.detection_graph.get_tensor_by_name('image_tensor:0')
# Each box represents a part of the image where a particular object was detected.
boxes = self.detection_graph.get_tensor_by_name('detection_boxes:0')
# Each score represent how level of confidence for each of the objects.
# Score is shown on the result image, together with the class label.
scores = self.detection_graph.get_tensor_by_name('detection_scores:0')
classes = self.detection_graph.get_tensor_by_name('detection_classes:0')
num_detections = self.detection_graph.get_tensor_by_name('num_detections:0')
# Actual detection.
(boxes, scores, classes, num_detections) = sess.run(
[boxes, scores, classes, num_detections],
feed_dict={image_tensor: image_np_expanded})
boxesList.append([boxes,xmin,ymin])
scoresList.append(scores)
classesList.append(classes)
# extractBox.extractBoxMessage(
# RecognizeInfoList,
# boxMessageList,
# classNameList,
# RecognizeInfo,
# incisePictureWidth,
# incisePictureHeight,
# inciseXmin,
# inciseYmin,
# np.squeeze(boxes),
# np.squeeze(classes).astype(np.int32),
# np.squeeze(scores),
# min_score_thresh=0.5
# )
以及高效率不多次生成和关闭sess:
def _detector(self,imageSerializedList,boxesList,scoresList,classesList):
incisePictureWidth=self.beCheckedImageWidth
incisePictureHeight=self.beCheckedImageHeight
with self.detection_graph.as_default():
with tf.Session(graph=self.detection_graph) as sess:
# Expand dimensions since the model expects images to have shape: [1, None, None, 3] image_tensor = self.detection_graph.get_tensor_by_name('image_tensor:0')
# Each box represents a part of the image where a particular object was detected.
boxes = self.detection_graph.get_tensor_by_name('detection_boxes:0')
# Each score represent how level of confidence for each of the objects.
# Score is shown on the result image, together with the class label.
scores = self.detection_graph.get_tensor_by_name('detection_scores:0')
classes = self.detection_graph.get_tensor_by_name('detection_classes:0')
num_detections = self.detection_graph.get_tensor_by_name('num_detections:0')
# Actual detection.
for imageSerialized in imageSerializedList:
image_np_expanded = np.expand_dims(imageSerialized[0], axis=0)
(box, score, cla, num_detection) = sess.run(
[boxes, scores, classes, num_detections],
feed_dict={image_tensor: image_np_expanded})
boxesList.append([box,imageSerialized[1],imageSerialized[2]])
scoresList.append(score)
classesList.append(cla)
tensorflow根据pb多bitch size去推导物体的更多相关文章
- tensorflow打印pb、ckpt模型的参数以及在tensorboard里显示图结构
打印pb模型参数及可视化结构import tensorflow as tf from tensorflow.python.framework import graph_util tf.reset_de ...
- 将keras的h5模型转换为tensorflow的pb模型
h5_to_pb.py from keras.models import load_model import tensorflow as tf import os import os.path as ...
- tensorRT 使用tensorflow的pb问价构建推理
- tensorflow使用pb文件进行模型预测
- Tensorflow object detection API 搭建属于自己的物体识别模型
一.下载Tensorflow object detection API工程源码 网址:https://github.com/tensorflow/models,可通过Git下载,打开Git Bash, ...
- Tensorflow技巧
1.尽量控制图片大小在1024以内,不然显存会爆炸. 2.尽量使用多GPU并行工作,训练下降速度快. 3.当需要被检测的单张图片里物体太多时,记得修改Region_proposals的个数 4.测试的 ...
- OpenCV开发笔记(七十二):红胖子8分钟带你使用opencv+dnn+tensorFlow识别物体
前言 级联分类器的效果并不是很好,准确度相对深度学习较低,本章使用opencv通过tensorflow深度学习,检测已有模型的分类. Demo 可以猜测,1其实是人,18序号类是狗 ...
- TensorFlow object detection API应用--配置
目标检测在图形识别的基础上有了更进一步的应用,但是代码也更加繁琐,TensorFlow专门为此开设了一个object detection API,接下来看看怎么使用它. object detectio ...
- 机器学习框架ML.NET学习笔记【6】TensorFlow图片分类
一.概述 通过之前两篇文章的学习,我们应该已经了解了多元分类的工作原理,图片的分类其流程和之前完全一致,其中最核心的问题就是特征的提取,只要完成特征提取,分类算法就很好处理了,具体流程如下: 之前介绍 ...
随机推荐
- 一个因为系统字号设置导致的rem计算渲染异常问题
测试同学突然拿着一部手机过来说,H5渲染各个元素都变大了,有些元素撑出了屏幕外面. 本来以为是某个Webview的渲染兼容问题,结果发现所有的浏览器都这样. 莫名其妙,隐约感觉是 rem计算出了问题, ...
- ie6-8 avalon2 单页应用项目实战备忘
坑爹的ie,作为小组leader,尼玛,小伙伴儿们不乐意做的事情,我来做好了..心累... 如果,各位同学有定制开发ie6-8版本的需求,还是尽量不要用单页应用模式了,也不要用avalon这类mvvm ...
- 2day:Python基础
基础知识: 1.python文件的后缀名:.py 2 .Windows Python的执行方式:Python 解释器路径 py文件路径 例:C:\python3\python.exe d:\1.py ...
- 分享一份Java架构师学习资料,2019年最新整理!
分享一套不错的架构师学习参考资料,免费领取的,无任何套路! 关注Java大后端公众号,在后台回复关键字:大大,即可免费领取,觉得资料不错,转发给其他朋友呗- 长按关注Java大后端公众号领取.
- python语句结构(控制语句与pass语句)
python语句结构(控制语句和pass语句) break-跳出循环:语句可以跳出for和while语句的循环体.如果你从for和while循环中终止,任何对应循环的else语块均终止 continu ...
- Python数据格式化
Python有两种格式化字符串的方式,使用%或者使用内置format()函数. 使用%格式化字符串 在Python中使用%来格式化字符串,用法和效果类似于C语言中的%.格式为:%特定的转换类型 %da ...
- android 使用现成做get请求
//接受子线程发来的消息 Handler hanler = new Handler() { @Override public void handleMessage(Message msg) { // ...
- Android开发 SpannableString开发详解
前言 SpannableString,是google提供用来处理富文本的功能类.支持很多文本内容的效果变化.另外,它也是Android实现富文本编辑器的关键. 关键API详解 String conte ...
- mysql 一次性插入的数据量过大报错max_allowed_packet解决方法
查询: show VARIABLES like ‘%max_allowed_packet%‘; 记录下数字(默认是一个7位) 执行语句: ; 重启服务 再查询 该数字 ,如果没变,则修改mysql的m ...
- zabbix自动发现主机(转)
zabbix自动发现主机 2018年06月15日 18:02:52 loyal-Wang 阅读数:817更多 个人分类: zabbix 版权声明:本文为博主原创文章,转载请注明出处. https: ...