Win10调试ssd_tensorflow的目标检测

1、环境:win10+tensorflow-gpu==1.14.0

2、下载代码:到https://github.com/balancap/SSD-Tensorflow到本地

3、解压代码,并将checkpoints下的ssd_300_vgg.ckpt.zip进行解压在checkpoints目录下。否则后果不堪设想

4、如果你的电脑装有jupyter notebook.则将此SSD-Tensorflow文件复制在jupyter文件目录下,然后启动jupyter notebook。

      打开notebooks下的ssd_notebook.ipynb文件,运行每个cell。

      也可以将此ipynb下的所有代码复制在SSD_Tensorflow目录新建的ssd_python.py中,运行

      也可以直接搜网上教程,新建py文件,复制代码,然后运行。

这个附上我复制的代码:(切记修改路径ckpt_file)

# coding: utf-8
# In[1]:import os
import math
import randomimport numpy as np
import tensorflow as tf
import cv2slim = tf.contrib.slim# In[2]:
import matplotlib.pyplot as plt
import matplotlib.image as mpimg# In[3]:import syssys.path.append('./')# In[4]:from nets import ssd_vgg_300, ssd_common, np_methods
from preprocessing import ssd_vgg_preprocessing
from notebooks import visualization# In[5]:# TensorFlow session: grow memory when needed. TF, DO NOT USE ALL MY GPU MEMORY!!!
gpu_options = tf.GPUOptions(allow_growth=True)
config = tf.ConfigProto(log_device_placement=False, gpu_options=gpu_options)
isess = tf.InteractiveSession(config=config)# ## SSD 300 Model
#
# The SSD 300 network takes 300x300 image inputs. In order to feed any image, the latter is resize to this input shape (i.e.`Resize.WARP_RESIZE`). Note that even though it may change the ratio width / height, the SSD model performs well on resized images (and it is the default behaviour in the original Caffe implementation).
#
# SSD anchors correspond to the default bounding boxes encoded in the network. The SSD net output provides offset on the coordinates and dimensions of these anchors.# In[6]:# Input placeholder.
net_shape = (300, 300)
data_format = 'NHWC'
img_input = tf.placeholder(tf.uint8, shape=(None, None, 3))
# Evaluation pre-processing: resize to SSD net shape.
image_pre, labels_pre, bboxes_pre, bbox_img = ssd_vgg_preprocessing.preprocess_for_eval(img_input, None, None, net_shape, data_format, resize=ssd_vgg_preprocessing.Resize.WARP_RESIZE)
image_4d = tf.expand_dims(image_pre, 0)# Define the SSD model.
reuse = True if 'ssd_net' in locals() else None
ssd_net = ssd_vgg_300.SSDNet()
with slim.arg_scope(ssd_net.arg_scope(data_format=data_format)):predictions, localisations, _, _ = ssd_net.net(image_4d, is_training=False, reuse=reuse)# Restore SSD model.
ckpt_filename = 'E:\gitcode\ssd\chde222-SSD-Tensorflow-master\SSD-Tensorflow\checkpoints/ssd_300_vgg.ckpt'
# ckpt_filename = '../checkpoints/VGG_VOC0712_SSD_300x300_ft_iter_120000.ckpt'
isess.run(tf.global_variables_initializer())
saver = tf.train.Saver()
saver.restore(isess, ckpt_filename)# SSD default anchor boxes.
ssd_anchors = ssd_net.anchors(net_shape)# ## Post-processing pipeline
#
# The SSD outputs need to be post-processed to provide proper detections. Namely, we follow these common steps:
#
# * Select boxes above a classification threshold;
# * Clip boxes to the image shape;
# * Apply the Non-Maximum-Selection algorithm: fuse together boxes whose Jaccard score > threshold;
# * If necessary, resize bounding boxes to original image shape.# In[7]:# Main image processing routine.
def process_image(img, select_threshold=0.5, nms_threshold=.45, net_shape=(300, 300)):# Run SSD network.rimg, rpredictions, rlocalisations, rbbox_img = isess.run([image_4d, predictions, localisations, bbox_img],feed_dict={img_input: img})# Get classes and bboxes from the net outputs.rclasses, rscores, rbboxes = np_methods.ssd_bboxes_select(rpredictions, rlocalisations, ssd_anchors,select_threshold=select_threshold, img_shape=net_shape, num_classes=21, decode=True)rbboxes = np_methods.bboxes_clip(rbbox_img, rbboxes)rclasses, rscores, rbboxes = np_methods.bboxes_sort(rclasses, rscores, rbboxes, top_k=400)rclasses, rscores, rbboxes = np_methods.bboxes_nms(rclasses, rscores, rbboxes, nms_threshold=nms_threshold)# Resize bboxes to original image shape. Note: useless for Resize.WARP!rbboxes = np_methods.bboxes_resize(rbbox_img, rbboxes)return rclasses, rscores, rbboxes# In[21]:# Test on some demo image and visualize output.
path = 'E:/gitcode/ssd/chde222-SSD-Tensorflow-master/SSD-Tensorflow/demo/'
image_names = sorted(os.listdir(path))img = mpimg.imread(path + image_names[-1])
rclasses, rscores, rbboxes = process_image(img)# visualization.bboxes_draw_on_img(img, rclasses, rscores, rbboxes, visualization.colors_plasma)
visualization.plt_bboxes(img, rclasses, rscores, rbboxes)

运行结果:

参考自https://blog.csdn.net/hezuo1181/article/details/91380182

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/567794.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

计算机基础cpu知识,CPU基础知识大全详解

CPU基础知识大全详解有哪些?CPU在电脑中是最核心关键的硬件之一,相当于人的大脑,决定了电脑运算能力,因此CPU的选择至关重要。下面就让小编带你去看看CPU基础知识大全详解,希望对你有所帮助吧!程序员必须了解的CPU知识…

c++ 不插入重复元素但也不排序_面试官爱问的 10 大经典排序算法,20+ 张图来搞定...

(给算法爱好者加星标,修炼编程内功)作者:技术让梦想更伟大 / 李肖遥 (本文来自作者投稿)冒泡排序简介冒泡排序是因为越小的元素会经由交换以升序或降序的方式慢慢浮到数列的顶端,就如同碳酸饮料中二氧化碳的气泡最终会上浮到顶端一样&#xf…

基础功能2-python修改文件中所有文件名

将policeImage中的所有图片命名为000001.jpg,000002.jpg等形式 import os path F:/vocDataset/policeImage files os.listdir(path) preindex for i, file in enumerate(files):if i>0 and i<9:preindex00000elif i>9 and i<99:preindex0000elif i>99 and i&…

计算机硬件操作系统应用软件之间的关系,操作系统是其他应用软件运行的基础,什么是操作系统...

简单理解操作系统就是一个人与计算机硬件之间的中介。打个比喻&#xff0c;没有操作系统的机器就像是没有用的砖头一样&#xff0c;而有操作系统的机器就是可以玩的砖头。 (推荐学习&#xff1a;phpstorm)操作系统&#xff0c;英文名称Operating System&#xff0c;简称OS&…

matplotlib 横坐标少了一个点_收藏起来!比 matplotlib 效率高十倍的数据可视化神器!...

点击上方“涛哥聊Python”&#xff0c;选择“星标”公众号作者&#xff1a;Will Koehrsen图文投稿&#xff1a;Allen编辑&#xff1a;Kooyee原文链接&#xff1a;https://towardsdatascience.com/the-next-level-of-data-visualization-in-python-dd6e99039d5e其他&#xff1a;…

ssd训练自己数据集

1、用labelImg标数据 2、将数据转换为tfrecord 错误记录&#xff1a; NotFoundError&#xff1a;无法创建NewWriteableFile 解决方法&#xff1a;您需要在运行此脚本的运行环境文件夹中自己创建一个目录 1、前期准备工作 第一步&#xff1a;先将SSD框架下载到本地&#…

计算机网络技术三级做题技巧,三级网络技术——我的经历,我的技巧

作者&#xff1a;liyunfei大家好&#xff0c;我是华北工学院的&#xff0c;专业是经济学。马上就要上大四了&#xff0c;现在已经拿到三级证书。作为过来人&#xff0c;对于网络考试&#xff0c;我有一些自己的感受&#xff0c;想和大家做个交流&#xff0c;供正在努力中的朋友…

elasticsearch date_MySQL数据实时增量同步到Elasticsearch

Mysql到Elasticsearch的数据同步&#xff0c;一般用ETL来实现&#xff0c;但性能并不理想&#xff0c;目前大部分的ETL是定时查询Mysql数据库有没有新增数据或者修改数据&#xff0c;如果数据量小影响不大&#xff0c;但如果几百万上千万的数据量性能就明显的下降很多&#xff…

联想计算机不能进入系统桌面,联想笔记本进不去桌面的解决方法

联想笔记本进不去桌面的解决方法笔记本电脑开机后&#xff0c;电源指示灯亮&#xff0c;显示器屏如果有显示&#xff0c;但进不了系统&#xff0c;这种情况多数是系统故障导致的&#xff0c;可以尝试开机按F8键&#xff0c;进入安全模式&#xff0c;然后进入最后一次安全配置进…

springboot jpa sql打印_SpringBoot集成Spring Data JPA以及读写分离

相关代码:github OSCchinaJPA是什么JPA(Java Persistence API)是Sun官方提出的Java持久化规范,它为Java开发人员提供了一种对象/关联映射工具 来管理Java应用中的关系数据.它包括以下几方面的内容:1.ORM映射 支持xml和注解方式建立实体与表之间的映射.2.Java持久化API 定义了一…

win10 make命令的安装

1、下载MinGWMinGW官网下载&#xff1a;http://www.mingw.org &#xff0c;点击右上角Downloads 或者网盘下载&#xff1a;链接&#xff1a;https://pan.baidu.com/s/1vQVKycK1TKVsnLV_OMgiCg 提取码&#xff1a;bbhl 点击下载 mingw-get-setup.exe 安装 mingw-get-setup.exe…

html中svg的css,HTML5 内联 SVG

什么是SVG&#xff1f;SVG 指可伸缩矢量图形 (Scalable Vector Graphics)SVG 用于定义用于网络的基于矢量的图形SVG 使用 XML 格式定义图形SVG 图像在放大或改变尺寸的情况下其图形质量不会有损失SVG 是万维网联盟的标准SVG 的优势与其他图像格式相比(比如 JPEG 和 GIF)&#x…

fast-rcnn win10 tensorflow部署

1、下载代码https://github.com/chde222/Faster-RCNN-TensorFlow-Python3 2、安装所依赖包 pip install -r requirements.txt 或者单独利用pip install cython pip install easydict 3、在 ./data/coco/pythonAPI 下打开cmd运行&#xff1a; python setup.py build_ext --in…

如何找到python的安装路径_如何查看python的安装路径

展开全部 官方文档上有写的&#xff0c;sys.executable是当前Python解释器&#xff08;或者其他Python实现&#xff09;的路径。 1、安装mysql 首先到mysql官网e68a843231313335323631343130323136353331333365643662下载文件&#xff1a;mysql-installer-community.msi 安装过…

两个html之间传递对象,解决微信警告:该链接含有无法解析的地址链接-两个html之间的传值(JSON数据)...

最近微信公众号开发进入二期了&#xff0c;增添关于汽车租赁的商城模块。遇到界面传值数据问题。1.首先我用的方式是&#xff1a;location.href"sales-detail.html?id"escape(JSON.stringify(htmlObj));另外&#xff0c;在第二界面用&#xff1a;var obj JSON.parse…

vue 获取url地址的参数_Vue之vuerouter的使用

1. 什么是vue-router?所谓的vue-router, 通俗的来讲 就是路由 但是这个和后端路由是不同的, 这是前端路由,是url和单页面组件的对应关系, 也就是SPA(单页应用)的路径管理器。再通俗的说&#xff0c;vue-router就是WebApp的链接路径管理系统。vue-router是Vue.js官方的路由插件…

win10下openpose1.5安装

历经一个星期的安装挫折&#xff0c;终于安装成功了。赶紧记录一下。 1、准备所需资料 &#xff08;1&#xff09;下载cuda和cudnn。版本最好都是cuda10和cudnn10.我下载的是下图所示版本。 如果不是这个版本可能会出错&#xff0c;而且出错几率很高。本人就因为安装的cuda10…

div展示html文本,html – 使文本适合div

我一直在努力重新创建我在90年代创建的父亲网站(呃),我一直无法让文本适合div内部并水平对齐.我需要将文本放在一起,以便它们适合div.这是jsfiddle中页面的代码示例HTMLHomeInside StaffOur Mission示例CSSdiv img#header{width: 50%;height: 15%;margin-left: 125px;margin-ri…

ImportError: cannot import name 'pyopenpose' from 'openpose'错误解决方法

前提条件&#xff1a;openpose1.5配置过程前面都成功&#xff0c;c api成功运行&#xff0c;但是python api配置中&#xff0c;cmake也添加了build_python_path.运行中仍出现 ImportError: cannot import name pyopenpose from openpose 这个错误。 解决方法&#xff1a; 将你…

python语句join_详解Python中的join()函数的用法

原博文 2017-08-07 20:51 − 函数&#xff1a;string.join() Python中有join()和os.path.join()两个函数&#xff0c;具体作用如下&#xff1a; join()&#xff1a; 连接字符串数组。将字符串、元组、列表中的元素以指定的字符(分隔符)连接生成一个新的字符串 &n...0584 相…