"src/vscode:/vscode.git/clone" did not exist on "115ac0b9a3dbd806cc52f2a428048b79502f2350"
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):
obj = {
field: anno[field]
# 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
}
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"])):
num_instances_without_valid_bounding_box += 1
continue
......@@ -199,10 +201,11 @@ def convert_to_dict_list(image_root, id_map, imgs, anns, dataset_name=None):
continue # ignore this instance
obj["segmentation"] = segm
if len(obj["bbox"]) == 5:
obj["bbox_mode"] = BoxMode.XYWHA_ABS
else:
obj["bbox_mode"] = BoxMode.XYWH_ABS
if "bbox_mode" not in obj:
if len(obj["bbox"]) == 5:
obj["bbox_mode"] = BoxMode.XYWHA_ABS
else:
obj["bbox_mode"] = BoxMode.XYWH_ABS
if id_map:
obj["category_id"] = id_map[obj["category_id"]]
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