A Python library for computer vision annotation tasks using Dash
Project description
Dash Annotate CV - A dash library for computer vision annotation tasks
dash_annotate_cv
is a Python Dash library for computer vision annotation tasks. It exposes reusable annotation components in a library format for dash
.
Supported tasks:
- Annotation of images (whole image labels)
Roadmap for future tasks:
- Annotating multiple labels per image
- Annotating bounding boxes
- Annotating videos
- Annotating tags
Note: 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.
conda create -n dash_annotate_cv python=3.11 conda activate dash_annotate_cv
-
Install.
pip install dash_annotate_cv
Or from the repository:
pip install -r requirements.txt pip install -e .
-
Run the example as described next.
Examples
The 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.
Each is described here briefly. You can also check out the examples.
Command line utility
To get started labeling immediately, you can use a simple command line utility. You just need to write a config YAML file. You can see the examples directory for more examples - as simple example is as follows:
# Annotation mode
# image_labels = Annotate images with whole-image labels
mode: image_labels
# Label source
label_source:
labels:
- astronaut
- camera
- cat
# Image source
image_source:
# Image source type
source_type: list_of_files
# List of files
list_of_files:
- ex_chelsea.jpg
- ex_astronaut.jpg
- ex_camera.jpg
# Storage (optional)
storage:
storage_type: json
json_file: example.json
# Options (optional)
options_image_labels:
# How many labels can be selected per image
selection_mode: single
To launch the app, simply run:
dacv conf.yml
Navigate to the default address http://127.0.0.1:8050/
in your browser to use the app.
Use dacv -h
for a complete list of options. Or check out the examples directory for more examples.
Python
You 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 library
import dash_annotate_cv as dac
# Other imports
from dash import Dash, html
import dash_bootstrap_components as dbc
from skimage import data
# Load some images
images = [ ("chelsea",data.chelsea()), ("astronaut",data.astronaut()), ("camera",data.camera()) ]
# Set up the image and label sources
image_source = dac.ImageSource(images=images)
label_source = dac.LabelSource(labels=["astronaut", "camera", "cat"])
# Set up writing
storage = dac.AnnotationStorage(storage_type=dac.AnnotationStorage.Type.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 the examples directory for more examples.
Loading the annotations & format
Loading the annotations is as simple as:
with open("annotations.json","r") as f:
annotations = dac.ImageAnnotations.from_dict(json.load(f))
See the ImageAnnotations
class for more information on the format.
Dev
Some useful references:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for dash_annotate_cv-0.1.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9a238669e09f14b5cdcd36d9ced2429250615860449187245af4e1a9bd60eff |
|
MD5 | 8b5afce3fa501554e6e872848b14343f |
|
BLAKE2b-256 | 1e7dae5d47a85d7315fb242332cdb53bbb025295936be11b37281c1198de807c |