DeployModel
Introduction
DeployModel widget in Supervisely is a comprehensive user interface element that allows users to deploy or connect to neural network models in three different modes:
Connect: Connect to an already deployed model session
Pretrained: Deploy a pretrained model from the Supervisely ecosystem
Custom: Deploy a custom model from your training experiments
This widget streamlines the model deployment workflow and provides a unified interface for managing model sessions in Supervisely apps. 
Function signature
DeployModel(
api=None,
team_id=None,
modes=None,
widget_id=None,
)Parameters
api
Api
Supervisely API instance for server communication
team_id
int
Team ID for model operations
modes
List[Literal["connect", "pretrained", "custom"]]
List of deployment modes to enable in the widget
widget_id
str
ID of the widget
api
Supervisely API instance for communicating with the Supervisely server. If not provided, will use the default API instance.
type: Api
default value: None (will create new Api instance)
team_id
Team ID for model deployment operations. If not provided, will use the team ID from environment variables.
type: int
default value: None (will use sly.env.team_id())
modes
List of deployment modes to enable in the widget. Can include "connect", "pretrained", and/or "custom". If not provided, all three modes will be available.
type: List[Literal["connect", "pretrained", "custom"]]
default value: None (all modes enabled)
widget_id
ID of the widget for internal use.
type: str
default value: None
Methods and attributes
Public Methods
deploy()
ModelAPI
Deploy or connect to a model based on current mode and selection. Returns ModelAPI instance for interacting with the deployed model.
stop()
None
Stop the currently deployed model session. Shuts down the model and cleans up resources.
disconnect()
None
Disconnect from the model without stopping it. The model continues running but this widget releases the connection.
get_deploy_parameters()
Dict[str, Any]
Get current deployment parameters as a dictionary including mode, agent_id, and mode-specific parameters.
Status and UI Control Methods
set_model_status()
status: Literal[...], extra_text: str
Set the deployment status message. Status can be: "deployed", "stopped", "deploying", "connecting", "connected", "error", or "hide".
set_session_info()
task_info: Dict
Display session information for deployed model including session ID, app name, and timestamp.
set_model_info()
session_id: int
Set model information widget with session details.
reset_model_info()
None
Reset model information widget to initial state.
set_model_message_by_tab()
tab_name: str
Update model info message based on active tab.
disable_modes()
None
Disable all mode selection and agent selector during deployment.
enable_modes()
None
Enable mode selection and agent selector after deployment completes.
show_stop()
None
Show stop/disconnect buttons and hide deploy/connect buttons.
Utility Methods
get_modules()
List[ModuleInfo]
Get list of available serving modules from ecosystem with framework categories.
get_frameworks()
List[str]
Get list of available framework names from serving modules.
Properties
model_api
ModelAPI or None
Current ModelAPI instance for the deployed/connected model. None if no model is active.
modes
Dict[str, DeployMode]
Dictionary of available deployment modes (Connect, Pretrained, Custom).
layout
Widget
The main layout widget (RadioTabs if multiple modes, otherwise single mode container).
Deployment Modes
Connect Mode
Connect to an already deployed model session. The widget displays a table of all active model sessions in your team.
Features:
Lists all deployed models with session ID, app name, framework, and model name
Refresh button to update the list of available sessions
Select and connect to any active session
Pretrained Mode
Deploy a pretrained model from the Supervisely ecosystem.

Features:
Browse pretrained models by framework
View model details including parameters and performance metrics
Select agent for deployment
Automatic model deployment
Custom Mode
Deploy a custom model from your training experiments.

Features:
Browse your training experiments
Select specific checkpoints
View experiment details and metrics
Deploy custom trained models
Mini App Example
You can find this example in our Github repository:
ui-widgets-demos/misc/deploy_model/src/main.py
Import libraries
Init API client
First, we load environment variables with credentials and init API for communicating with Supervisely Instance:
Initialize DeployModel widget
Create additional UI elements
Create app layout
Add button handlers
Usage Examples
Deploy a pretrained model
Connect to existing session
Deploy custom model
Get deployment parameters
Stop deployed model
Disconnect without stopping
Last updated
Was this helpful?