@@ -66,28 +66,28 @@ def pred_bbox():
66
66
detection_scores = detection_graph .get_tensor_by_name ('detection_scores:0' )
67
67
detection_classes = detection_graph .get_tensor_by_name ('detection_classes:0' )
68
68
num_detections = detection_graph .get_tensor_by_name ('num_detections:0' )
69
- for image_path in test_imgs :
70
- image = Image .open (image_path )
71
- image_np = load_image_into_numpy_array (image )
72
- # the array based representation of the image will be used later in order to prepare the
73
- # result image with boxes and labels on it.
74
- # Expand dimensions since the model expects images to have shape: [1, None, None, 3]
75
- image_np_expanded = np .expand_dims (image_np , axis = 0 )
76
- # Actual detection.
77
- (boxes , scores , classes , num ) = sess .run (
78
- [detection_boxes , detection_scores , detection_classes , num_detections ],
79
- feed_dict = {image_tensor : image_np_expanded })
80
- ### 256 here is the image size from Label Maker, adjust it according to your input image size.
81
- bboxe = (boxes * 256 ).astype (np .int )
82
- bboxe = np .squeeze (bboxe )
83
- score = np .squeeze (((scores * 100 ).transpose ()).astype (np .int ))
84
- ### only keep the bbox that prediction score is higher than 50.
85
- bboxes = bboxe [score > 50 ]
86
- if bboxes .any ():
87
- bboxes_ls = bboxes .tolist ()
88
- for bbox in bboxes_ls :
89
- # pred_bboxes.append([image_path[-18:],bbox])
90
- pred_bboxes .append (bbox )
69
+ for image_path in test_imgs :
70
+ image = Image .open (image_path )
71
+ image_np = load_image_into_numpy_array (image )
72
+ # the array based representation of the image will be used later in order to prepare the
73
+ # result image with boxes and labels on it.
74
+ # Expand dimensions since the model expects images to have shape: [1, None, None, 3]
75
+ image_np_expanded = np .expand_dims (image_np , axis = 0 )
76
+ # Actual detection.
77
+ (boxes , scores , classes , num ) = sess .run (
78
+ [detection_boxes , detection_scores , detection_classes , num_detections ],
79
+ feed_dict = {image_tensor : image_np_expanded })
80
+ ### 256 here is the image size from Label Maker, adjust it according to your input image size.
81
+ bboxe = (boxes * 256 ).astype (np .int )
82
+ bboxe = np .squeeze (bboxe )
83
+ score = np .squeeze (((scores * 100 ).transpose ()).astype (np .int ))
84
+ ### only keep the bbox that prediction score is higher than 50.
85
+ bboxes = bboxe [score > 50 ]
86
+ if bboxes .any ():
87
+ bboxes_ls = bboxes .tolist ()
88
+ for bbox in bboxes_ls :
89
+ # pred_bboxes.append([image_path[-18:],bbox])
90
+ pred_bboxes .append (bbox )
91
91
return pred_bboxes
92
92
93
93
def gr_bbox ():
0 commit comments