-
大小: 6KB文件类型: .py金币: 2下载: 1 次发布日期: 2021-06-07
- 语言: Python
- 标签: TensorFlow 视频 目标检测
资源简介
配置及运行文章见http://blog.csdn.net/asukasmallriver/article/details/78696260
代码片段和文件信息
# coding: utf-8
# # object Detection Demo
# Welcome to the object detection inference walkthrough! This notebook will walk you step by step through the process of using a pre-trained model to detect objects in an image. Make sure to follow the [installation instructions](https://github.com/tensorflow/models/blob/master/object_detection/g3doc/installation.md) before you start.
# # Imports
# In[1]:
import numpy as np
import os
import six.moves.urllib as urllib
import sys
import tarfile
import tensorflow as tf
import zipfile
from collections import defaultdict
from io import StringIO
from matplotlib import pyplot as plt
from PIL import Image
import cv2 #add 20170825
cap = cv2.VideoCapture(0) #add 20170825
# ## Env setup
# In[2]: #delete 20170825
# This is needed to display the images. #delete 20170825
#get_ipython().magic(‘matplotlib inline‘) #delete 20170825
# This is needed since the notebook is stored in the object_detection folder.
sys.path.append(“..“)
# ## object detection imports
# Here are the imports from the object detection module.
# In[3]:
from utils import label_map_util
from utils import visualization_utils as vis_util
# # Model preparation
# ## Variables
#
# Any model exported using the ‘export_inference_graph.py‘ tool can be loaded here simply by changing ‘PATH_TO_CKPT‘ to point to a new .pb file.
#
# By default we use an “SSD with Mobilenet“ model here. See the [detection model zoo](https://github.com/tensorflow/models/blob/master/object_detection/g3doc/detection_model_zoo.md) for a list of other models that can be run out-of-the-box with varying speeds and accuracies.
# In[4]:
# What model to download.
MODEL_NAME = ‘ssd_mobilenet_v1_coco_11_06_2017‘
#MODEL_NAME = ‘faster_rcnn_resnet101_coco_11_06_2017‘
#MODEL_NAME = ‘ssd_inception_v2_coco_11_06_2017‘
MODEL_FILE = MODEL_NAME + ‘.tar.gz‘
DOWNLOAD_base = ‘http://download.tensorflow.org/models/object_detection/‘
# Path to frozen detection graph. This is the actual model that is used for the object detection.
PATH_TO_CKPT = MODEL_NAME + ‘/frozen_inference_graph.pb‘
# List of the strings that is used to add correct label for each box.
PATH_TO_LABELS = os.path.join(‘data‘ ‘mscoco_label_map.pbtxt‘)
NUM_CLASSES = 90
# ## Download Model
# In[5]:
opener = urllib.request.URLopener()
opener.retrieve(DOWNLOAD_base + MODEL_FILE MODEL_FILE)
tar_file = tarfile.open(MODEL_FILE)
for file in tar_file.getmembers():
file_name = os.path.basename(file.name)
if ‘frozen_inference_graph.pb‘ in file_name:
tar_file.extract(file os.getcwd())
# ## Load a (frozen) Tensorflow model into memory.
# In[6]:
detection_graph = tf.Graph()
with detection_gra
相关资源
- tensorflow制作自己的灰度图像数据集并
- 深度学习视频中的行为识别
- Python-使用DeepFakes实现YouTube视频自动换
- Mofan莫烦python全部教程代码
- 一套最新价值1680元的python爬虫实战全
- 测试工程师相关学习视频(包含pyth
- 093 2018北风网人工智能视频(完结)转
- anaconda下安装tensorflow(注:不同版本
- 北京大学曹健老师-人工智能实践:
- Deep Learning With Python - Jason Brownlee
- Python-自然场景文本检测PSENet的一个
- Python-高效准确的EAST文本检测器的一个
- Python-TensorFlow弱监督图像分割
- Python-基于tensorflow实现的用textcnn方法
- Python-subpixel利用Tensorflow的一个子像素
- Python-冲顶大会芝士超人西瓜视频头脑
- 【官方文档】TensorFlow Python API docume
- 中国大学MOOC课件爬取含视频
- 从视频中分离前景目标的Python & Matl
-
tensorflow画风迁移代码 st
yle transfer - 10行Python代码实现目标检测
- opencv3+python人脸检测和识别- 完整实战
- opencv3+python人脸检测和识别- 完整实战
- 简单粗暴 TensorFlow
- opencv3+python人脸检测和识别 完整项目
- opencv3视频中检测人脸python
- 5. 深度学习中的目标检测 python代码实
- [PDF] Reinforcement Learning With Open AI Tens
- tensorflow目标检测代码
- 《Python金融序列量化应用编程指南》
评论
共有 条评论