Image
Introduction
Image widget in Supervisely is a simple widget that displays images using the HTML <img> tag, and is convenient to use when there is no need to add extra functions for displaying annotations or adjusting their settings, but only to display the image passed to it by url or local path.
Function signature
Image(
url="",
width=None,
height=None,
widget_id=None,
)
Parameters
url
str
Image url or local path to image on the host
width
Optional[Union[int, str]]
Image width in pixels or percent
height
Optional[Union[int, str]]
Image height in pixels or percent
widget_id
str
ID of the widget
url
Image url or local path to image on the host. Determines image to be displayed on widget.
type: str
default value: ""
width
Image width in pixels or percent.
type: Optional[Union[int, str]]
default value: None
height
Image height in pixels or percent.
type: Optional[Union[int, str]]
default value: None
widget_id
ID of the widget.
type: str
default value: None
Methods and attributes
set(url: str)
Set image by url in Image widget.
clean_up()
Clean Image widget from item.
set_image_size(height: Optional[Union[int, str]], width: Optional[Union[int, str]])
Set image size in Image widget.
show()
Show Image widget.
hide()
Hide Image widget.
Mini App Example
You can find this example in our Github repository:
ui-widgets-demos/media/001_image/src/main.py
Import libraries
Init API client
First, we load environment variables with credentials and init API for communicating with Supervisely Instance:
Get images infos from server
Get images urls
Initialize Image widgets we will use in UI
Image widgets we will use in UIDeclare static files directory path and initialize Image using image from local directory
Image using image from local directoryCreate 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
Define static_dir parameter for using files from local directory. Create an app object with layout parameter.

Last updated
Was this helpful?