otx.api.entities.label#

This module define the label entity.

Classes

Domain(value)

Describes an algorithm domain like classification, detection, etc.

LabelEntity(name, domain[, color, hotkey, ...])

This represents a label.

class otx.api.entities.label.Domain(value)[source]#

Bases: Enum

Describes an algorithm domain like classification, detection, etc.

class otx.api.entities.label.LabelEntity(name: str, domain: Domain, color: Color | None = None, hotkey: str = '', creation_date: datetime | None = None, is_empty: bool = False, id: ID | None = None, is_anomalous: bool = False)[source]#

Bases: object

This represents a label. The Label is the object that the user annotates and the tasks predict.

For example, a label with name “car” can be constructed as follows.

>>> car = LabelEntity(name="car", domain=Domain.DETECTION)

About Empty Label

In addition to representing the presence of a certain object, the label can also be used to represent the absence of objects in the image (or other media types). Such a label is referred to as empty label. The empty label is constructed as follows:

>>> empty = LabelEntity(name="empty", domain=Domain.DETECTION, is_empty=True)

Empty label is used to declare that there is nothing of interest inside this image. For example, let’s assume a car detection project. During annotation process, for positive images (images with cars), the users are asked to annotate the images with bounding boxes with car label. However, when the user sees a negative image (no car), the user needs to annotate this image with an empty label.

The empty label is particularly useful to distinguish images with no objects of interest from images that have not been annotated, especially in task-chain scenario. Let’s assume car detection task that is followed with with another detection task which detects the driver inside the car. There are two issues here:

  1. The user can (intentionally or unintentionally) miss to annotate

    the driver inside a car.

  2. There is no driver inside the car.

Without empty label, these two cases cannot be distinguished. This is why an empty label is introduced. The empty label makes an explicit distinction between missing annotations and “negative” images.

Parameters:
  • name – the name of the label

  • domain – the algorithm domain this label is associated to

  • color – the color of the label (See Color)

  • hotkey – key or combination of keys to select this label in the UI

  • creation_date – the date time of the label creation

  • is_empty – set to True if the label is an empty label.

  • id – the ID of the label. Set to ID() so that a new unique ID will be assigned upon saving. If the argument is None, it will be set to ID()

  • is_anomalous – boolean that indicates whether the label is the Anomalous label. Always set to False for non- anomaly projects.

property color: Color#

Returns the Color object for the label.

property creation_date: datetime#

Returns the creation date of the label.

property domain#

Returns the algorithm domain associated to this label.

property hotkey: str#

Returns the hotkey for the label.

property id: ID#

DEPRECATED.

property id_: ID#

Returns the label id.

property is_empty: bool#

Returns a boolean indicating if the label is an empty label.

property name#

Returns the label name.