|
@@ -18,12 +18,16 @@ class CARS_Annotations(BaseAnnotations):
|
|
|
split_file="tr_ID.txt",
|
|
|
bounding_boxes="bounding_boxes.txt",
|
|
|
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.images_file, "_images"],
|
|
|
[info.labels_file, "labels"],
|
|
|
[info.split_file, "_split"],
|
|
|
+ [info.parts_file, "_part_locs"],
|
|
|
+ [info.part_names_file, "_part_names"],
|
|
|
[info.bounding_boxes, "_bounding_boxes"],
|
|
|
]
|
|
|
return info
|
|
@@ -39,8 +43,17 @@ class CARS_Annotations(BaseAnnotations):
|
|
|
self.train_split = np.array([uuid_to_split[uuid] for uuid in self.uuids], dtype=bool)
|
|
|
self.test_split = np.logical_not(self.train_split)
|
|
|
|
|
|
+ @property
|
|
|
+ def has_parts(self):
|
|
|
+ return self._part_locs is not None
|
|
|
+
|
|
|
def _load_parts(self):
|
|
|
self.part_names = {}
|
|
|
+
|
|
|
+ # load only if present
|
|
|
+ if self.has_parts:
|
|
|
+ super(CARS_Annotations, self)._load_parts()
|
|
|
+
|
|
|
self._load_bounding_boxes()
|
|
|
|
|
|
def _load_bounding_boxes(self):
|
|
@@ -56,6 +69,8 @@ class CARS_Annotations(BaseAnnotations):
|
|
|
dtype=self.meta.bounding_box_dtype)
|
|
|
|
|
|
def parts(self, *args, **kwargs):
|
|
|
+ if self.has_parts:
|
|
|
+ return super(CARS_Annotations, self).parts(*args, **kwargs)
|
|
|
return None
|
|
|
|
|
|
def bounding_box(self, uuid):
|