ClassesColorMapping
Introduction
Classes Color Mapping
widget allows users to edit class colors on the fly. This widget can be used when you have classes with similar colors and you want to change them to be more distinguishable.
Function signature
Parameters
classes
Union[List[ObjClass], ObjClassCollection]
Supervisely object class collection or list of object classes
grayscale
bool
If True
convert selected RGB color to grayscale
widget_id
str
ID of the widget
classes
List of ObjClass
objects or Supervisely object class collection (ObjClassCollection
).
type: Union[List[ObjClass], ObjClassCollection]
grayscale
If True
convert selected RGB color value to grayscale.
type: bool
default False
widget_id
ID of the widget.
type: str
default value: None
Methods and attributes
set()
Set classes to widget.
set_colors()
Set classes colors.
get_classes()
Get all classes.
get_selected_classes_original()
Get classes with original colors.
get_selected_classes_edited()
Get classes with selected colors.
get_mapping()
Get class to color map.
set_default()
Set multiple flag.
select()
Return list of all classes.
Mini App Example
You can find this example in our Github repository:
supervisely-ecosystem/ui-widgets-demos/input/010_classes_color_mapping/src/main.py
Import libraries
Init API client
First, we load environment variables with credentials and init API for communicating with Supervisely Instance:
Create list of object classes and init ClassesColorMapping
widget
ClassesColorMapping
widgetInitialize ClassesListPreview
widget to display changes and Button
widget to save changes
ClassesListPreview
widget to display changes and Button
widget to save changesCreate app layout
Prepare a layout for app using Card
widget with the content
parameter and place widget that we've just created into the Container
widget.
Create app using layout
Create an app object with layout parameter.
Add functions to control widgets from python code
Last updated
Was this helpful?