|
@@ -20,21 +20,27 @@ class INAT19_Annotations(BaseAnnotations):
|
|
|
# train_content="train2019.json",
|
|
|
|
|
|
# fake bounding boxes: the whole image
|
|
|
- bounding_box_dtype=np.dtype([(v, np.int32) for v in "xywh"])
|
|
|
+ parts_file=join("parts", "part_locs.txt"),
|
|
|
+ bounding_box_dtype=np.dtype([(v, np.int32) for v in "xywh"]),
|
|
|
)
|
|
|
|
|
|
info.structure = [
|
|
|
[info.content, "_content"],
|
|
|
[info.val_content, "_val_content"],
|
|
|
+ [info.parts_file, "_part_locs"],
|
|
|
]
|
|
|
return info
|
|
|
|
|
|
def read_content(self, json_file, attr):
|
|
|
+ if not json_file.endswith(".json"):
|
|
|
+ return super(INAT19_Annotations, self).read_content(json_file, attr)
|
|
|
with self._open(json_file) as f:
|
|
|
content = json.load(f)
|
|
|
setattr(self, attr, content)
|
|
|
|
|
|
- def parts(self, uuids):
|
|
|
+ def parts(self, *args, **kwargs):
|
|
|
+ if self.has_parts:
|
|
|
+ return super(INAT19_Annotations, self).parts(*args, **kwargs)
|
|
|
return None
|
|
|
|
|
|
def bounding_box(self, uuid):
|
|
@@ -49,6 +55,10 @@ class INAT19_Annotations(BaseAnnotations):
|
|
|
|
|
|
def _load_parts(self):
|
|
|
self.part_names = {}
|
|
|
+
|
|
|
+ # load only if present
|
|
|
+ if self.has_parts:
|
|
|
+ super(INAT19_Annotations, self)._load_parts()
|
|
|
self._load_bounding_boxes()
|
|
|
|
|
|
def _load_split(self):
|