Skip to content

Commit 5ba3d58

Browse files
committed
Update PointAndBoxPromptGenerator - Fixes for Background Prompts
1 parent 3abcbd0 commit 5ba3d58

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

micro_sam/prompt_generators.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ def __call__(self, gt, gt_id, center_coordinates, bbox_coordinates):
5656
dilated_object = binary_dilation(object_mask, iterations=self.dilation_strength)
5757
background_mask = np.zeros(gt.shape)
5858
background_mask[bbox_coordinates[0]:bbox_coordinates[2], bbox_coordinates[1]:bbox_coordinates[3]] = 1
59-
background_mask = abs(background_mask - dilated_object)
6059
background_mask = binary_dilation(background_mask, iterations=self.dilation_strength)
60+
background_mask = abs(
61+
background_mask.astype(np.float32) - dilated_object.astype(np.float32)
62+
) # casting booleans to do subtraction
6163

6264
n_negative_remaining = self.n_negative_points
6365
if n_negative_remaining > 0:

0 commit comments

Comments
 (0)