@@ -30,7 +30,7 @@ def crop_graph(image_ph, boxes_ph, box_ind_ph, mask_ind_ph, box_size, mask_boxes
3030 #crops = (crops - mean)/std
3131 mini = tf .math .reduce_min (crops , axis = [1 , 2 ], keepdims = True )
3232 maxi = tf .math .reduce_max (crops , axis = [1 , 2 ], keepdims = True )
33- crops = (crops - mini ) / maxi
33+ crops = (crops - mini ) / ( maxi - mini + tf . keras . backend . epsilon ())
3434
3535 if export_masks :
3636 crops = tf .concat ((crops [:, :, :, 0 :- 1 ], tf .expand_dims (masks , axis = - 1 )), axis = 3 )
@@ -332,6 +332,15 @@ def prepare_image(self, session, image_array, meta, sample_first_crops=False):
332332 self .input_variables ["mask_ind_ph" ]: mask_ind
333333 }
334334
335+ # check that all boxes overlap the image
336+ ymins = boxes [:, [0 , 2 ]].min (axis = 1 )
337+ ymaxs = boxes [:, [0 , 2 ]].max (axis = 1 )
338+ xmins = boxes [:, [1 , 3 ]].min (axis = 1 )
339+ xmaxs = boxes [:, [1 , 3 ]].max (axis = 1 )
340+ if (np .any (ymins > 1 ) or np .any (xmins > 1 ) or
341+ np .any (ymaxs < 0 ) or np .any (ymaxs < 0 )):
342+ print ("WARNING: Some cell boxes are entirely outside the image" )
343+
335344 for i in range (num_targets ):
336345 tname = "target_" + str (i )
337346 feed_dict [self .input_variables ["targets_phs" ][tname ]] = targets [i ]
0 commit comments