CompareAnnotations
Introduction
CompareAnnotations
is a simple widget that allows you to compare different annotations for one image. It can be useful for comparing annotations of different applied NN models. Widget doesn't support Keypoints
shape. This widget is based on GridGallery widget.
Function signature
Parameters
Parameters | Type | Description |
---|---|---|
|
| Determines number of columns in widget |
|
| Figures opacity |
|
| If |
|
| Border width |
|
| Set fixed gallery height in |
|
| If no image is given, this message will be displayed. |
|
| Id of the widget |
columns_number
Determines the number of columns on CompareAnnotations
.
type: int
default value: 1
default_opacity
Figures opacity.
type: float
default value: 0.5
fill_rectangle
If False
labels with shape Rectangle
will be hollow.
type: bool
default value: true
border_width
Determines border width to rectangle figures.
type: int
default value: 3
view_height
Set fixed gallery height in px
.
type: int
default value: None
empty_message
If no image is given, this message will be displayed.
type: str
default value: "No image was provided"
widget_id
ID of the widget.
type: str
default value: None
Methods and attributes
Attributes and Methods | Description |
---|---|
| Returns current image URL |
| Set current image by URL |
| Add annotations to gallery |
| Checks whether image is set or not |
| Clean up widget from image and annotations |
Mini App Example
In this example, we will use CompareAnnotations
widget to display different annotations for one image. We will modify and duplicate an existing image annotation and slightly alter the labels on it, to make them different. All labels will be converted to shape Rectangle
.
You can find this example in our Github repository:
supervisely-ecosystem/ui-widgets-demos/compare-data/005_compare_annotations/src/main.py
Import libraries
Init API client
First, we load environment variables with credentials and init API for communicating with Supervisely Instance:
Get project ID and dataset ID
This app requires that you project have at least 2 images in it. If you don't have any projects, you can get one from Supervisely Ecosystem.
Get images and annotations infos
Option 1. Collect image names, URLs, annotations and generate annotation names from server
Option 2. You can also serve images from your local machine, using a static directory
Sort lists of images and annotations to make sure they are in the correct order.
Read annotations from local .json files
Create a function to modify the annotation
Iterate over column numbers and append modified annotations to widget
We iterate over column numbers for demo purposes to show all annotations in one line.
Create buttons for changing current image and cleaning up widget
Create app layout
Prepare a layout for app using Card
widget with the content
parameter and place widget that we've just created in the Container
widget.
Create app using layout
Create an app object with layout parameter.
In case you want to use a static directory, you need to pass it to the Application.
Create a callback functions for buttons
Last updated