瀏覽代碼

changed the way different annotation files are loaded

Dimitri Korsch 5 年之前
父節點
當前提交
7ae8744d95

+ 9 - 5
cvdatasets/annotation/base.py

@@ -167,21 +167,25 @@ class BaseAnnotations(abc.ABC):
 		logging.debug("Final kwargs: {}".format(pretty_print_dict(new_kwargs)))
 		logging.debug("Final kwargs: {}".format(pretty_print_dict(new_kwargs)))
 		return new_kwargs
 		return new_kwargs
 
 
-	@abc.abstractmethod
 	def read_annotation_files(self) -> AnnotationFiles:
 	def read_annotation_files(self) -> AnnotationFiles:
 		logging.debug("Creating default AnnotationFiles object")
 		logging.debug("Creating default AnnotationFiles object")
-		return AnnotationFiles(root=self.root, load_strict=self.load_strict)
+		files = AnnotationFiles(root=self.root, load_strict=self.load_strict)
+		return self.load_files(files)
+
+	@abc.abstractmethod
+	def load_files(self, files_obj) -> AnnotationFiles:
+		return files_obj
 
 
 	@abc.abstractmethod
 	@abc.abstractmethod
-	def _parse_uuids(self):
+	def _parse_uuids(self) -> None:
 		pass
 		pass
 
 
 	@abc.abstractmethod
 	@abc.abstractmethod
-	def _parse_labels(self):
+	def _parse_labels(self) -> None:
 		pass
 		pass
 
 
 	@abc.abstractmethod
 	@abc.abstractmethod
-	def _parse_split(self):
+	def _parse_split(self) -> None:
 		pass
 		pass
 
 
 
 

+ 3 - 4
cvdatasets/annotation/types/file_list.py

@@ -5,10 +5,9 @@ from cvdatasets.annotation.files import AnnotationFiles
 
 
 class FileListAnnotations(Annotations):
 class FileListAnnotations(Annotations):
 
 
-	def read_annotation_files(self) -> AnnotationFiles:
-		files = super(FileListAnnotations, self).read_annotation_files()
-		files.load_files("images.txt", "labels.txt", "tr_ID.txt")
-		return files
+	def load_files(self, file_obj) -> AnnotationFiles:
+		file_obj.load_files("images.txt", "labels.txt", "tr_ID.txt")
+		return file_obj
 
 
 	def _parse_uuids(self) -> None:
 	def _parse_uuids(self) -> None:
 		assert self.files.images is not None, \
 		assert self.files.images is not None, \

+ 3 - 4
cvdatasets/annotation/types/folder_annotations.py

@@ -5,14 +5,13 @@ from cvdatasets.annotation.files import AnnotationFiles
 
 
 class FolderAnnotations(Annotations):
 class FolderAnnotations(Annotations):
 
 
-	def read_annotation_files(self) -> AnnotationFiles:
-		files = super(FileListAnnotations, self).read_annotation_files()
-		files.load_files(
+	def load_files(self, file_obj) -> AnnotationFiles:
+		file_obj.load_files(
 			train_images="ILSVRC2012_img_train",
 			train_images="ILSVRC2012_img_train",
 			val_images="ILSVRC2012_img_val",
 			val_images="ILSVRC2012_img_val",
 			test_images=("ILSVRC2012_img_test", True),
 			test_images=("ILSVRC2012_img_test", True),
 		)
 		)
-		return files
+		return file_obj
 
 
 	@property
 	@property
 	def _has_test_set(self) -> bool:
 	def _has_test_set(self) -> bool:

+ 3 - 4
cvdatasets/annotation/types/json_annotations.py

@@ -14,13 +14,12 @@ def _uuid_entry(im_info):
 
 
 class JSONAnnotations(Annotations):
 class JSONAnnotations(Annotations):
 
 
-	def read_annotation_files(self) -> AnnotationFiles:
-		files = super(JSONAnnotations, self).read_annotation_files()
-		files.load_files(
+	def load_files(self, file_obj) -> AnnotationFiles:
+		file_obj.load_files(
 			"trainval.json", "val.json",
 			"trainval.json", "val.json",
 			("unlabeled_train.json", True),
 			("unlabeled_train.json", True),
 		)
 		)
-		return files
+		return file_obj
 
 
 	@property
 	@property
 	def has_unlabeled_data(self) -> bool:
 	def has_unlabeled_data(self) -> bool: