Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. image = Image.open(image_path)
  2. # the array based representation of the image will be used later in order to prepare the
  3. # result image with boxes and labels on it.
  4. image_np = load_image_into_numpy_array(image)
  5. # Expand dimensions since the model expects images to have shape: [1, None, None, 3]
  6. image_np_expanded = np.expand_dims(image_np, axis=0)
  7. # Actual detection.
  8. output_dict = run_inference_for_single_image(image_np, detection_graph)
  9. # Visualization of the results of a detection.
  10. vis_util.visualize_boxes_and_labels_on_image_array(
  11. image_np,
  12. output_dict['detection_boxes'],
  13. output_dict['detection_classes'],
  14. output_dict['detection_scores'],
  15. category_index,
  16. instance_masks=output_dict.get('detection_masks'),
  17. use_normalized_coordinates=True,
  18. line_thickness=2)
  19. plt.figure(figsize=IMAGE_SIZE)
  20. plt.imshow(image_np)
  21.  
  22. width = 1024
  23. height = 600
  24.  
  25. for i,j in zip(output_dict['detection_boxes'],output_dict['detection_scores']):
  26. if(j>0.5):
  27. print(i[0]*width,i[2]*height,i[1]*width,i[3]*height)
  28.  
  29. 456.1627197265625 433.97676944732666 659.828125 562.1794939041138
  30. 430.4501953125 364.17006254196167 612.30224609375 440.01832008361816
  31. 453.7798156738281 326.9976854324341 584.5558471679688 374.18121099472046
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement