|
@@ -6,15 +6,9 @@ from cvdatasets.annotation.types.json_annotations import JSONAnnotations
|
|
|
|
|
|
from cvargparse.utils import BaseChoiceType
|
|
|
from cvargparse.utils.enumerations import MetaBaseType
|
|
|
+from cvdatasets.utils import read_info_file
|
|
|
|
|
|
-class AnnotationMetaType(MetaBaseType):
|
|
|
-
|
|
|
- def __getitem__(cls, key):
|
|
|
- res = super(AnnotationMetaType, cls).__getitem__(key)
|
|
|
- res.value.name = key
|
|
|
- return res
|
|
|
-
|
|
|
-class AnnotationType(BaseChoiceType, metaclass=AnnotationMetaType):
|
|
|
+class AnnotationType(BaseChoiceType):
|
|
|
FOLDER = FolderAnnotations
|
|
|
FILE_LIST = FileListAnnotations
|
|
|
JSON = JSONAnnotations
|
|
@@ -23,7 +17,15 @@ class AnnotationType(BaseChoiceType, metaclass=AnnotationMetaType):
|
|
|
|
|
|
@classmethod
|
|
|
def new_annotation(cls, opts):
|
|
|
- annot = cls[opts.dataset].value
|
|
|
+ if opts.dataset in cls:
|
|
|
+ annot = cls[opts.dataset].value
|
|
|
+ else:
|
|
|
+ info_file = read_info_file(opts.data)
|
|
|
+ assert opts.dataset in info_file.DATASETS, \
|
|
|
+ f"No information was found about the dataset \"{args.dataset}\" in the info file \"{args.data}\""
|
|
|
+ ds_info = info_file.DATASETS[opts.dataset]
|
|
|
+ annot = cls[ds_info.annotation_type.lower()].value
|
|
|
+
|
|
|
return annot.new(opts)
|
|
|
|
|
|
@classmethod
|