Created
August 26, 2018 19:41
-
-
Save MrDavidYu/2933458dbf7600bea56bfba105122794 to your computer and use it in GitHub Desktop.
This file contains hidden or 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: | |
image_tensor = detection_graph.get_tensor_by_name('image_tensor:0') | |
detection_boxes = detection_graph.get_tensor_by_name('detection_boxes:0') | |
detection_scores = detection_graph.get_tensor_by_name('detection_scores:0') | |
detection_classes = detection_graph.get_tensor_by_name('detection_classes:0') | |
num_detections = detection_graph.get_tensor_by_name('num_detections:0') | |
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) | |
(boxes, scores, classes, num) = sess.run( | |
[detection_boxes, detection_scores, detection_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, | |
max_boxes_to_draw=200, # Modify depending on how many objects are likely to be in a given image | |
min_score_thresh=0.6, # Adjust accordingly, this will determine your detection threshold | |
use_normalized_coordinates=True, | |
line_thickness=2) | |
plt.figure(figsize=IMAGE_SIZE) | |
plt.imshow(image_np) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment