Model Zoo Overview#

The FiftyOne Model Zoo provides a powerful interface for downloading models and applying them to your FiftyOne datasets.

It provides native access to hundreds of pre-trained models, and it also supports downloading arbitrary public or private models whose definitions are provided via GitHub repositories or URLs.

Basic recipe#

The basic recipe for working with zoo models is to load one via load_zoo_model() and then apply it to a dataset or view using methods like apply_model() and compute_embeddings().

You can generate model predictions by passing any zoo model to the apply_model() method of a dataset or view.

For example, the code sample below shows a self-contained example of loading a Faster R-CNN model from the model zoo and adding its predictions to the COCO-2017 dataset:

 1import fiftyone as fo
 2import fiftyone.zoo as foz
 3
 4# List available zoo models
 5print(foz.list_zoo_models())
 6
 7# Download and load a model
 8model = foz.load_zoo_model("faster-rcnn-resnet50-fpn-coco-torch")
 9
10# Load some samples from the COCO-2017 validation split
11dataset = foz.load_zoo_dataset(
12    "coco-2017",
13    split="validation",
14    dataset_name="coco-2017-validation-sample",
15    max_samples=50,
16    shuffle=True,
17)
18
19#
20# Choose some samples to process. This can be the entire dataset, or a
21# subset of the dataset. In this case, we'll choose some samples at
22# random
23#
24samples = dataset.take(25)
25
26#
27# Generate predictions for each sample and store the results in the
28# `faster_rcnn` field of the dataset, discarding all predictions with
29# confidence below 0.5
30#
31samples.apply_model(model, label_field="faster_rcnn", confidence_thresh=0.5)
32print(samples)
33
34# Visualize predictions in the App
35session = fo.launch_app(view=samples)

Note

Zoo models may require additional packages such as PyTorch or TensorFlow (or specific versions of them) in order to be used. See this section for more information on viewing/installing package requirements for models.

If you try to load a zoo model without the proper packages installed, you will receive an error message that will explain what you need to install.

Depending on your compute environment, some package requirement failures may be erroneous. In such cases, you can suppress error messages.

Built-in models#

The Model Zoo provides built-in access to hundreds of pre-trained models that you can apply to your datasets with a few simple commands.

Remotely-sourced models#

The Model Zoo also supports downloading and applying models whose definitions are provided via GitHub repositories or URLs.

Model interface#

All models in the Model Zoo are exposed via the Model class, which defines a common interface for loading models and generating predictions with defined input and output data formats.

Note

Did you know? You can also pass custom models to methods like apply_model() and compute_embeddings()!

API reference#

The Model Zoo can be accessed via the Python library and the CLI. Consult the API reference below to see how to download, apply, and manage zoo models.