From 017b1c092e577bd5b6aa86d9a980ee307710879a Mon Sep 17 00:00:00 2001 From: Christoffer Date: Thu, 12 Oct 2023 12:24:10 +0200 Subject: [PATCH] fixed darwin v1 annotation loading bug (ignored bboxes when loading polygons) --- darwin/utils/utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/darwin/utils/utils.py b/darwin/utils/utils.py index 575c50843..6a5beb41f 100644 --- a/darwin/utils/utils.py +++ b/darwin/utils/utils.py @@ -616,6 +616,8 @@ def _parse_darwin_annotation(annotation: Dict[str, Any]) -> Optional[dt.Annotati # Darwin JSON 1.0 representation of complex and simple polygons elif "polygon" in annotation: bounding_box = annotation.get("bounding_box") + if bounding_box is None: + bounding_box = annotation["polygon"].get("bounding_box") if "additional_paths" in annotation["polygon"]: paths = [annotation["polygon"]["path"]] + annotation["polygon"]["additional_paths"] main_annotation = dt.make_complex_polygon(name, paths, bounding_box, slot_names=slot_names) @@ -624,6 +626,8 @@ def _parse_darwin_annotation(annotation: Dict[str, Any]) -> Optional[dt.Annotati # Darwin JSON 1.0 representation of complex polygons elif "complex_polygon" in annotation: bounding_box = annotation.get("bounding_box") + if bounding_box is None: + bounding_box = annotation["polygon"].get("bounding_box") if isinstance(annotation["complex_polygon"]["path"][0], list): paths = annotation["complex_polygon"]["path"] else: