Adapter to read and write annotations for multi label classification.
The adapter has the following parameters:
--path
: the path to the base folder containing the annotations (e.g.: data/image_classification/my_collection)
--categories_file_name
: tThe path to the categories file if not set, default to categories.txt
--annotations_file_name
: The name of annotations file. if not set, default to annotations.csv
MultiCategoryAnnotationAdapter
(path
, categories_file_name
=None
, annotations_file_name
=None
) :: AnnotationAdapter
Adapter to read and write annotations for multi label classification.
AnnotationAdapter.list_files
(subset_type
=<SubsetType.TRAINVAL: 'trainval'>
)
List all physical files in a sub-set.
subset_type
: the subset type to list
return: a list of file paths if subset type exist, else an empty list
MultiCategoryAnnotationAdapter.read_annotations
(subset_type
=<SubsetType.TRAINVAL: 'trainval'>
)
Read annotations from a multi classification CSV annotations file.
subset_type
: the subset type to read
return: the annotations as dictionary
AnnotationAdapter.read_categories
()
Read categories.
return: a list of category names
AnnotationAdapter.write_files
(file_paths
, subset_type
=<SubsetType.TRAINVAL: 'trainval'>
)
Write physical files in a sub-set.
file_paths
: a list of file paths to write
subset_type
: the subset type to write into
return: a list of written target file paths
MultiCategoryAnnotationAdapter.write_annotations
(annotations
, subset_type
=<SubsetType.TRAINVAL: 'trainval'>
)
Writes a multi classification CSV annotations file and copy the corresponding source files.
annotations
: the annotations as dictionary
subset_type
: the subset type to write
return: a list of written target file paths
AnnotationAdapter.write_categories
(categories
)
Write categories.
categories
: a list of category names
MultiCategoryAnnotationAdapter.argparse
(prefix
=None
)
Returns the argument parser containing argument definition for command line use.
prefix
: a parameter prefix to set, if needed
return: the argument parser