Annotator
The Annotator component provides a GUI which allows the user to create or modify his data set with categories labels and/or meta-annotations.
AnnotatorClassification
The AnnotatorClassification class can be used to annotate data sets for classification tasks.
Parameters
- dataset, optional
DatasetClassification- Dataset to be modified with annotations. If not specified, a new one is created.
(default is None) - task_type
TaskType, optional- Problem task_type. If the dataset is not specified, it is a mandatory parameter.
(default is None) - observations
list, optional- List of observations path. If the dataset is not specified, it is a mandatory parameter.
(default is None) - classes_to_annotate
list, optional- List of categories to be annotated. If the dataset is not specified, it is a mandatory parameter.
(default is None) - output_path
str, optional- The path where the annotated data set will be saved. If the dataset is not specified, it is a mandatory parameter.
(default is None) - ds_name
str, optional- Name of the data set. If the dataset is not specified, it is a mandatory parameter.
(default is None) - properties_and_values
dict, optional- Meta-annotations and corresponding values used to annotate the data set. If not specified, only the categeories will be annotated.
(default is None)Example: {'property_name': (property_type, ['value1', 'value2', '...', 'valuen'])}
The meta-annotations can be of the following types: MetaPropertiesType.UNIQUE, MetaPropertiesType.TEXT, MetaPropertiesType.CONTINUE - show_name
bool, optional- Indicates whether to show the name of the file.
(default is True) - show_axis
bool, optional- Indicates whether to show the axis of the plot.
(default is False) - fig_size
pair, optional- Indicates the size of the figure visualized during the annotation process.
(default is (10, 10)) - buttons_vertical
bool, optional- Indicates whether to display the buttons vertically.
(default is False) - custom_display_function
function, optional- User custom display visualization.
(default is None) - validate_function
function, optional- Annotation process validation function.
(default is None) - show_reset
bool, optional- Indicates whether to show the 'reset annotation' button.
(default is True) - is_image
bool, optional- Indicates whether the observations represent images. If False, the 'custom_display_function' parameter is mandatory.
(default is True)
Example
Annotate a new data set with only categories labels
from odin.annotator import AnnotatorClassification
task_type = TaskType.CLASSIFICATION_MULTI_LABEL
images = ["path/image1.jpg", "path/image2.jpg", "...", "path/imagen.jpg"]
classes_to_annotate = ["category_a", "category_b", "...", "category_n"]
dataset_name = "my_dataset_name"
output_path = "new/dataset/output/path/"
my_annotator = AnnotatorClassification(task_type=task_type,
observations=images,
classes_to_annotate=classes,
output_path=output_path,
ds_name=dataset_name)
my_annotator.start_classification()
Annotate an existing data set with only meta-annotations
from odin.classes import DatasetClassification
from odin.annotator import AnnotatorClassification
dataset_gt = "path/to/gt/file.json"
images_path = "path/to/images"
classification_type = TaskType.CLASSIFICATION_MULTI_LABEL
my_dataset = DatasetClassification(dataset_gt,
classification_type,
observations_abs_path=images_path,
for_analysis=False)
meta_annotations = {"property_name": (MetaPropertiesType.UNIQUE, ["value1", "value2"])}
def validate_function(img_record):
return 'property_name' in img_record
my_annotator = AnnotatorClassification(dataset=my_dataset,
properties_and_values=meta_annotations,
validate_function=validate_function)
my_annotator.start_classification()
Annotate a new data set with categories labels and meta-annotations
from odin.annotator import AnnotatorClassification
task_type = TaskType.CLASSIFICATION_MULTI_LABEL
images = ["path/image1.jpg", "path/image2.jpg", "...", "path/imagen.jpg"]
classes_to_annotate = ["category_a", "category_b", "...", "category_n"]
dataset_name = "my_dataset_name"
output_path = "new/dataset/output/path/"
meta_annotations = {"property_name": (MetaPropertiesType.UNIQUE, ["value1", "value2"])}
my_annotator = AnnotatorClassification(task_type=task_type,
observations=images,
classes_to_annotate=classes,
output_path=output_path,
ds_name=dataset_name,
properties_and_values=meta_annotations)
my_annotator.start_classification()
AnnotatorLocalization
The AnnotatorLocalization class can be used to annotate data sets for localization tasks, such as object detection (it is possible to draw and annotate bounding boxes) and instance segmentation (it is possible to draw and annotate segmentation masks).
Parameters
- dataset, optional
DatasetLocalization- Dataset to be modified with annotations. If not specified, a new one is created.
(default is None) - task_type
TaskType, optional- Problem task_type. If the dataset is not specified, it is a mandatory parameter.
(default is None) - images
list, optional- List of images path. If the dataset is not specified, it is a mandatory parameter.
(default is None) - classes_to_annotate
list, optional- List of categories to be annotated. If the dataset is not specified, it is a mandatory parameter.
(default is None) - output_path
str, optional- The path where the annotated data set will be saved. If the dataset is not specified, it is a mandatory parameter.
(default is None) - ds_name
str, optional- Name of the data set. If the dataset is not specified, it is a mandatory parameter.
(default is None) - properties_and_values
dict, optional- Meta-annotations and corresponding values used to annotate the data set. If not specified, only the categeories will be annotated..
(default is None)Example: {'property_name': (property_type, ['value1', 'value2', '...', 'valuen'])}
The meta-annotations can be of the following types: MetaPropertiesType.UNIQUE, MetaPropertiesType.TEXT, MetaPropertiesType.CONTINUE - show_name
bool, optional- Indicates whether to show the name of the file.
(default is True) - show_axis
bool, optional- Indicates whether to show the axis of the plot.
(default is False) - fig_size
pair, optional- Indicates the size of the figure visualized during the annotation process.
(default is (10, 10)) - buttons_vertical
bool, optional- Indicates whether to display the buttons vertically.
(default is False) - custom_display_function
function, optional- User custom display visualization.
(default is None) - validate_function
function, optional- Annotation process validation function.
(default is None) - show_reset
bool, optional- Indicates whether to show the 'reset annotation' button.
(default is True)
Example
Annotate a new data set with only categories labels
from odin.annotator import AnnotatorLocalization
task_type = TaskType.OBJECT_DETECTION
images = ["path/image1.jpg", "path/image2.jpg", "...", "path/imagen.jpg"]
classes_to_annotate = ["category_a", "category_b", "...", "category_n"]
dataset_name = "my_dataset_name"
output_path = "new/dataset/output/path/"
my_annotator = AnnotatorLocalization(task_type=task_type,
images=images,
classes_to_annotate=classes,
output_path=output_path,
ds_name=dataset_name)
my_annotator.start_annotation()
Annotate an existing data set with only meta-annotations
from odin.classes import DatasetLocalization
from odin.annotator import AnnotatorLocalization
dataset_gt = "path/to/gt/file.json"
images_path = "path/to/images"
classification_type = TaskType.OBJECT_DETECTION
my_dataset = DatasetLocalization(dataset_gt,
classification_type,
images_abs_path=images_path,
for_analysis=False)
meta_annotations = {"property_name": (MetaPropertiesType.UNIQUE, ["value1", "value2"])}
def validate_function(img_record):
return 'property_name' in img_record
my_annotator = AnnotatorLocalization(dataset=my_dataset,
properties_and_values=meta_annotations,
validate_function=validate_function)
my_annotator.start_annotation()
Annotate a new data set with categories labels and meta-annotations
from odin.annotator import AnnotatorLocalization
task_type = TaskType.INSTANCE_SEGMENTATION
images = ["path/image1.jpg", "path/image2.jpg", "...", "path/imagen.jpg"]
classes_to_annotate = ["category_a", "category_b", "...", "category_n"]
dataset_name = "my_dataset_name"
output_path = "new/dataset/output/path/"
meta_annotations = {"property_name": (MetaPropertiesType.UNIQUE, ["value1", "value2"])}
my_annotator = AnnotatorLocalization(task_type=task_type,
images=images,
classes_to_annotate=classes,
output_path=output_path,
ds_name=dataset_name,
properties_and_values=meta_annotations)
my_annotator.start_annotation()