Package: dash-annotate-cv
Dash Annotate CV - A dash library for computer vision annotation tasksdash_annotate_cvis a Python Dash library for computer vision annotation tasks. It exposes reusable annotation components in a library format fordash.Example of whole-image label annotationsExample of bounding box annotationsSupported tasks:Annotation of images (whole image labels)Annotating multiple labels per imageAnnotating bounding boxes including labelsRoadmap for future tasks:Support for more annotation formats: YOLO, COCO, etc.Support for image segmentation tasks.Support for skeleton annotation tasks.Annotating video eventsAnnotating video tagsNote: this library is not meant for production usage. It is meant to be used for quick prototyping and testing of annotation tasks.Getting started(Recommended) Create a new conda environment.condacreate-ndash_annotate_cvpython=3.11
condaactivatedash_annotate_cvInstall using pip:pipinstalldash_annotate_cvOr local install from the repository:gitclonehttps://github.com/smrfeld/dash-annotate-cvcddash-annotate-cv
pipinstall-e.Run the example as described next.ExamplesThe app can be launched in two ways:A simple command line utility lets you get up and running quickly.The app can be launched by writing a short Python script, which lets you use the annotation components in a flexible way in your own Dash app. We follow the practices of resuable components in Dash described inAll-in-one components for Dash.Each is described here briefly. You can also check out theexamples.Command line utilityTo get started labeling immediately, you can use a simple command line utility. You just need to write a config YAML file. You can see theexamplesdirectory for more examples - as simple example is as follows:# Annotation mode# image_labels = Annotate images with whole-image labels# bboxs = Annotate bounding boxes in each imagemode:image_labels# Label sourcelabel_source:labels:-astronaut-camera-cat# Image sourceimage_source:# Image source typesource_type:list_of_files# List of fileslist_of_files:-ex_chelsea.jpg-ex_astronaut.jpg-ex_camera.jpg# Storage (optional)storage:storage_type:jsonjson_file:example.json# Options (optional)options:# How many labels can be selected per imageselection_mode:singleTo launch the app, simply run:dacvconf.ymlNavigate to the default addresshttp://127.0.0.1:8050/in your browser to use the app.Usedacv -hfor a complete list of options. Or check out theexamplesdirectory for more examples.PythonYou can use the library in your own Dash app. This is recommended as a more flexible way to create your own annotation interface. The following example shows how to use the library to annotate images with labels.# Import the libraryimportdash_annotate_cvasdac# Other importsfromdashimportDash,htmlimportdash_bootstrap_componentsasdbcfromskimageimportdata# Load some imagesimages=[("chelsea",data.chelsea()),("astronaut",data.astronaut()),("camera",data.camera())]# type: ignoreimages_pil=[(name,Image.fromarray(image))forname,imageinimages]# Set up the image and label sourcesimage_source=dac.ImageSource(images=images_pil)label_source=dac.LabelSource(labels=["astronaut","camera","cat"])# Set up writingstorage=dac.AnnotationStorage(storage_types=[dac.StorageType.JSON],json_file="annotations.json")app=Dash(__name__,external_stylesheets=[dbc.themes.BOOTSTRAP])app.layout=dbc.Container([html.H1("Annotate Images"),dac.AnnotateImageLabelsAIO(label_source,image_source,annotation_storage=storage)])app.run(debug=True)The result is shown in the gif above. Check out theexamplesdirectory for more examples.Loading the annotations & formatLoading the annotations is as simple as:withopen("annotations.json","r")asf:annotations=dac.ImageAnnotations.from_dict(json.load(f))See theImageAnnotationsclass for more information on the format.DevSome useful references:All-in-one components for DashImage annotation in Dash