Skip to content

Commit f94cd09

Browse files
igorsugakfacebook-github-bot
authored andcommitted
s,np.bool\b,bool,
Summary: X-link: facebookresearch/Detectron#1047 X-link: facebook/openzl#582 `np.bool` and `bool` are identical, but the former is removed from Numpy-1.24.X. Differential Revision: D49196618
1 parent bca1a19 commit f94cd09

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

mmdet/core/evaluation/mean_ap.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ def tpfp_imagenet(
8484
# an indicator of ignored gts
8585
gt_ignore_inds = np.concatenate(
8686
(
87-
np.zeros(gt_bboxes.shape[0], dtype=np.bool),
88-
np.ones(gt_bboxes_ignore.shape[0], dtype=np.bool),
87+
np.zeros(gt_bboxes.shape[0], dtype=bool),
88+
np.ones(gt_bboxes_ignore.shape[0], dtype=bool),
8989
)
9090
)
9191
# stack gt_bboxes and gt_bboxes_ignore for convenience
@@ -179,8 +179,8 @@ def tpfp_default(
179179
# an indicator of ignored gts
180180
gt_ignore_inds = np.concatenate(
181181
(
182-
np.zeros(gt_bboxes.shape[0], dtype=np.bool),
183-
np.ones(gt_bboxes_ignore.shape[0], dtype=np.bool),
182+
np.zeros(gt_bboxes.shape[0], dtype=bool),
183+
np.ones(gt_bboxes_ignore.shape[0], dtype=bool),
184184
)
185185
)
186186
# stack gt_bboxes and gt_bboxes_ignore for convenience

mmdet/core/mask/structures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,5 +860,5 @@ def polygon_to_bitmap(polygons, height, width):
860860
"""
861861
rles = maskUtils.frPyObjects(polygons, height, width)
862862
rle = maskUtils.merge(rles)
863-
bitmap_mask = maskUtils.decode(rle).astype(np.bool)
863+
bitmap_mask = maskUtils.decode(rle).astype(bool)
864864
return bitmap_mask

mmdet/models/detectors/pa_predictor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def palette2filter(palette, neighbor_sizes=None, bidirection=True):
5151
"""
5252

5353
def generate_cross_filter(number_of_neighbors, dist):
54-
cross_filter = np.zeros((number_of_neighbors,) + palette.shape, dtype=np.bool)
54+
cross_filter = np.zeros((number_of_neighbors,) + palette.shape, dtype=bool)
5555
cross_filter[0, dist:, :] = np.logical_or(palette[dist:, :], palette[:-dist, :])
5656
cross_filter[1, :, dist:] = np.logical_or(palette[:, dist:], palette[:, :-dist])
5757
cross_filter[2, dist:, dist:] = np.logical_or(
@@ -81,7 +81,7 @@ def generate_cross_filter(number_of_neighbors, dist):
8181
number_of_span = len(neighbor_sizes)
8282
number_of_neighbors_per_span = 8 if bidirection else 4
8383
potential_filter = np.zeros(
84-
(number_of_neighbors_per_span * number_of_span,) + palette.shape, dtype=np.bool
84+
(number_of_neighbors_per_span * number_of_span,) + palette.shape, dtype=bool
8585
)
8686
for neighbor_idx, dist in enumerate(neighbor_sizes):
8787
offset = neighbor_idx * number_of_neighbors_per_span
@@ -103,7 +103,7 @@ def palette2weight(
103103
"""
104104

105105
def generate_cross_weight(number_of_neighbors, dist):
106-
cross_filter = np.zeros((number_of_neighbors,) + palette.shape, dtype=np.bool)
106+
cross_filter = np.zeros((number_of_neighbors,) + palette.shape, dtype=bool)
107107
cross_filter[0, dist:, :] = np.maximum(palette[dist:, :], palette[:-dist, :])
108108
cross_filter[1, :, dist:] = np.maximum(palette[:, dist:], palette[:, :-dist])
109109
cross_filter[2, dist:, dist:] = np.maximum(
@@ -152,7 +152,7 @@ def generate_cross_weight(number_of_neighbors, dist):
152152
number_of_span = len(neighbor_sizes)
153153
number_of_neighbors_per_span = 8 if bidirection else 4
154154
potential_weight = np.zeros(
155-
(number_of_neighbors_per_span * number_of_span,) + palette.shape, dtype=np.bool
155+
(number_of_neighbors_per_span * number_of_span,) + palette.shape, dtype=bool
156156
)
157157
for neighbor_idx, dist in enumerate(neighbor_sizes):
158158
offset = neighbor_idx * number_of_neighbors_per_span

pa_lib/evaluate_helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ def rank_by_variance(image, masks, weight_by_size=False, nms=1.0):
6161
def compute_iou(annotation, segmentation, mask_threshold=0.0):
6262
if type(annotation) == torch.Tensor:
6363
annotation = annotation.numpy()
64-
annotation = annotation.astype(np.bool)
65-
segmentation = (segmentation > mask_threshold).astype(np.bool)
64+
annotation = annotation.astype(bool)
65+
segmentation = (segmentation > mask_threshold).astype(bool)
6666

6767
if np.isclose(np.sum(annotation), 0) and np.isclose(np.sum(segmentation), 0):
6868
return 1

0 commit comments

Comments
 (0)