Skip to content

Commit

Permalink
Merge pull request #7 from franchesoni/npbool-patch-1
Browse files Browse the repository at this point in the history
replace deprecated np.bool with bool to improve compatibility
qinliuliuqin authored Feb 17, 2023
2 parents 85ed317 + 518ac98 commit dde857c
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions isegm/data/points_sampler.py
Original file line number Diff line number Diff line change
@@ -258,7 +258,7 @@ def _positive_erode(self, mask):

kernel = np.ones((3, 3), np.uint8)
eroded_mask = cv2.erode(mask.astype(np.uint8),
kernel, iterations=self.positive_erode_iters).astype(np.bool)
kernel, iterations=self.positive_erode_iters).astype(bool)

if eroded_mask.sum() > 10:
return eroded_mask
@@ -269,7 +269,7 @@ def _get_border_mask(self, mask):
expand_r = int(np.ceil(self.expand_ratio * np.sqrt(mask.sum())))
kernel = np.ones((3, 3), np.uint8)
expanded_mask = cv2.dilate(mask.astype(np.uint8), kernel, iterations=expand_r)
expanded_mask[mask.astype(np.bool)] = 0
expanded_mask[mask.astype(bool)] = 0
return expanded_mask


2 changes: 1 addition & 1 deletion isegm/inference/clicker.py
Original file line number Diff line number Diff line change
@@ -82,7 +82,7 @@ def _remove_last_click(self):

def reset_clicks(self):
if self.gt_mask is not None:
self.not_clicked_map = np.ones_like(self.gt_mask, dtype=np.bool)
self.not_clicked_map = np.ones_like(self.gt_mask, dtype=bool)

self.num_pos_clicks = 0
self.num_neg_clicks = 0
4 changes: 2 additions & 2 deletions isegm/utils/vis.py
Original file line number Diff line number Diff line change
@@ -93,15 +93,15 @@ def blend_mask(image, mask, alpha=0.6):


def get_boundaries(instances_masks, boundaries_width=1):
boundaries = np.zeros((instances_masks.shape[0], instances_masks.shape[1]), dtype=np.bool)
boundaries = np.zeros((instances_masks.shape[0], instances_masks.shape[1]), dtype=bool)

for obj_id in np.unique(instances_masks.flatten()):
if obj_id == 0:
continue

obj_mask = instances_masks == obj_id
kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (3, 3))
inner_mask = cv2.erode(obj_mask.astype(np.uint8), kernel, iterations=boundaries_width).astype(np.bool)
inner_mask = cv2.erode(obj_mask.astype(np.uint8), kernel, iterations=boundaries_width).astype(bool)

obj_boundary = np.logical_xor(obj_mask, np.logical_and(inner_mask, obj_mask))
boundaries = np.logical_or(boundaries, obj_boundary)
2 changes: 1 addition & 1 deletion scripts/annotations_conversion/common.py
Original file line number Diff line number Diff line change
@@ -94,7 +94,7 @@ def get_root_indx(root_indx, check_indx):

return None

used_masks = np.zeros(len(masks), dtype=np.bool)
used_masks = np.zeros(len(masks), dtype=bool)
parents = [None] * len(masks)
node_level = [0] * len(masks)
for ti in range(len(masks) - 1):

0 comments on commit dde857c

Please sign in to comment.