@@ -50,31 +50,31 @@ def tf_od_pred():
50
50
detection_scores = detection_graph .get_tensor_by_name ('detection_scores:0' )
51
51
detection_classes = detection_graph .get_tensor_by_name ('detection_classes:0' )
52
52
num_detections = detection_graph .get_tensor_by_name ('num_detections:0' )
53
- for image_path in test_imgs :
54
- image = Image .open (image_path )
55
- image_np = load_image_into_numpy_array (image )
56
- # the array based representation of the image will be used later in order to prepare the
57
- # result image with boxes and labels on it.
58
- # Expand dimensions since the model expects images to have shape: [1, None, None, 3]
59
- image_np_expanded = np .expand_dims (image_np , axis = 0 )
60
- # Actual detection.
61
- (boxes , scores , classes , num ) = sess .run (
62
- [detection_boxes , detection_scores , detection_classes , num_detections ],
63
- feed_dict = {image_tensor : image_np_expanded })
64
- # draw_bounding_box_on_image(image, boxes, )
65
- # Visualization of the results of a detection.
66
- vis_image = vis_util .visualize_boxes_and_labels_on_image_array (
67
- image_np ,
68
- np .squeeze (boxes ),
69
- np .squeeze (classes ).astype (np .int32 ),
70
- np .squeeze (scores ),
71
- category_index ,
72
- use_normalized_coordinates = True ,
73
- line_thickness = 1 )
74
- print ("{} boxes in {} image tile!" .format (len (boxes ), image_path ))
75
- image_pil = Image .fromarray (np .uint8 (vis_image )).convert ('RGB' )
76
- with tf .gfile .Open (image_path , 'w' ) as fid :
77
- image_pil .save (fid , 'PNG' )
53
+ for image_path in test_imgs :
54
+ image = Image .open (image_path )
55
+ image_np = load_image_into_numpy_array (image )
56
+ # the array based representation of the image will be used later in order to prepare the
57
+ # result image with boxes and labels on it.
58
+ # Expand dimensions since the model expects images to have shape: [1, None, None, 3]
59
+ image_np_expanded = np .expand_dims (image_np , axis = 0 )
60
+ # Actual detection.
61
+ (boxes , scores , classes , num ) = sess .run (
62
+ [detection_boxes , detection_scores , detection_classes , num_detections ],
63
+ feed_dict = {image_tensor : image_np_expanded })
64
+ # draw_bounding_box_on_image(image, boxes, )
65
+ # Visualization of the results of a detection.
66
+ vis_image = vis_util .visualize_boxes_and_labels_on_image_array (
67
+ image_np ,
68
+ np .squeeze (boxes ),
69
+ np .squeeze (classes ).astype (np .int32 ),
70
+ np .squeeze (scores ),
71
+ category_index ,
72
+ use_normalized_coordinates = True ,
73
+ line_thickness = 1 )
74
+ print ("{} boxes in {} image tile!" .format (len (boxes ), image_path ))
75
+ image_pil = Image .fromarray (np .uint8 (vis_image )).convert ('RGB' )
76
+ with tf .gfile .Open (image_path , 'w' ) as fid :
77
+ image_pil .save (fid , 'PNG' )
78
78
79
79
80
80
0 commit comments