|
@@ -3,10 +3,10 @@ import numpy as np
|
|
|
from os.path import join
|
|
|
|
|
|
from nabirds.utils import _MetaInfo
|
|
|
-from .base import BaseAnnotations
|
|
|
+from .base import BaseAnnotations, BBoxMixin
|
|
|
|
|
|
|
|
|
-class CARS_Annotations(BaseAnnotations):
|
|
|
+class CARS_Annotations(BaseAnnotations, BBoxMixin):
|
|
|
name="CARS"
|
|
|
|
|
|
@property
|
|
@@ -37,12 +37,6 @@ class CARS_Annotations(BaseAnnotations):
|
|
|
# set labels from [1..N] to [0..N-1]
|
|
|
self.labels -= 1
|
|
|
|
|
|
- def _load_split(self):
|
|
|
- assert self._split is not None, "Train-test split was not loaded!"
|
|
|
- uuid_to_split = {uuid: int(split) for uuid, split in zip(self.uuids, self._split)}
|
|
|
- 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)
|
|
|
-
|
|
|
def _load_parts(self):
|
|
|
self.part_names = {}
|
|
|
|
|
@@ -52,22 +46,7 @@ class CARS_Annotations(BaseAnnotations):
|
|
|
|
|
|
self._load_bounding_boxes()
|
|
|
|
|
|
- def _load_bounding_boxes(self):
|
|
|
- assert self._bounding_boxes is not None, "Bouding boxes were not loaded!"
|
|
|
-
|
|
|
- uuid_to_bbox = {}
|
|
|
- for content in [i.split() for i in self._bounding_boxes]:
|
|
|
- uuid, bbox = content[0], content[1:]
|
|
|
- uuid_to_bbox[uuid] = [float(i) for i in bbox]
|
|
|
-
|
|
|
- self.bounding_boxes = np.array(
|
|
|
- [tuple(uuid_to_bbox[uuid]) for uuid in self.uuids],
|
|
|
- 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):
|
|
|
- return self.bounding_boxes[self.uuid_to_idx[uuid]].copy()
|