Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecating np.bool Type Alias #9498

Merged
merged 2 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/PyCQA/flake8
rev: 3.8.3
rev: 5.0.4
hooks:
- id: flake8
- repo: https://github.com/PyCQA/isort
Expand Down
14 changes: 7 additions & 7 deletions mmdet/core/evaluation/mean_ap.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def tpfp_imagenet(det_bboxes,

# an indicator of ignored gts
gt_ignore_inds = np.concatenate(
(np.zeros(gt_bboxes.shape[0], dtype=np.bool),
np.ones(gt_bboxes_ignore.shape[0], dtype=np.bool)))
(np.zeros(gt_bboxes.shape[0],
dtype=bool), np.ones(gt_bboxes_ignore.shape[0], dtype=bool)))
# stack gt_bboxes and gt_bboxes_ignore for convenience
gt_bboxes = np.vstack((gt_bboxes, gt_bboxes_ignore))

Expand Down Expand Up @@ -202,8 +202,8 @@ def tpfp_default(det_bboxes,

# an indicator of ignored gts
gt_ignore_inds = np.concatenate(
(np.zeros(gt_bboxes.shape[0], dtype=np.bool),
np.ones(gt_bboxes_ignore.shape[0], dtype=np.bool)))
(np.zeros(gt_bboxes.shape[0],
dtype=bool), np.ones(gt_bboxes_ignore.shape[0], dtype=bool)))
# stack gt_bboxes and gt_bboxes_ignore for convenience
gt_bboxes = np.vstack((gt_bboxes, gt_bboxes_ignore))

Expand Down Expand Up @@ -317,8 +317,8 @@ def tpfp_openimages(det_bboxes,

# an indicator of ignored gts
gt_ignore_inds = np.concatenate(
(np.zeros(gt_bboxes.shape[0], dtype=np.bool),
np.ones(gt_bboxes_ignore.shape[0], dtype=np.bool)))
(np.zeros(gt_bboxes.shape[0],
dtype=bool), np.ones(gt_bboxes_ignore.shape[0], dtype=bool)))
# stack gt_bboxes and gt_bboxes_ignore for convenience
gt_bboxes = np.vstack((gt_bboxes, gt_bboxes_ignore))

Expand Down Expand Up @@ -517,7 +517,7 @@ def get_cls_group_ofs(annotations, class_id):
if ann.get('gt_is_group_ofs', None) is not None:
gt_group_ofs.append(ann['gt_is_group_ofs'][gt_inds])
else:
gt_group_ofs.append(np.empty((0, 1), dtype=np.bool))
gt_group_ofs.append(np.empty((0, 1), dtype=bool))

return gt_group_ofs

Expand Down
2 changes: 1 addition & 1 deletion mmdet/core/export/model_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def forward(self, img, img_metas, return_loss=True, **kwargs):
masks = torch.nn.functional.interpolate(
masks.unsqueeze(0), size=(ori_h, ori_w))
masks = masks.squeeze(0).detach().numpy()
if masks.dtype != np.bool:
if masks.dtype != bool:
masks = masks >= 0.5
segms_results = [[] for _ in range(len(self.CLASSES))]
for j in range(len(dets)):
Expand Down
2 changes: 1 addition & 1 deletion mmdet/core/mask/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ def polygon_to_bitmap(polygons, height, width):
"""
rles = maskUtils.frPyObjects(polygons, height, width)
rle = maskUtils.merge(rles)
bitmap_mask = maskUtils.decode(rle).astype(np.bool)
bitmap_mask = maskUtils.decode(rle).astype(bool)
return bitmap_mask


Expand Down
14 changes: 7 additions & 7 deletions mmdet/datasets/openimages.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,13 @@ def get_ann_info(self, idx):
labels_ignore = np.array(labels_ignore)

assert len(is_group_ofs) == len(labels) == len(bboxes)
gt_is_group_ofs = np.array(is_group_ofs, dtype=np.bool)
gt_is_group_ofs = np.array(is_group_ofs, dtype=bool)

# These parameters is not used yet.
is_occludeds = np.array(is_occludeds, dtype=np.bool)
is_truncateds = np.array(is_truncateds, dtype=np.bool)
is_depictions = np.array(is_depictions, dtype=np.bool)
is_insides = np.array(is_insides, dtype=np.bool)
is_occludeds = np.array(is_occludeds, dtype=bool)
is_truncateds = np.array(is_truncateds, dtype=bool)
is_depictions = np.array(is_depictions, dtype=bool)
is_insides = np.array(is_insides, dtype=bool)

ann = dict(
bboxes=bboxes.astype(np.float32),
Expand Down Expand Up @@ -450,7 +450,7 @@ def add_supercategory_ann(self, annotations):
bboxes=np.array(gt_bboxes).astype(np.float32),
labels=np.array(gt_labels).astype(np.int64),
bboxes_ignore=ann['bboxes_ignore'],
gt_is_group_ofs=np.array(gt_is_group_ofs).astype(np.bool))
gt_is_group_ofs=np.array(gt_is_group_ofs).astype(bool))

return annotations

Expand Down Expand Up @@ -790,7 +790,7 @@ def load_annotations(self, ann_file):
gt_bboxes = np.array(bboxes, dtype=np.float32)
gt_labels = np.array(labels, dtype=np.int64)
gt_bboxes_ignore = np.zeros((0, 4), dtype=np.float32)
gt_is_group_ofs = np.array(is_group_ofs, dtype=np.bool)
gt_is_group_ofs = np.array(is_group_ofs, dtype=bool)

img_info = dict(filename=filename)
ann_info = dict(
Expand Down
4 changes: 2 additions & 2 deletions tests/test_metrics/test_mean_ap.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def test_tpfp_openimages():
[10, 10, 25, 25, 0.98], [28, 28, 35, 35, 0.97],
[30, 30, 51, 51, 0.96], [100, 110, 120, 130, 0.15]])
gt_bboxes = np.array([[10., 10., 30., 30.], [30., 30., 50., 50.]])
gt_groups_of = np.array([True, False], dtype=np.bool)
gt_groups_of = np.array([True, False], dtype=bool)
gt_ignore = np.zeros((0, 4))

# Open Images evaluation using group of.
Expand Down Expand Up @@ -158,7 +158,7 @@ def test_tpfp_openimages():
assert cls_dets.shape == (6, 5)

# Open Images evaluation using group of, and gt is all group of bboxes.
gt_groups_of = np.array([True, True], dtype=np.bool)
gt_groups_of = np.array([True, True], dtype=bool)
result = tpfp_openimages(
det_bboxes,
gt_bboxes,
Expand Down