Adapter to read and write annotations where the folder structure represents the categories.

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
  • --category_index: The folder index, representing the category, default to -1 (the parent folder of the file)

class FolderCategoryAnnotationAdapter[source]

FolderCategoryAnnotationAdapter(path, categories_file_name=None, category_index=None) :: AnnotationAdapter

Adapter to read and write annotations where the folder structure represents the categories.

AnnotationAdapter.list_files[source]

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

FolderCategoryAnnotationAdapter.read_annotations[source]

FolderCategoryAnnotationAdapter.read_annotations(subset_type=<SubsetType.TRAINVAL: 'trainval'>)

Read annotations from folder structure representing the categories. subset_type: the subset type to read return: the annotations as dictionary

AnnotationAdapter.read_categories[source]

AnnotationAdapter.read_categories()

Read categories. return: a list of category names

AnnotationAdapter.write_files[source]

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

FolderCategoryAnnotationAdapter.write_annotations[source]

FolderCategoryAnnotationAdapter.write_annotations(annotations, subset_type=<SubsetType.TRAINVAL: 'trainval'>)

Write annotations to folder structure representing the categories. annotations: the annotations as dictionary subset_type: the subset type to write return: a list of written target file paths

AnnotationAdapter.write_categories[source]

AnnotationAdapter.write_categories(categories)

Write categories. categories: a list of category names

FolderCategoryAnnotationAdapter.argparse[source]

FolderCategoryAnnotationAdapter.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