Skip to content

Commit

Permalink
Add check for empty bboxes
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #616

The check for valid bboxes doesn't verify that the bbox list has exactly 4 elements, and crashes the training instead of marking empty bboxes as invalid (see f472700454).

Reviewed By: tglik

Differential Revision: D48653084

fbshipit-source-id: 2d47fb267c5e51ab27798662ae739014f3d310e4
  • Loading branch information
Karla Brkic authored and facebook-github-bot committed Sep 6, 2023
1 parent 7ad54f5 commit 66f626d
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions d2go/data/extended_coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def convert_coco_text_to_coco_detection_json(
def valid_bbox(bbox_xywh: List[int], img_w: int, img_h: int) -> bool:
if (
bbox_xywh is None
or not len(bbox_xywh) == 4
or (bbox_xywh[3] == 0 or bbox_xywh[2] == 0)
or not (0 <= bbox_xywh[0] <= img_w - bbox_xywh[2])
or not (0 <= bbox_xywh[1] <= img_h - bbox_xywh[3])
Expand Down

0 comments on commit 66f626d

Please sign in to comment.