ImageAnnotationPreview

Introduction

ImageAnnotationPreview is a widget for displaying image annotation.

Function signature

image_preview = ImageAnnotationPreview(
    annotations_opacity = 0.5,
    enable_zoom = False,
    line_width = 1,
)

Parameters

Parameters
Type
Description

annotations_opacity

float

Opacity of the annotation

enable_zoom

bool

If True allows to zoom image

line_width

int

Width of the annotation border (contour) line

widget_id

str

ID of the widget

annotations_opacity

Annotation opacity. Value must be between 0 and 1. Set to 0 to hide annotations.

type: float

default value: 0.5

enable_zoom

If True, allows to zoom image with the mouse wheel.

type: bool

default value: False

line_width

Width of the annotation border (contour) line. Set to 0 to hide line.

type: int

default value: 1

widget_id

ID of the widget.

type: str

default value: None

Methods and attributes

Attributes and Methods
Description

set()

Set image and annotation to widget.

clean_up()

Clean up widget from image.

is_empty()

Return bool value, whether image is set or not.

Mini App Example

You can find this example in our Github repository:

supervisely-ecosystem/ui-widgets-demos/media/015_image_annotation_preview/src/main.py

Import libraries

Init API client

First, we load environment variables with credentials and init API for communicating with Supervisely Instance:

Initialize Project ID

Get Project ID and meta

Get images from dataset

Get annotation for image

Initialize ImageAnnotationPreview widget and set image with annotation and project meta

Add button widget to show random image, we will use it later

Create app layout

Prepare a layout for app using Card widget with the content parameter and place widgets that we've just created in the Container widget.

Create app using layout

Create an app object with layout parameter.

Add button click event to update preview

Last updated

Was this helpful?