API Index

Annotation widgets

class ipyannotations.PolygonAnnotator(canvas_size: Tuple[int, int] = (700, 500), classes: Optional[List[str]] = None)

An annotator for drawing polygons on an image.

Parameters
  • canvas_size ((int, int), optional) – Size of the annotation canvas, by default (500, 500)

  • classes (List[str], optional) – The list of classes you want to create annotations for, by default None.

Methods

display(image: Union[ipywidgets.widgets.widget_media.Image, pathlib.Path])

Clear the annotations and display an image

Parameters

image (widgets.Image, pathlib.Path, np.ndarray) – The image, or the path to the image.

on_submit(callback: Callable[[Any], None])

Register a callback to handle data when the user clicks “Submit”.

Note

Callbacks are called in order of registration - first registered, first called.

Parameters

callback (Callable[[Any], None]) – A function that takes in data. Usually, this data is a list of dictionaries, but you are able to define data post-processors when you create an annotator that get called before this callback is called. Any return values are ignored.

on_skip(callback: Callable[[], None])

Register a callback to handle when the user clicks “Skip”.

Parameters

callback (Callable[[], None]) – The function to be called when the user clicks “Skip”. It should take no arguments, and any return values are ignored.

on_undo(callback: Callable[[], None])

Register a callback to handle when the user clicks “Undo”.

Note that any callback registered here is only called when the canvas is empty - while there are annotations on the canvas, “Undo” actually undoes the annotations, until the canvas is empty.

Parameters

callback (Callable[[], None]) – A function to be called when users press “Undo”. This should be a function that takes in no arguments; any return values are ignored.

Attributes

options

An instance of a Python list.

data

The annotation data.

class ipyannotations.PointAnnotator(canvas_size=(700, 500), classes=None)

An annotator for drawing points on an image.

Parameters
  • canvas_size ((int, int), optional) – Size of the annotation canvas, by default (500, 500)

  • classes (List[str], optional) – The list of classes you want to create annotations for, by default None.

Methods

display(image: Union[ipywidgets.widgets.widget_media.Image, pathlib.Path])

Clear the annotations and display an image

Parameters

image (widgets.Image, pathlib.Path, np.ndarray) – The image, or the path to the image.

on_submit(callback: Callable[[Any], None])

Register a callback to handle data when the user clicks “Submit”.

Note

Callbacks are called in order of registration - first registered, first called.

Parameters

callback (Callable[[Any], None]) – A function that takes in data. Usually, this data is a list of dictionaries, but you are able to define data post-processors when you create an annotator that get called before this callback is called. Any return values are ignored.

on_skip(callback: Callable[[], None])

Register a callback to handle when the user clicks “Skip”.

Parameters

callback (Callable[[], None]) – The function to be called when the user clicks “Skip”. It should take no arguments, and any return values are ignored.

on_undo(callback: Callable[[], None])

Register a callback to handle when the user clicks “Undo”.

Note that any callback registered here is only called when the canvas is empty - while there are annotations on the canvas, “Undo” actually undoes the annotations, until the canvas is empty.

Parameters

callback (Callable[[], None]) – A function to be called when users press “Undo”. This should be a function that takes in no arguments; any return values are ignored.

Attributes

options

An instance of a Python list.

data

The annotation data.