Skip to content

Commit

Permalink
Fix imshow_bbox error when input bboxes is empty (open-mmlab#796)
Browse files Browse the repository at this point in the history
* update imshow_bbox to handle empty bboxes
* update unittest
* add trimesh into requirements (related to open-mmlab#771)
  • Loading branch information
ly015 authored Jul 21, 2021
1 parent eab02a7 commit 6188c9f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mmpose/core/visualization/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def imshow_bboxes(img,
"""

# adapt to mmcv.imshow_bboxes input format
bboxes = np.split(bboxes, bboxes.shape[0], axis=0)
bboxes = np.split(
bboxes, bboxes.shape[0], axis=0) if bboxes.shape[0] > 0 else []
if not isinstance(colors, list):
colors = [colors for _ in range(len(bboxes))]
colors = [mmcv.color_val(c) for c in colors]
Expand Down
1 change: 1 addition & 0 deletions requirements/optional.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ onnxruntime
poseval@git+https://github.com/svenkreiss/poseval.git
pyrender
smplx>=0.1.28
trimesh
8 changes: 8 additions & 0 deletions tests/test_visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ def test_imshow_bbox():
show=False,
out_file=f'{tmpdir}/out.png')

# test case of empty bboxes
_ = imshow_bboxes(
img,
np.zeros((0, 4), dtype=np.float32),
labels=None,
colors='red',
show=False)


def test_effects():
img = np.zeros((100, 100, 3), dtype=np.uint8)
Expand Down

0 comments on commit 6188c9f

Please sign in to comment.