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图片分类
一.概述 通过之前两篇文章的学习,我们应该已经了解了多元分类的工作原理,图片的分类其流程和之前完全一致,其中最核心的问题就是特征的提取,只要完成特征提取,分类算法就很好处理了,具体流程如下: 之前介绍 ...
随机推荐
- 6_1.springboot2.x整合JDBC与数据源配置原理解析
1.引言 对于数据访问层,无论是SQL还是NOSQL,Spring Boot默认采用整合 Spring Data的方式进行统一处理,添加大量自动配置,屏蔽了很多设置.引入各种xxxTemplate,x ...
- Python - 作为浅拷贝的list对象乘法
运行下面这段代码 # !/usr/bin/env python3 # -*- coding=utf-8 -*- temp_a = [[0]*2]*3 temp_b = [[0]*2 for i in ...
- python三元运算符公式/出错怎么看
成功 if 条件 else 失败 Tip:问题要从下往上看,出问题的是最底下的问题,
- springcloud系列14 bus的使用
首先springcloud_bus原理: (1)完整流程:发送端(endpoint)构造事件event,将其publish到context上下文中(spring cloud bus有一个父上下文,bo ...
- Pyinstaller打包Web项目
最近需要用python打包一个单页面网页demo,于是准备用python包pyinstaller来打包程序.网上搜索了一下,大部分教程都是打包非web项目,这里分享一下打包简单网页demo的过程. 系 ...
- [NOIP2019模拟赛][AT2381] Nuske vs Phantom Thnook
题目链接 评测姬好快啊(港记号?)暴力40pts变成60pts 因为题目说了保证蓝色点两两之间只有一条路径,所以肯定组成了一棵树,而对于每次询问的x1,y1,x2,y2的子矩阵中就存在着一个森林 不难 ...
- python全栈开发:字符串格式化
Python的字符串格式化有两种方式: 百分号方式.format方式百分号的方式相对来说比较老,而format方式则是比较先进的方式,企图替换古老的方式,目前两者并存. 1.百分号方式 %[(name ...
- poj 2774 字符串哈希求最长公共子串
Long Long Message #include <iostream> #include <algorithm> #include <cstdio> #incl ...
- ROC曲线及AUC
ROC曲线 意义 ROC曲线指受试者工作特征曲线 / 接收器操作特性曲线(receiver operating characteristic curve),是反映敏感性和特异性连续变量的综合指标,是用 ...
- Linux CentOS CapsLock 大小写反转问题 解决
虚拟机centos7,输入大小写字母反了,开启capslock的时候变成小写字母了,关闭则变成大写了... 只需要执行 setleds +caps 或 setleds -caps 即可,如图: