|
@@ -9,36 +9,11 @@ from cvdatasets.annotations.base.parts_mixin import PartsMixin
|
|
from cvdatasets.utils import _MetaInfo
|
|
from cvdatasets.utils import _MetaInfo
|
|
|
|
|
|
|
|
|
|
-class INAT19_Annotations(BBoxMixin, PartsMixin, BaseAnnotations):
|
|
|
|
-
|
|
|
|
- name="INAT19"
|
|
|
|
-
|
|
|
|
- @property
|
|
|
|
- def meta(self):
|
|
|
|
- info = _MetaInfo(
|
|
|
|
- images_folder="images",
|
|
|
|
- content="trainval2019.json",
|
|
|
|
- val_content="val2019.json",
|
|
|
|
- # 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"),
|
|
|
|
- part_names_file=join("parts", "parts.txt"),
|
|
|
|
- )
|
|
|
|
-
|
|
|
|
- info.structure = [
|
|
|
|
- [info.content, "_content"],
|
|
|
|
- [info.val_content, "_val_content"],
|
|
|
|
- [info.parts_file, "_part_locs"],
|
|
|
|
- [info.part_names_file, "_part_names"],
|
|
|
|
- ]
|
|
|
|
- return info
|
|
|
|
|
|
+class BaseINAT_Annotations(BBoxMixin, PartsMixin, BaseAnnotations):
|
|
|
|
|
|
def read_content(self, json_file, attr):
|
|
def read_content(self, json_file, attr):
|
|
if not json_file.endswith(".json"):
|
|
if not json_file.endswith(".json"):
|
|
- return super(INAT19_Annotations, self).read_content(json_file, attr)
|
|
|
|
|
|
+ return super(BaseINAT_Annotations, self).read_content(json_file, attr)
|
|
with self._open(json_file) as f:
|
|
with self._open(json_file) as f:
|
|
content = json.load(f)
|
|
content = json.load(f)
|
|
setattr(self, attr, content)
|
|
setattr(self, attr, content)
|
|
@@ -69,3 +44,61 @@ class INAT19_Annotations(BBoxMixin, PartsMixin, BaseAnnotations):
|
|
uuid_fnames = [(str(im["id"]), im["file_name"]) for im in self._content["images"]]
|
|
uuid_fnames = [(str(im["id"]), im["file_name"]) for im in self._content["images"]]
|
|
self.uuids, self.images = map(np.array, zip(*uuid_fnames))
|
|
self.uuids, self.images = map(np.array, zip(*uuid_fnames))
|
|
self.uuid_to_idx = {uuid: i for i, uuid in enumerate(self.uuids)}
|
|
self.uuid_to_idx = {uuid: i for i, uuid in enumerate(self.uuids)}
|
|
|
|
+
|
|
|
|
+ @property
|
|
|
|
+ def meta(self):
|
|
|
|
+ raise NotImplementedError
|
|
|
|
+
|
|
|
|
+class INAT19_Annotations(BaseINAT_Annotations):
|
|
|
|
+
|
|
|
|
+ name="INAT19"
|
|
|
|
+
|
|
|
|
+ @property
|
|
|
|
+ def meta(self):
|
|
|
|
+ info = _MetaInfo(
|
|
|
|
+ images_folder="images",
|
|
|
|
+ content="trainval2019.json",
|
|
|
|
+ val_content="val2019.json",
|
|
|
|
+ # 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"),
|
|
|
|
+ part_names_file=join("parts", "parts.txt"),
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+ info.structure = [
|
|
|
|
+ [info.content, "_content"],
|
|
|
|
+ [info.val_content, "_val_content"],
|
|
|
|
+ [info.parts_file, "_part_locs"],
|
|
|
|
+ [info.part_names_file, "_part_names"],
|
|
|
|
+ ]
|
|
|
|
+ return info
|
|
|
|
+
|
|
|
|
+class INAT18_Annotations(BaseINAT_Annotations):
|
|
|
|
+
|
|
|
|
+ name="INAT18"
|
|
|
|
+
|
|
|
|
+ @property
|
|
|
|
+ def meta(self):
|
|
|
|
+ info = _MetaInfo(
|
|
|
|
+ images_folder="images",
|
|
|
|
+ content="trainval2018.json",
|
|
|
|
+ # content="train2018.json",
|
|
|
|
+ val_content="val2018.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"),
|
|
|
|
+ part_names_file=join("parts", "parts.txt"),
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+ info.structure = [
|
|
|
|
+ [info.content, "_content"],
|
|
|
|
+ [info.val_content, "_val_content"],
|
|
|
|
+ [info.parts_file, "_part_locs"],
|
|
|
|
+ [info.part_names_file, "_part_names"],
|
|
|
|
+ ]
|
|
|
|
+ return info
|