class Session(object): (source)
Constructor: Session(dataset, view, sample_id, group_id, ...)
Session that maintains a 1-1 shared state with the FiftyOne App.
Basic Usage
- Use
launch_app
to launch the App and retrieve its correspondingSession
instance. - To open a dataset in the App, simply set the
Session.dataset
property of the session to yourfiftyone.core.dataset.Dataset
. - To load a specific view into your dataset, simply set the
Session.view
property of the session to yourfiftyone.core.view.DatasetView
. - To load a specific sample in the modal, simply set the
Session.sample_id
property of the session to the ID of thefiftyone.core.sample.Sample
. - To load a specific group in the modal, simply set the
Session.group_id
property of the session to the ID of thefiftyone.core.groups.Group
. - To attach/remove interactive plots, use the methods exposed on the
Session.plots
property of the session. - Use
Session.refresh
to refresh the App if you update a dataset outside of the App - Use
Session.selected
to retrieve the IDs of the currently selected samples in the App. - Use
Session.selected_labels
to retrieve the IDs of the currently selected labels in the App. - In notebook contexts, use
Session.freeze
to replace the App and any attached plots with static images. - Use
Session.close
andSession.open
to temporarily close and reopen the App without creating a newSession
instance. - Use
close_app
to programmatically close the App and terminate the session.
Parameters | |
dataset | an optional fiftyone.core.dataset.Dataset or
fiftyone.core.view.DatasetView to load |
view | an optional fiftyone.core.view.DatasetView to
load |
sample | an optional fiftyone.core.sample.Sample ID
to load in the modal |
group | an optional fiftyone.core.groups.Group ID
to load in the modal |
spaces | an optional fiftyone.core.odm.workspace.Space
instance defining a space configuration to load |
color | an optional
fiftyone.core.odm.dataset.ColorScheme defining a custom
color scheme to use |
plots | an optional
fiftyone.core.plots.manager.PlotManager to connect to this
session |
port | the port number to serve the App. If None, fiftyone.config.default_app_port is used |
address | the address to serve the App. If None, fiftyone.config.default_app_address is used |
remote | whether this is a remote session, and opening the App should not be attempted |
browser | an 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 |
height | an optional height, in pixels, at which to render App instances in notebook cells. Only applicable in notebook contexts |
auto | whether to automatically show a new App window whenever the state of the session is updated. Only applicable in notebook contexts |
config | an optional fiftyone.core.config.AppConfig to
control fine-grained default App settings |
Method | __del__ |
Undocumented |
Method | __init__ |
Undocumented |
Method | __repr__ |
Undocumented |
Method | auto |
Undocumented |
Method | clear |
Clears the current fiftyone.core.dataset.Dataset from the session, if any. |
Method | clear |
Clears the currently selected samples, if any. |
Method | clear |
Clears the currently selected labels, if any. |
Method | clear |
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 |
Undocumented |
Method | config |
Undocumented |
Method | dataset |
Undocumented |
Method | freeze |
Screenshots the active App cell, replacing it with a static image. |
Method | group |
Undocumented |
Method | load |
Loads the given saved workspace. |
Method | no |
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 |
Opens the App in a new tab of your browser. |
Method | plots |
Undocumented |
Method | refresh |
Refreshes the current App window. |
Method | sample |
Undocumented |
Method | select |
Selects the specified labels in the current view in the App. |
Method | select |
Selects the specified samples in the current view in the App, |
Method | selected |
Undocumented |
Method | selected |
Undocumented |
Method | show |
Opens the App in the output of the current notebook cell. |
Method | spaces |
Undocumented |
Method | summary |
Returns a string summary of the session. |
Method | tag |
Adds the tag to the currently selected labels, if necessary. |
Method | tag |
Adds the tag to the currently selected samples, if necessary. |
Method | untag |
Removes the tag from the currently selected labels, if necessary. |
Method | untag |
Removes the tag from the currently selected samples, if necessary. |
Method | view |
Undocumented |
Method | wait |
Blocks execution until the App is closed by the user. |
Instance Variable | browser |
Undocumented |
Instance Variable | selected |
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 |
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 |
The current fiftyone.core.groups.Group ID in the modal, if any. |
Property | has |
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 |
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 |
A fiftyone.core.view.DatasetView containing the currently selected content in the App. |
Property | server |
The server address for the session, or None if not specified. |
Property | server |
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 |
Undocumented |
Method | _set |
Undocumented |
Method | _validate |
Undocumented |
Instance Variable | _client |
Undocumented |
Instance Variable | _disable |
Undocumented |
Instance Variable | _get |
Undocumented |
Instance Variable | _notebook |
Undocumented |
Instance Variable | _plots |
Undocumented |
Instance Variable | _state |
Undocumented |
Instance Variable | _wait |
Undocumented |
Property | _collection |
Undocumented |
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
@update_state(
def dataset(self, dataset:
fod.Dataset | None
):
(source)
¶
Undocumented
Screenshots the active App cell, replacing it with a static image.
Only applicable to notebook contexts.
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.SetAttributes | a context manager |
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
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.
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:None | a list of dicts specifying the labels to select |
ids:None | an ID or iterable of IDs of the labels to select |
tags:None | a tag or iterable of tags of labels to select |
fields:None | a field or iterable of fields from which to select |
Opens the App in the output of the current notebook cell.
This method has no effect in non-notebook contexts.
Parameters | |
height:None | a height, in pixels, for the App |
Adds the tag to the currently selected labels, if necessary.
The currently selected labels are Session.selected_labels
.
Parameters | |
tag:str | a tag |
Adds the tag to the currently selected samples, if necessary.
The currently selected labels are Session.selected
.
Parameters | |
tag:str | a tag |
Removes the tag from the currently selected labels, if necessary.
The currently selected labels are Session.selected_labels
.
Parameters | |
tag:str | a tag |
Removes the tag from the currently selected samples, if necessary.
The currently selected labels are Session.selected
.
Parameters | |
tag:str | a tag |
Blocks execution until the App is closed by the user.
All connected windows (tabs) must be closed before this method will unblock.
Parameters | |
wait:3 | the 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 |
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 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()
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 theselected
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
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