"vscode:/vscode.git/clone" did not exist on "af54e5645399bc67711155de2f8bb9cb1f4ebbe1"
Commit 66f626dd authored by Karla Brkic's avatar Karla Brkic Committed by Facebook GitHub Bot
Browse files

Add check for empty bboxes

Summary:
Pull Request resolved: https://github.com/facebookresearch/d2go/pull/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
parent 7ad54f57
...@@ -142,6 +142,7 @@ def convert_coco_text_to_coco_detection_json( ...@@ -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: def valid_bbox(bbox_xywh: List[int], img_w: int, img_h: int) -> bool:
if ( if (
bbox_xywh is None bbox_xywh is None
or not len(bbox_xywh) == 4
or (bbox_xywh[3] == 0 or bbox_xywh[2] == 0) 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[0] <= img_w - bbox_xywh[2])
or not (0 <= bbox_xywh[1] <= img_h - bbox_xywh[3]) or not (0 <= bbox_xywh[1] <= img_h - bbox_xywh[3])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment