|
@@ -1,5 +1,8 @@
|
|
|
import numpy as np
|
|
|
|
|
|
+from pathlib import Path
|
|
|
+
|
|
|
+from cvdatasets import utils
|
|
|
from cvdatasets.annotation.base import Annotations
|
|
|
from cvdatasets.annotation.files import AnnotationFiles
|
|
|
|
|
@@ -42,22 +45,27 @@ class FolderAnnotations(Annotations):
|
|
|
def _has_test_set(self) -> bool:
|
|
|
return self.files.test_images is not None
|
|
|
|
|
|
+ def _uuid_from_path(self, fpath):
|
|
|
+ return "_".join(Path(fpath).relative_to(self.root).parts)
|
|
|
+ # return "_".join(Path(fpath).parts[-3:])
|
|
|
|
|
|
def _parse_uuids(self) -> None:
|
|
|
self.images_folder = ""
|
|
|
|
|
|
- train_uuid_fnames = [(fpath.name, str(fpath.relative_to(self.root))) for
|
|
|
+ train_uuid_fnames = [(self._uuid_from_path(fpath), str(fpath.relative_to(self.root))) for
|
|
|
fpath in self.files.train_images]
|
|
|
|
|
|
- val_uuid_fnames = [(fpath.name, str(fpath.relative_to(self.root))) for
|
|
|
+ val_uuid_fnames = [(self._uuid_from_path(fpath), str(fpath.relative_to(self.root))) for
|
|
|
fpath in self.files.val_images]
|
|
|
|
|
|
if self._has_test_set:
|
|
|
- test_uuid_fnames = [(fpath.name, str(fpath.relative_to(self.root))) for
|
|
|
+ test_uuid_fnames = [(self._uuid_from_path(fpath), str(fpath.relative_to(self.root))) for
|
|
|
fpath in self.files.test_images]
|
|
|
|
|
|
uuid_fnames = train_uuid_fnames + val_uuid_fnames
|
|
|
self.uuids, self.image_names = map(np.array, zip(*uuid_fnames))
|
|
|
+
|
|
|
+ utils.dataset._uuid_check(self.uuids)
|
|
|
self.uuid_to_idx = {uuid: i for i, uuid in enumerate(self.uuids)}
|
|
|
|
|
|
|