fiftyone.brain.internal.models#

Module contents#

Brain models.

Copyright 2017-2025, Voxel51, Inc.

Functions:

list_models()

Returns the list of available models.

list_downloaded_models()

Returns information about the models that have been downloaded.

is_model_downloaded(name)

Determines whether the model of the given name is downloaded.

download_model(name[, overwrite])

Downloads the model of the given name.

install_model_requirements(name[, error_level])

Installs any package requirements for the model with the given name.

ensure_model_requirements(name[, error_level])

Ensures that the package requirements for the model with the given name are satisfied.

load_model(name[, download_if_necessary, ...])

Loads the model of the given name.

find_model(name)

Returns the path to the model on disk.

get_model(name)

Returns the eta.core.models.Model instance for the model with the given name.

delete_model(name)

Deletes the model from local disk, if necessary.

Classes:

HasBrainModel()

Mixin class for Config classes of fiftyone.core.models.Model instances whose models are stored privately by the FiftyOne Brain.

fiftyone.brain.internal.models.list_models()#

Returns the list of available models.

Returns:

a list of model names

fiftyone.brain.internal.models.list_downloaded_models()#

Returns information about the models that have been downloaded.

Returns:

a dict mapping model names to (model path, eta.core.models.Model) tuples

fiftyone.brain.internal.models.is_model_downloaded(name)#

Determines whether the model of the given name is downloaded.

Parameters:

name – the name of the model, which can have @<ver> appended to refer to a specific version of the model. If no version is specified, the latest version of the model is used

Returns:

True/False

fiftyone.brain.internal.models.download_model(name, overwrite=False)#

Downloads the model of the given name.

If the model is already downloaded, it is not re-downloaded unless overwrite == True is specified.

Parameters:
  • name – the name of the model, which can have @<ver> appended to refer to a specific version of the model. If no version is specified, the latest version of the model is used. Call list_models() to see the available models

  • overwrite (False) – whether to overwrite any existing files

Returns:

tuple of

  • model: the eta.core.models.Model instance for the model

  • model_path: the path to the downloaded model on disk

fiftyone.brain.internal.models.install_model_requirements(name, error_level=0)#

Installs any package requirements for the model with the given name.

Parameters:
  • name – the name of the model, which can have @<ver> appended to refer to a specific version of the model. If no version is specified, the latest version of the model is used. Call list_models() to see the available models

  • error_level –

    the error level to use, defined as:

    0: raise error if a requirement install fails 1: log warning if a requirement install fails 2: ignore install fails

fiftyone.brain.internal.models.ensure_model_requirements(name, error_level=0)#

Ensures that the package requirements for the model with the given name are satisfied.

Parameters:
  • name – the name of the model, which can have @<ver> appended to refer to a specific version of the model. If no version is specified, the latest version of the model is used. Call list_models() to see the available models

  • error_level –

    the error level to use, defined as:

    0: raise error if a requirement is not satisfied 1: log warning if a requirement is not satisifed 2: ignore unsatisifed requirements

fiftyone.brain.internal.models.load_model(name, download_if_necessary=True, install_requirements=False, error_level=0, **kwargs)#

Loads the model of the given name.

By default, the model will be downloaded if necessary.

Parameters:
  • name – the name of the model, which can have @<ver> appended to refer to a specific version of the model. If no version is specified, the latest version of the model is used. Call list_models() to see the available models

  • download_if_necessary (True) – whether to download the model if it is not found in the specified directory

  • install_requirements – whether to install any requirements before loading the model. By default, this is False

  • error_level –

    the error level to use, defined as:

    0: raise error if a requirement is not satisfied 1: log warning if a requirement is not satisifed 2: ignore unsatisifed requirements

  • **kwargs – keyword arguments to inject into the model’s Config instance

Returns:

a fiftyone.core.models.Model

fiftyone.brain.internal.models.find_model(name)#

Returns the path to the model on disk.

The model must be downloaded. Use download_model() to download models.

Parameters:

name – the name of the model, which can have @<ver> appended to refer to a specific version of the model. If no version is specified, the latest version of the model is used

Returns:

the path to the model on disk

Raises:

ValueError – if the model does not exist or has not been downloaded

fiftyone.brain.internal.models.get_model(name)#

Returns the eta.core.models.Model instance for the model with the given name.

Parameters:

name – the name of the model

Returnsn eta.core.models.ModelZooModel

fiftyone.brain.internal.models.delete_model(name)#

Deletes the model from local disk, if necessary.

Parameters:

name – the name of the model, which can have @<ver> appended to refer to a specific version of the model. If no version is specified, the latest version of the model is used

class fiftyone.brain.internal.models.HasBrainModel#

Bases: HasPublishedModel

Mixin class for Config classes of fiftyone.core.models.Model instances whose models are stored privately by the FiftyOne Brain.

Methods:

download_model_if_necessary()

Downloads the published model specified by the config, if necessary.

init(d)

Initializes the published model config.

download_model_if_necessary()#

Downloads the published model specified by the config, if necessary.

After this method is called, the model_path attribute will always contain the path to the model on disk.

init(d)#

Initializes the published model config.

This method should be called by ModelConfig.__init__(), and it performs the following tasks:

  • Parses the model_name and model_path parameters

  • Populates any default parameters in the provided ModelConfig dict

Parameters:

d – a ModelConfig dict

Returns:

a ModelConfig dict with any default parameters populated