@@ -2269,17 +2269,6 @@ def unmold_detections(self, detections, mrcnn_mask, image_shape, window):
22692269 scores = detections [:N , 5 ]
22702270 masks = mrcnn_mask [np .arange (N ), :, :, class_ids ]
22712271
2272- # Filter out detections with zero area. Often only happens in early
2273- # stages of training when the network weights are still a bit random.
2274- exclude_ix = np .where (
2275- (boxes [:, 2 ] - boxes [:, 0 ]) * (boxes [:, 2 ] - boxes [:, 0 ]) <= 0 )[0 ]
2276- if exclude_ix .shape [0 ] > 0 :
2277- boxes = np .delete (boxes , exclude_ix , axis = 0 )
2278- class_ids = np .delete (class_ids , exclude_ix , axis = 0 )
2279- scores = np .delete (scores , exclude_ix , axis = 0 )
2280- masks = np .delete (masks , exclude_ix , axis = 0 )
2281- N = class_ids .shape [0 ]
2282-
22832272 # Compute scale and shift to translate coordinates to image domain.
22842273 h_scale = image_shape [0 ] / (window [2 ] - window [0 ])
22852274 w_scale = image_shape [1 ] / (window [3 ] - window [1 ])
@@ -2291,6 +2280,17 @@ def unmold_detections(self, detections, mrcnn_mask, image_shape, window):
22912280 # Translate bounding boxes to image domain
22922281 boxes = np .multiply (boxes - shifts , scales ).astype (np .int32 )
22932282
2283+ # Filter out detections with zero area. Often only happens in early
2284+ # stages of training when the network weights are still a bit random.
2285+ exclude_ix = np .where (
2286+ (boxes [:, 2 ] - boxes [:, 0 ]) * (boxes [:, 3 ] - boxes [:, 1 ]) <= 0 )[0 ]
2287+ if exclude_ix .shape [0 ] > 0 :
2288+ boxes = np .delete (boxes , exclude_ix , axis = 0 )
2289+ class_ids = np .delete (class_ids , exclude_ix , axis = 0 )
2290+ scores = np .delete (scores , exclude_ix , axis = 0 )
2291+ masks = np .delete (masks , exclude_ix , axis = 0 )
2292+ N = class_ids .shape [0 ]
2293+
22942294 # Resize masks to original image size and set boundary threshold.
22952295 full_masks = []
22962296 for i in range (N ):
0 commit comments