"vscode:/vscode.git/clone" did not exist on "c6e4e1c3c51c42db36560033fbe9aa614305f1d9"
Commit 4a44e22d authored by jzhugithub's avatar jzhugithub
Browse files

definite Tensor outside detection loop, change Tensor names

parent 09a32f32
...@@ -241,12 +241,22 @@ ...@@ -241,12 +241,22 @@
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
"metadata": { "metadata": {
"collapsed": true,
"scrolled": true "scrolled": true
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"with detection_graph.as_default():\n", "with detection_graph.as_default():\n",
" with tf.Session(graph=detection_graph) as sess:\n", " with tf.Session(graph=detection_graph) as sess:\n",
" # Definite input and output Tensors for detection_graph\n",
" image_tensor = detection_graph.get_tensor_by_name('image_tensor:0')\n",
" # Each box represents a part of the image where a particular object was detected.\n",
" detection_boxes = detection_graph.get_tensor_by_name('detection_boxes:0')\n",
" # Each score represent how level of confidence for each of the objects.\n",
" # Score is shown on the result image, together with the class label.\n",
" detection_scores = detection_graph.get_tensor_by_name('detection_scores:0')\n",
" detection_classes = detection_graph.get_tensor_by_name('detection_classes:0')\n",
" num_detections = detection_graph.get_tensor_by_name('num_detections:0')\n",
" for image_path in TEST_IMAGE_PATHS:\n", " for image_path in TEST_IMAGE_PATHS:\n",
" image = Image.open(image_path)\n", " image = Image.open(image_path)\n",
" # the array based representation of the image will be used later in order to prepare the\n", " # the array based representation of the image will be used later in order to prepare the\n",
...@@ -254,17 +264,9 @@ ...@@ -254,17 +264,9 @@
" image_np = load_image_into_numpy_array(image)\n", " image_np = load_image_into_numpy_array(image)\n",
" # Expand dimensions since the model expects images to have shape: [1, None, None, 3]\n", " # Expand dimensions since the model expects images to have shape: [1, None, None, 3]\n",
" image_np_expanded = np.expand_dims(image_np, axis=0)\n", " image_np_expanded = np.expand_dims(image_np, axis=0)\n",
" image_tensor = detection_graph.get_tensor_by_name('image_tensor:0')\n",
" # Each box represents a part of the image where a particular object was detected.\n",
" boxes = detection_graph.get_tensor_by_name('detection_boxes:0')\n",
" # Each score represent how level of confidence for each of the objects.\n",
" # Score is shown on the result image, together with the class label.\n",
" scores = detection_graph.get_tensor_by_name('detection_scores:0')\n",
" classes = detection_graph.get_tensor_by_name('detection_classes:0')\n",
" num_detections = detection_graph.get_tensor_by_name('num_detections:0')\n",
" # Actual detection.\n", " # Actual detection.\n",
" (boxes, scores, classes, num_detections) = sess.run(\n", " (boxes, scores, classes, num) = sess.run(\n",
" [boxes, scores, classes, num_detections],\n", " [detection_boxes, detection_scores, detection_classes, num_detections],\n",
" feed_dict={image_tensor: image_np_expanded})\n", " feed_dict={image_tensor: image_np_expanded})\n",
" # Visualization of the results of a detection.\n", " # Visualization of the results of a detection.\n",
" vis_util.visualize_boxes_and_labels_on_image_array(\n", " vis_util.visualize_boxes_and_labels_on_image_array(\n",
...@@ -305,7 +307,7 @@ ...@@ -305,7 +307,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython2", "pygments_lexer": "ipython2",
"version": "2.7.12" "version": "2.7.13"
} }
}, },
"nbformat": 4, "nbformat": 4,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment