DatasetThumbnail
widget in Supervisely is a widget that allows to display a thumbnail image that represents supervisely dataset. It is a useful widget for applications that run from specific dataset, allowing users to have quick access to this dataset, so that when the user clicks on the thumbnail, the link will take him to this dataset.
DatasetThumbnail(
project_info=None,
dataset_info=None,
show_project_name=True,
widget_id=None
)
Parameters | Type | Description |
---|---|---|
project_info |
ProjectInfo |
NamedTuple , containing information about project |
dataset_info |
DatasetInfo |
NamedTuple , containing information about dataset |
show_project_name |
bool |
Determines to display project name |
widget_id |
str |
ID of the widget |
NamedTuple
, containing information about project.
type: ProjectInfo
default value: None
project = api.project.get_info_by_id(project_id)
dataset_thumbnail = DatasetThumbnail(project_info=project)
NamedTuple
, containing information about dataset.
type: DatasetInfo
default value: None
dataset = api.dataset.get_info_by_id(id=dataset_id)
dataset_thumbnail = DatasetThumbnail(dataset_info=dataset)
Determines to display project name.
type: bool
default value: True
project = api.project.get_info_by_id(project_id)
dataset = api.dataset.get_info_by_id(dataset_id)
dataset_thumbnail = DatasetThumbnail(
project_info=project,
dataset_info=dataset,
show_project_name=False
)
ID of the widget.
type: str
default value: None
Attributes and Methods | Description |
---|---|
set(project_info: ProjectInfo, dataset_info: DatasetInfo, show_project_name: bool = True) |
Set input project data. |
You can find this example in our Github repository:
ui-widgets-demos/thumbnail/002_dataset_thumbnail/src/main.py
import os
import supervisely as sly
from dotenv import load_dotenv
from supervisely.app.widgets import Card, Container, DatasetThumbnail
First, we load environment variables with credentials and init API for communicating with Supervisely Instance:
load_dotenv("local.env")
load_dotenv(os.path.expanduser("~/supervisely.env"))
api = sly.Api()
project_id = sly.env.project_id()
project = api.project.get_info_by_id(project_id)
dataset_id = sly.env.dataset_id()
dataset = api.dataset.get_info_by_id(id=dataset_id)
dataset_thumbnail = DatasetThumbnail(project_info=project, dataset_info=dataset)
Prepare a layout for app using Card
widget with the content
parameter and place widget that we've just created in the Container
widget.
card = Card(
title="Dataset Thumbnail",
content=Container(widgets=[dataset_thumbnail]),
)
layout = Container(widgets=[card])
Create an app object with layout parameter.
app = sly.Application(layout=layout)