Data annotation logic.
RegionShape[source]
Enum= [NONE, CIRCLE, ELLIPSE, POINT, POLYGON, POLYLINE, RECTANGLE]
The supported region shape types
parse_region_shape[source]
parse_region_shape(shape_str)
Try to parse the region shape from a string representation.
shape_str: the shape as string
return: the parsed RegionShape
raises: ValueError if unsupported shape parsed
class Region[source]
Region(shape=<RegionShape.NONE: 'none'>,points_x=None,points_y=None,radius_x=0,radius_y=0,rotation=0,labels=None)
A region
shape: the region shape
points_x: a list of points x-coordinates
points_y: a list of points y-coordinates
radius_x: a radius on x-coordinate
radius_y: a radius on y-coordinate
rotation: a rotation factor
labels: a set of region labels
class Annotation[source]
Annotation(annotation_id=None,file_path=None,regions=None)
A annotation for a file.
annotation_id: a unique annotation identifier
file_name: the file
file_path: the file path
regions: A list of regions
Annotation.labels[source]
Annotation.labels()
Returns a list of labels, assigned to the annotation. return: a list of labels
annotation_filter[source]
annotation_filter(annotations,condition)
Filter annotations.
annotations: the annotations to filter
condition: the filter callback
return: the filtered annotations
convert_region[source]
convert_region(region:Region,target_shape:RegionShape)
Convert region to target shape.
region: the region to convert
target_shape: the target shape to convert to
class AnnotationAdapter[source]
AnnotationAdapter(path,categories_file_name=None) ::ABC
Abstract Base Adapter to inherit for writing custom adapters
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
AnnotationAdapter.read_annotations[source]
AnnotationAdapter.read_annotations(subset_type=<SubsetType.TRAINVAL: 'trainval'>)
Read annotations.
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
AnnotationAdapter.write_annotations[source]
AnnotationAdapter.write_annotations(annotations,subset_type=<SubsetType.TRAINVAL: 'trainval'>)
Write annotations.
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
AnnotationAdapter.argparse[source]
AnnotationAdapter.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