Skip to content

Labels

mozuma.labels.base.LabelSet dataclass

Label set is an ordered list of labels used for classification tasks

Attributes:

Name Type Description
label_set_unique_id str

Unique identifier for a label set

label_list List[str]

Ordered list of labels

label_to_idx dict

Dict with items (label_name, label_index)

Examples:

LabelSet objects are used as classic lists:

animal_labels = LabelSet(
    label_set_unique_id="animals",
    label_list=["cat", "dog"]
)
print(animal_labels.label_set_unique_id)    # "animals"
print(animal_labels[0])     # "cat"
print(animal_labels[1])     # "dog"
print(len(animal_labels))   # 2

print(animal_labels.get_label_ids(["dog"])) # [1]

get_label_ids(self, labels: List[str]) -> List[int]

Get the list of label indices for the provided labels.

Parameters:

Name Type Description Default
labels List[str]

list of labels of which to obtain indices

required

Exceptions:

Type Description
ValueError

when a label in labels is not found in the label set

Returns:

Type Description
indices (List[int])

list of indices

Available label sets

  • mozuma.labels.imagenet.IMAGENET_LABELS
  • mozuma.labels.places_io.PLACES_IN_OUT_DOOR
  • mozuma.labels.places_io.PLACES_IO_LABELS
  • mozuma.labels.places.PLACES_LABELS
  • mozuma.labels.vinvl_attributes.VINVL_ATTRIBUTE_LABELS
  • mozuma.labels.vinvl.VINVL_LABELS