Skip to content

Commit da422b4

Browse files
committed
v.1.14.0
1 parent e732ab9 commit da422b4

7 files changed

+502
-226
lines changed
Loading
Loading

docs/source/camera.rst

+16-13
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ Detect Objects Using Your Webcam
33

44
Hereby you can find an example which allows you to use your camera to generate a video stream, based on which you can perform object_detection.
55

6+
To run the example, simply create a new file under ``<PATH_TO_TF>/TensorFlow/models/research/object_detection`` and paste the code below.
7+
68
.. code-block:: python
79
810
import numpy as np
@@ -18,8 +20,8 @@ Hereby you can find an example which allows you to use your camera to generate a
1820
from io import StringIO
1921
from matplotlib import pyplot as plt
2022
from PIL import Image
21-
from utils import label_map_util
22-
from utils import visualization_utils as vis_util
23+
from object_detection.utils import label_map_util
24+
from object_detection.utils import visualization_utils as vis_util
2325
2426
# Define the video stream
2527
cap = cv2.VideoCapture(0) # Change only if you have more than one webcams
@@ -40,20 +42,22 @@ Hereby you can find an example which allows you to use your camera to generate a
4042
NUM_CLASSES = 90
4143
4244
# Download Model
43-
opener = urllib.request.URLopener()
44-
opener.retrieve(DOWNLOAD_BASE + MODEL_FILE, MODEL_FILE)
45-
tar_file = tarfile.open(MODEL_FILE)
46-
for file in tar_file.getmembers():
47-
file_name = os.path.basename(file.name)
48-
if 'frozen_inference_graph.pb' in file_name:
49-
tar_file.extract(file, os.getcwd())
45+
if not os.path.exists(os.path.join(os.getcwd(), MODEL_FILE)):
46+
print("Downloading model")
47+
opener = urllib.request.URLopener()
48+
opener.retrieve(DOWNLOAD_BASE + MODEL_FILE, MODEL_FILE)
49+
tar_file = tarfile.open(MODEL_FILE)
50+
for file in tar_file.getmembers():
51+
file_name = os.path.basename(file.name)
52+
if 'frozen_inference_graph.pb' in file_name:
53+
tar_file.extract(file, os.getcwd())
5054
5155
5256
# Load a (frozen) Tensorflow model into memory.
5357
detection_graph = tf.Graph()
5458
with detection_graph.as_default():
55-
od_graph_def = tf.GraphDef()
56-
with tf.gfile.GFile(PATH_TO_CKPT, 'rb') as fid:
59+
od_graph_def = tf.compat.v1.GraphDef()
60+
with tf.io.gfile.GFile(PATH_TO_CKPT, 'rb') as fid:
5761
serialized_graph = fid.read()
5862
od_graph_def.ParseFromString(serialized_graph)
5963
tf.import_graph_def(od_graph_def, name='')
@@ -76,9 +80,8 @@ Hereby you can find an example which allows you to use your camera to generate a
7680
7781
# Detection
7882
with detection_graph.as_default():
79-
with tf.Session(graph=detection_graph) as sess:
83+
with tf.compat.v1.Session(graph=detection_graph) as sess:
8084
while True:
81-
8285
# Read frame from camera
8386
ret, image_np = cap.read()
8487
# Expand dimensions since the model expects images to have shape: [1, None, None, 3]

docs/source/index.rst

+13-7
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,34 @@
66
TensorFlow Object Detection API tutorial
77
============================================
88

9+
.. important:: This tutorial is intended for TensorFlow 1.14, which (at the time of writing this tutorial) is the latest stable version before TensorFlow 2.x.
10+
11+
Tensorflow 1.15 has also been released, but seems to be exhibiting `instability issues <https://github.com/tensorflow/models/issues/7640>`_.
12+
13+
A version for Tensorflow 1.9 can be found `here <https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/v1.9.1/>`_.
14+
15+
A version for Tensorflow 2.x is in the making and a link will be added here when ready.
16+
917
This is a step-by-step tutorial/guide to setting up and using TensorFlow's Object Detection API to perform, namely, object detection in images/video.
1018

1119
The software tools which we shall use throughout this tutorial are listed in the table below:
1220

1321
+---------------------------------------------+
1422
| Target Software versions |
1523
+==============+==============================+
16-
| OS | Windows, Linux [*]_ |
24+
| OS | Windows, Linux |
1725
+--------------+------------------------------+
18-
| Python | 3.6 |
26+
| Python | 3.7 |
1927
+--------------+------------------------------+
20-
| TensorFlow | 1.9 |
28+
| TensorFlow | 1.14 |
2129
+--------------+------------------------------+
22-
| CUDA Toolkit | v9.0 |
30+
| CUDA Toolkit | 10.0 |
2331
+--------------+------------------------------+
24-
| CuDNN | v7.0.5 |
32+
| CuDNN | 7.6.5 |
2533
+--------------+------------------------------+
2634
| Anaconda | Python 3.7 (Optional) |
2735
+--------------+------------------------------+
2836

29-
.. [*] Even though this tutorial is mostly based (and properly tested) on Windows 10, information is also provided for Linux systems.
30-
3137
.. toctree::
3238
:maxdepth: 4
3339
:caption: Contents:

0 commit comments

Comments
 (0)