"tools/python/vscode:/vscode.git/clone" did not exist on "d7cac787579cadb703b8621b410e1a1e59a1ce65"
Commit 77ef0db7 authored by Luming Ma's avatar Luming Ma Committed by Facebook GitHub Bot
Browse files

read "bbox_mode" from annotation when filtering out images with invalid bbox

Summary: Some annotations are using XYXY_ABS for bbox mode so that many images were incorrectly filtered out by assuming XYWH_ABS mode. This diff read bbox_mode from annotation and convert bbox to XYWH_ABS before checking invalid bbox.

Differential Revision: D29365700

fbshipit-source-id: 355346b6826f401f504691090631997e169ead4a
parent d4aedb83
...@@ -175,11 +175,13 @@ def convert_to_dict_list(image_root, id_map, imgs, anns, dataset_name=None): ...@@ -175,11 +175,13 @@ def convert_to_dict_list(image_root, id_map, imgs, anns, dataset_name=None):
obj = { obj = {
field: anno[field] field: anno[field]
# NOTE: maybe use MetadataCatalog for this # NOTE: maybe use MetadataCatalog for this
for field in ["iscrowd", "bbox", "keypoints", "category_id", "extras"] for field in ["iscrowd", "bbox", "bbox_mode", "keypoints", "category_id", "extras"]
if field in anno if field in anno
} }
bbox_object = obj.get("bbox", None) bbox_object = obj.get("bbox", None)
if bbox_object is not None and "bbox_mode" in obj:
bbox_object = BoxMode.convert(bbox_object, obj["bbox_mode"], BoxMode.XYWH_ABS)
if "width" in record and "height" in record and (not valid_bbox(bbox_object, record["width"], record["height"])): if "width" in record and "height" in record and (not valid_bbox(bbox_object, record["width"], record["height"])):
num_instances_without_valid_bounding_box += 1 num_instances_without_valid_bounding_box += 1
continue continue
...@@ -199,10 +201,11 @@ def convert_to_dict_list(image_root, id_map, imgs, anns, dataset_name=None): ...@@ -199,10 +201,11 @@ def convert_to_dict_list(image_root, id_map, imgs, anns, dataset_name=None):
continue # ignore this instance continue # ignore this instance
obj["segmentation"] = segm obj["segmentation"] = segm
if len(obj["bbox"]) == 5: if "bbox_mode" not in obj:
obj["bbox_mode"] = BoxMode.XYWHA_ABS if len(obj["bbox"]) == 5:
else: obj["bbox_mode"] = BoxMode.XYWHA_ABS
obj["bbox_mode"] = BoxMode.XYWH_ABS else:
obj["bbox_mode"] = BoxMode.XYWH_ABS
if id_map: if id_map:
obj["category_id"] = id_map[obj["category_id"]] obj["category_id"] = id_map[obj["category_id"]]
objs.append(obj) objs.append(obj)
......
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