class documentation

Session that maintains a 1-1 shared state with the FiftyOne App.

Basic Usage

Parameters
datasetan optional fiftyone.core.dataset.Dataset or fiftyone.core.view.DatasetView to load
viewan optional fiftyone.core.view.DatasetView to load
sample_idan optional fiftyone.core.sample.Sample ID to load in the modal
group_idan optional fiftyone.core.groups.Group ID to load in the modal
spacesan optional fiftyone.core.odm.workspace.Space instance defining a space configuration to load
color_schemean optional fiftyone.core.odm.dataset.ColorScheme defining a custom color scheme to use
plotsan optional fiftyone.core.plots.manager.PlotManager to connect to this session
portthe port number to serve the App. If None, fiftyone.config.default_app_port is used
addressthe address to serve the App. If None, fiftyone.config.default_app_address is used
remotewhether this is a remote session, and opening the App should not be attempted
browseran optional browser to use to open the App. If None, the default browser will be used. Refer to list of supported browsers at https://docs.python.org/3/library/webbrowser.html
heightan optional height, in pixels, at which to render App instances in notebook cells. Only applicable in notebook contexts
autowhether to automatically show a new App window whenever the state of the session is updated. Only applicable in notebook contexts
configan optional fiftyone.core.config.AppConfig to control fine-grained default App settings
Method __del__ Undocumented
Method __init__ Undocumented
Method __repr__ Undocumented
Method auto.setter Undocumented
Method clear_dataset Clears the current fiftyone.core.dataset.Dataset from the session, if any.
Method clear_selected Clears the currently selected samples, if any.
Method clear_selected_labels Clears the currently selected labels, if any.
Method clear_view Clears the current fiftyone.core.view.DatasetView from the session, if any.
Method close Closes the session and terminates the App, if necessary.
Method color_scheme.setter Undocumented
Method config.setter Undocumented
Method dataset.setter Undocumented
Method freeze Screenshots the active App cell, replacing it with a static image.
Method group_id.setter Undocumented
Method load_workspace Loads the given saved workspace.
Method no_show Returns a context manager that temporarily prevents new App instances from being opened in the current notebook cell when methods are run that normally would show new App windows.
Method open Opens the App, if necessary.
Method open_tab Opens the App in a new tab of your browser.
Method plots.setter Undocumented
Method refresh Refreshes the current App window.
Method sample_id.setter Undocumented
Method select_labels Selects the specified labels in the current view in the App.
Method select_samples Selects the specified samples in the current view in the App,
Method selected.setter Undocumented
Method selected_labels.setter Undocumented
Method show Opens the App in the output of the current notebook cell.
Method spaces.setter Undocumented
Method summary Returns a string summary of the session.
Method tag_selected_labels Adds the tag to the currently selected labels, if necessary.
Method tag_selected_samples Adds the tag to the currently selected samples, if necessary.
Method untag_selected_labels Removes the tag from the currently selected labels, if necessary.
Method untag_selected_samples Removes the tag from the currently selected samples, if necessary.
Method view.setter Undocumented
Method wait Blocks execution until the App is closed by the user.
Instance Variable browser Undocumented
Instance Variable selected_labels A list of labels currently selected in the App.
Instance Variable spaces The layout state for the session.
Property auto The auto setting for the session.
Property color_scheme The color scheme for the session.
Property config The current fiftyone.core.config.AppConfig.
Property dataset The fiftyone.core.dataset.Dataset connected to the session.
Property group_id The current fiftyone.core.groups.Group ID in the modal, if any.
Property has_plots Whether this session has any attached plots.
Property plots The fiftyone.core.plots.manager.PlotManager instance that manages plots attached to this session.
Property remote Whether the session is remote.
Property sample_id The current fiftyone.core.sample.Sample ID in the modal, if any.
Property selected A list of sample IDs of the currently selected samples in the App, if any.
Property selected_view A fiftyone.core.view.DatasetView containing the currently selected content in the App.
Property server_address The server address for the session, or None if not specified.
Property server_port The server port for the session.
Property url The URL of the session.
Property view The fiftyone.core.view.DatasetView connected to the session, or None if no view is connected.
Method _set_dataset Undocumented
Method _set_view Undocumented
Method _validate Undocumented
Instance Variable _client Undocumented
Instance Variable _disable_wait_warning Undocumented
Instance Variable _get_time Undocumented
Instance Variable _notebook_cells Undocumented
Instance Variable _plots Undocumented
Instance Variable _state Undocumented
Instance Variable _wait_closed Undocumented
Property _collection Undocumented
def __del__(self): (source)

Undocumented

def __init__(self, dataset: fod.Dataset | fov.DatasetView = None, view: fov.DatasetView = None, sample_id: str = None, group_id: str = None, spaces: Space = None, color_scheme: food.ColorScheme = None, plots: fop.PlotManager = None, port: int = None, address: str = None, remote: bool = False, browser: str = None, height: int = None, auto: bool = True, config: AppConfig = None, view_name: str = None): (source)

Undocumented

def __repr__(self) -> str: (source)

Undocumented

@auto.setter
def auto(self, auto: bool): (source)

Undocumented

@update_state()
def clear_dataset(self): (source)

Clears the current fiftyone.core.dataset.Dataset from the session, if any.

def clear_selected(self): (source)

Clears the currently selected samples, if any.

@update_state()
def clear_selected_labels(self): (source)

Clears the currently selected labels, if any.

@update_state()
def clear_view(self): (source)

Clears the current fiftyone.core.view.DatasetView from the session, if any.

def close(self): (source)

Closes the session and terminates the App, if necessary.

@color_scheme.setter
def color_scheme(self, color_scheme: food.ColorScheme | None): (source)

Undocumented

@config.setter
@update_state()
def config(self, config: AppConfig | None): (source)

Undocumented

@dataset.setter
@update_state(auto_show=True)
def dataset(self, dataset: fod.Dataset | None): (source)

Undocumented

def freeze(self): (source)

Screenshots the active App cell, replacing it with a static image.

Only applicable to notebook contexts.

@group_id.setter
def group_id(self, group_id: str | None): (source)

Undocumented

def load_workspace(self, workspace: str): (source)

Loads the given saved workspace.

Parameters
workspace:strthe name of a saved workspace
def no_show(self) -> fou.SetAttributes: (source)

Returns a context manager that temporarily prevents new App instances from being opened in the current notebook cell when methods are run that normally would show new App windows.

This method has no effect in non-notebook contexts.

Examples:

import fiftyone as fo

dataset = foz.load_zoo_dataset("quickstart")
session = fo.launch_app(dataset)

# (new cell)

# Opens a new App instance
session.view = dataset.take(100)

# (new cell)

# Does not open a new App instance
with session.no_show():
    session.view = dataset.take(100)
Returns
fou.SetAttributesa context manager
def open(self): (source)

Opens the App, if necessary.

The behavior of this method depends on your context:

  • Notebooks: calls Session.show to open a new App window in the output of your current cell
  • Other (non-remote): opens the App in a new browser tab
def open_tab(self): (source)

Opens the App in a new tab of your browser.

This method can be called from Jupyter notebooks to override the default location of the App.

@plots.setter
def plots(self, plots: fop.PlotManager | None): (source)

Undocumented

def refresh(self): (source)

Refreshes the current App window.

@sample_id.setter
def sample_id(self, sample_id: str | None): (source)

Undocumented

def select_labels(self, labels: list[dict] | None = None, ids: str | t.Iterable[str] | None = None, tags: str | t.Iterable[str] | None = None, fields: str | t.Iterable[str] | None = None): (source)

Selects the specified labels in the current view in the App.

This method uses the same interface as fiftyone.core.collections.SampleCollection.select_labels to specify the labels to select.

Parameters
labels:Nonea list of dicts specifying the labels to select
ids:Nonean ID or iterable of IDs of the labels to select
tags:Nonea tag or iterable of tags of labels to select
fields:Nonea field or iterable of fields from which to select
def select_samples(self, ids: str | t.Iterable[str] | None = None, tags: str | t.Iterable[str] | None = None): (source)

Selects the specified samples in the current view in the App,

Parameters
ids:Nonean ID or iterable of IDs of samples to select
tags:Nonea tag or iterable of tags of samples to select
@selected.setter
def selected(self, sample_ids: list[str]): (source)

Undocumented

@selected_labels.setter
def selected_labels(self, labels: dict): (source)

Undocumented

@update_state()
def show(self, height: int = None): (source)

Opens the App in the output of the current notebook cell.

This method has no effect in non-notebook contexts.

Parameters
height:Nonea height, in pixels, for the App
@spaces.setter
def spaces(self, spaces: Space | None): (source)

Undocumented

def summary(self) -> str: (source)

Returns a string summary of the session.

Returns
stra string summary
@update_state()
def tag_selected_labels(self, tag: str): (source)

Adds the tag to the currently selected labels, if necessary.

The currently selected labels are Session.selected_labels.

Parameters
tag:stra tag
@update_state()
def tag_selected_samples(self, tag: str): (source)

Adds the tag to the currently selected samples, if necessary.

The currently selected labels are Session.selected.

Parameters
tag:stra tag
@update_state()
def untag_selected_labels(self, tag: str): (source)

Removes the tag from the currently selected labels, if necessary.

The currently selected labels are Session.selected_labels.

Parameters
tag:stra tag
@update_state()
def untag_selected_samples(self, tag: str): (source)

Removes the tag from the currently selected samples, if necessary.

The currently selected labels are Session.selected.

Parameters
tag:stra tag
@view.setter
@update_state(auto_show=True)
def view(self, view: fov.DatasetView | None): (source)

Undocumented

def wait(self, wait: float = 3): (source)

Blocks execution until the App is closed by the user.

All connected windows (tabs) must be closed before this method will unblock.

Parameters
wait:3the number of seconds to wait for a new App connection before returning if all connections are lost. If negative, the process will wait forever, regardless of connections

Undocumented

@property
selected_labels: list[dict] = (source)

A list of labels currently selected in the App.

Items are dictionaries with the following keys:

  • label_id: the ID of the label
  • sample_id: the ID of the sample containing the label
  • field: the field name containing the label
  • frame_number: the frame number containing the label (only applicable to video samples)

The layout state for the session.

The auto setting for the session.

The color scheme for the session.

The current fiftyone.core.config.AppConfig.

For changes to a session's config to take effect in the App, a call to Session.refresh or another state-updating action such as session.view = my_view must occur.

Example usage:

import fiftyone as fo

dataset, session = fo.quickstart()

# change the show confidence setting and push the change to the App
session.config.show_confidence = False
session.refresh()

The current fiftyone.core.groups.Group ID in the modal, if any.

Whether this session has any attached plots.

The fiftyone.core.plots.manager.PlotManager instance that manages plots attached to this session.

Whether the session is remote.

The current fiftyone.core.sample.Sample ID in the modal, if any.

A list of sample IDs of the currently selected samples in the App, if any.

A fiftyone.core.view.DatasetView containing the currently selected content in the App.

The selected view is defined as follows:

  • If both samples and labels are selected, the view will contain only the selected_labels from within the selected samples
  • If samples are selected, the view will only contain the selected samples
  • If labels are selected, the view will only contain the selected_labels
  • If no samples or labels are selected, the view will be None
@property
server_address: str = (source)

The server address for the session, or None if not specified.

@property
server_port: int = (source)

The server port for the session.

The URL of the session.

The fiftyone.core.view.DatasetView connected to the session, or None if no view is connected.

def _set_dataset(self, dataset): (source)

Undocumented

def _set_view(self, view): (source)

Undocumented

def _validate(self, dataset: fod.Dataset | fov.DatasetView | None, view: fov.DatasetView | None, spaces: Space | None, color_scheme: food.ColorScheme | None, plots: fop.PlotManager | None, config: AppConfig | None): (source)

Undocumented

Undocumented

_disable_wait_warning: bool = (source)

Undocumented

_get_time = (source)

Undocumented

Undocumented

Undocumented

Undocumented

_wait_closed: bool = (source)

Undocumented