Created
July 5, 2017 10:17
-
-
Save nbortolotti/6e2c27e475a27b7cd135e0f2c765e637 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with detection_graph.as_default(): | |
with tf.Session(graph=detection_graph) as sess: | |
for image_path in TEST_IMAGE_PATHS: | |
image = Image.open(image_path) | |
image_np = load_image_into_numpy_array(image) | |
image_np_expanded = np.expand_dims(image_np, axis=0) | |
image_tensor = detection_graph.get_tensor_by_name('image_tensor:0') | |
boxes = detection_graph.get_tensor_by_name('detection_boxes:0') | |
scores = detection_graph.get_tensor_by_name('detection_scores:0') | |
classes = detection_graph.get_tensor_by_name('detection_classes:0') | |
num_detections = detection_graph.get_tensor_by_name('num_detections:0') | |
(boxes, scores, classes, num_detections) = sess.run( | |
[boxes, scores, classes, num_detections], | |
feed_dict={image_tensor: image_np_expanded}) | |
vis_util.visualize_boxes_and_labels_on_image_array( | |
image_np, | |
np.squeeze(boxes), | |
np.squeeze(classes).astype(np.int32), | |
np.squeeze(scores), | |
category_index, | |
use_normalized_coordinates=True, | |
line_thickness=4) | |
plt.figure(figsize=IMAGE_SIZE) | |
plt.imshow(image_np) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment