Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
b61ccce1
Commit
b61ccce1
authored
Mar 30, 2019
by
Guo Yejun (郭叶军)
Committed by
pkulzc
Mar 29, 2019
Browse files
Update object detection notebook to use image_np_expanded (#6345)
parent
5775220a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
research/object_detection/object_detection_tutorial.ipynb
research/object_detection/object_detection_tutorial.ipynb
+3
-3
No files found.
research/object_detection/object_detection_tutorial.ipynb
View file @
b61ccce1
...
@@ -372,7 +372,7 @@
...
@@ -372,7 +372,7 @@
" detection_boxes = tf.slice(detection_boxes, [0, 0], [real_num_detection, -1])\n",
" detection_boxes = tf.slice(detection_boxes, [0, 0], [real_num_detection, -1])\n",
" detection_masks = tf.slice(detection_masks, [0, 0, 0], [real_num_detection, -1, -1])\n",
" detection_masks = tf.slice(detection_masks, [0, 0, 0], [real_num_detection, -1, -1])\n",
" detection_masks_reframed = utils_ops.reframe_box_masks_to_image_masks(\n",
" detection_masks_reframed = utils_ops.reframe_box_masks_to_image_masks(\n",
" detection_masks, detection_boxes, image.shape[
0
], image.shape[
1
])\n",
" detection_masks, detection_boxes, image.shape[
1
], image.shape[
2
])\n",
" detection_masks_reframed = tf.cast(\n",
" detection_masks_reframed = tf.cast(\n",
" tf.greater(detection_masks_reframed, 0.5), tf.uint8)\n",
" tf.greater(detection_masks_reframed, 0.5), tf.uint8)\n",
" # Follow the convention by adding back the batch dimension\n",
" # Follow the convention by adding back the batch dimension\n",
...
@@ -382,7 +382,7 @@
...
@@ -382,7 +382,7 @@
"\n",
"\n",
" # Run inference\n",
" # Run inference\n",
" output_dict = sess.run(tensor_dict,\n",
" output_dict = sess.run(tensor_dict,\n",
" feed_dict={image_tensor:
np.expand_dims(
image
, 0)
})\n",
" feed_dict={image_tensor: image})\n",
"\n",
"\n",
" # all outputs are float32 numpy arrays, so convert types as appropriate\n",
" # all outputs are float32 numpy arrays, so convert types as appropriate\n",
" output_dict['num_detections'] = int(output_dict['num_detections'][0])\n",
" output_dict['num_detections'] = int(output_dict['num_detections'][0])\n",
...
@@ -418,7 +418,7 @@
...
@@ -418,7 +418,7 @@
" # 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",
" # Actual detection.\n",
" # Actual detection.\n",
" output_dict = run_inference_for_single_image(image_np, detection_graph)\n",
" output_dict = run_inference_for_single_image(image_np
_expanded
, detection_graph)\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",
" image_np,\n",
" image_np,\n",
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment