class documentation

Description of a color scheme in the App.

Example:

import fiftyone as fo
import fiftyone.zoo as foz

dataset = foz.load_zoo_dataset("quickstart")

# Store a custom color scheme for a dataset
dataset.app_config.color_scheme = fo.ColorScheme(
    color_by="value",
    color_pool=[
        "#ff0000",
        "#00ff00",
        "#0000ff",
        "pink",
        "yellowgreen",
    ],
    fields=[
        {
            "path": "ground_truth",
            "fieldColor": "#ff00ff",
            "colorByAttribute": "label",
            "valueColors": [{"value": "dog", "color": "yellow"}],
            "maskTargetsColors": [
                {"intTarget": 2, "color": "#ff0000"},
                {"intTarget": 12, "color": "#99ff00"},
            ],
        }
    ],
    label_tags={
        "fieldColor": "#00ffff",
        "valueColors": [
            {"value": "correct", "color": "#ff00ff"},
            {"value": "mistake", "color": "#00ff00"},
        ],
    },
    colorscales=[
        {
            "path": "heatmap1",
            "list": [
                {"value": 0, "color": "rgb(0, 0, 255)"},
                {"value": 1, "color": "rgb(0, 255, 255)"},
            ],
        },
        {
            "path": "heatmap2",
            "name": "hsv",
        },
    ],
    multicolor_keypoints=False,
    opacity=0.5,
    show_skeletons=True,
    default_mask_targets_colors=[
        {"intTarget": 1, "color": "#FEC0AA"},
        {"intTarget": 2, "color": "#EC4E20"},
    ],
    default_colorscale={"name": "sunset", "list": None},
)

session = fo.launch_app(dataset)
Parameters
color_bywhether annotations should be colored by "field", "value", or "instance"
color_poolan optional list of colors to use as a color pool for this dataset
multicolor_keypointswhether to use multiple colors for keypoints
opacitytransparency of the annotation, between 0 and 1
show_skeletonswhether to show skeletons of keypoints
fields

an optional list of dicts of per-field custom colors with the following keys:

  • path (required): the fully-qualified path to the field you're customizing
  • fieldColor (optional): a color to assign to the field in the App sidebar
  • colorByAttribute (optional): the attribute to use to assign per-value colors. Only applicable when the field is an embedded document
  • valueColors (optional): a list of dicts specifying colors to use for individual values of this field
  • maskTargetsColors (optional): a list of dicts specifying index and color for 2D masks in the same format as described below for default mask targets
default_mask_targets_colors

a list of dicts with the following keys specifying index and color for 2D masks of the dataset. If a field does not have field specific mask targets colors, this list will be used:

  • intTarget: an integer target value
  • color: a color string

Note that the pixel value 0 is a reserved "background" class that is always rendered as invisible in the App

default_colorscale

dataset default colorscale dict with the following keys:

  • name (optional): a named plotly colorscale, e.g. "hsv". See https://plotly.com/python/builtin-colorscales
  • list (optional): a list of dicts of colorscale values
    • value: a float number between 0 and 1. A valid list must have have colors defined for 0 and 1
    • color: an RGB color string
colorscales

an optional list of dicts of per-field custom colorscales with the following keys:

  • path (required): the fully-qualified path to the field you're customizing. use "dataset" if you are setting the default colorscale for dataset
  • name (optional): a named colorscale plotly recognizes
  • list (optional): a list of dicts of colorscale values with the following keys:
    • value: a float number between 0 and 1. A valid list must have have colors defined for 0 and 1
    • color: an RGB color string
label_tags

an optional dict specifying custom colors for label tags with the following keys:

  • fieldColor (optional): a color to assign to all label tags
  • valueColors (optional): a list of dicts
Class Variable color_by Undocumented
Class Variable color_pool Undocumented
Class Variable colorscales Undocumented
Class Variable default_colorscale Undocumented
Class Variable default_mask_targets_colors Undocumented
Class Variable fields Undocumented
Class Variable label_tags Undocumented
Class Variable meta Undocumented
Class Variable multicolor_keypoints Undocumented
Class Variable opacity Undocumented
Class Variable show_skeletons Undocumented
Instance Variable id Undocumented
Method _id.setter Undocumented
Method _validate Undocumented
Method _validate_color_by Undocumented
Method _validate_colorscales Undocumented
Method _validate_default_colorscale Undocumented
Method _validate_default_mask_targets_colors Undocumented
Method _validate_fields Undocumented
Method _validate_mask_targets Undocumented
Method _validate_opacity Undocumented
Method _validate_single_colorscale Undocumented
Property _id Undocumented

Inherited from EmbeddedDocument:

Method __init__ Undocumented

Inherited from MongoEngineBaseDocument (via EmbeddedDocument, BaseEmbeddedDocument):

Class Method from_dict Loads the document from a BSON/JSON dictionary.
Method __deepcopy__ Undocumented
Method __delattr__ Undocumented
Method __delitem__ Undocumented
Method clear_field Clears the field from the document.
Method field_to_mongo Undocumented
Method field_to_python Undocumented
Method get_field Gets the field of the document.
Method has_field Determines whether the document has a field of the given name.
Method set_field Sets the value of a field of the document.
Method to_dict Serializes this document to a BSON/JSON dictionary.
Property field_names An ordered tuple of the public fields of this document.
Method _get_field Undocumented
Method _get_field_names Returns an ordered tuple of field names of this document.
Method _get_repr_fields Returns an ordered tuple of field names that should be included in the repr of the document.
Method _to_db_fields Undocumented
Instance Variable _fields_ordered Undocumented

Inherited from SerializableDocument (via EmbeddedDocument, BaseEmbeddedDocument, MongoEngineBaseDocument):

Class Method from_json Loads the document from a JSON string.
Method __eq__ Undocumented
Method __repr__ Undocumented
Method __str__ Undocumented
Method copy Returns a deep copy of the document.
Method fancy_repr Generates a customizable string representation of the document.
Method iter_fields Returns an iterator over the (name, value) pairs of the public fields of the document.
Method merge Merges the contents of the given document into this document.
Method to_json Serializes the document to a JSON string.
color_by: None = (source)

Undocumented

color_pool: None = (source)

Undocumented

colorscales: None = (source)

Undocumented

default_colorscale: None = (source)

Undocumented

default_mask_targets_colors: None = (source)

Undocumented

Undocumented

label_tags: None = (source)

Undocumented

multicolor_keypoints: None = (source)

Undocumented

Undocumented

show_skeletons: None = (source)

Undocumented

Undocumented

@_id.setter
def _id(self, value): (source)

Undocumented

def _validate(self): (source)

Undocumented

def _validate_color_by(self): (source)

Undocumented

def _validate_colorscales(self): (source)

Undocumented

def _validate_default_colorscale(self): (source)

Undocumented

def _validate_default_mask_targets_colors(self): (source)

Undocumented

def _validate_fields(self): (source)

Undocumented

def _validate_mask_targets(self, mask_targets, context): (source)

Undocumented

def _validate_opacity(self): (source)

Undocumented

def _validate_single_colorscale(self, scale): (source)

Undocumented

Undocumented