Skip to content

Instantly share code, notes, and snippets.

@Alakhator
Created April 6, 2020 07:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Alakhator/94be61947a18e3cb21806cb5fdf1c99a to your computer and use it in GitHub Desktop.
Save Alakhator/94be61947a18e3cb21806cb5fdf1c99a to your computer and use it in GitHub Desktop.
def show_inference(model, image_path):
# the array based representation of the image will be used later in order to prepare the
# result image with boxes and labels on it.
image_np = np.array(Image.open(image_path))
# Actual detection.
output_dict = run_inference_for_single_image(model, image_np)
# Visualization of the results of a detection.
vis_util.visualize_boxes_and_labels_on_image_array(
image_np,
output_dict['detection_boxes'],
output_dict['detection_classes'],
output_dict['detection_scores'],
category_index,
instance_masks=output_dict.get('detection_masks_reframed', None),
use_normalized_coordinates=True,
line_thickness=8)
display(Image.fromarray(image_np))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment