From 13d9290a998045e44196e0ce1239dc81e7e8078b Mon Sep 17 00:00:00 2001 From: Lei Xu Date: Fri, 16 Sep 2022 12:07:55 -0700 Subject: [PATCH] Convert coco bounding box format to [x0,y0,x1,y1] format. (#169) --- python/benchmarks/parse_coco.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/benchmarks/parse_coco.py b/python/benchmarks/parse_coco.py index 7680ac09cd..4f9e80e3d0 100755 --- a/python/benchmarks/parse_coco.py +++ b/python/benchmarks/parse_coco.py @@ -28,6 +28,10 @@ def _instances_to_df(self, split, instances_json): df = pd.DataFrame(instances_json["annotations"]) df["segmentation"] = df.segmentation.apply(_convert_segmentation) df["iscrowd"] = df.iscrowd.astype("bool") + # Convert coco dataset bounding box [x,y,width,height] to [x0,y0,x1,y1] format. + df["bbox"] = df.bbox.apply( + lambda arr: [arr[0], arr[1], arr[0] + arr[2], arr[1] + arr[3]] + ) category_df = pd.DataFrame(instances_json["categories"]).rename( {"id": "category_id"}, axis=1 )