ClassificationInstance Objects

class ClassificationInstance()

classification_hash

@property
def classification_hash() -> str

A unique identifier for the classification instance.

classification_name

@property
def classification_name() -> str

Classification name from the project ontology

feature_hash

@property
def feature_hash() -> str

Feature node hash from the project ontology

set_for_frames

def set_for_frames(frames: Frames = 0,
                   *,
                   overwrite: bool = False,
                   created_at: Optional[datetime] = None,
                   created_by: Optional[str] = None,
                   confidence: float = DEFAULT_CONFIDENCE,
                   manual_annotation: bool = DEFAULT_MANUAL_ANNOTATION,
                   last_edited_at: Optional[datetime] = None,
                   last_edited_by: Optional[str] = None,
                   reviews: Optional[List[dict]] = None) -> None

Places the classification onto the specified frame. If the classification already exists on the frame and overwrite is set to True, the currently specified values will be overwritten.

Arguments:

frames: The frame to add the classification instance to. Defaulting to the first frame for convenience. overwrite: If True, overwrite existing data for the given frames. This will not reset all the non-specified values. If False and data already exists for the given frames, raises an error. created_at: Optionally specify the creation time of the classification instance on this frame. Defaults to datetime.now(). created_by: Optionally specify the creator of the classification instance on this frame. Defaults to the current SDK user. last_edited_at: Optionally specify the last edit time of the classification instance on this frame. Defaults to datetime.now(). last_edited_by: Optionally specify the last editor of the classification instance on this frame. Defaults to the current SDK user. confidence: Optionally specify the confidence of the classification instance on this frame. Defaults to 1.0. manual_annotation: Optionally specify whether the classification instance on this frame was manually annotated. Defaults to True. reviews: Should only be set by internal functions.

get_annotation

def get_annotation(frame: Union[int, str] = 0) -> Annotation

Arguments:

  • frame - Either the frame number or the image hash if the data type is an image or image group. Defaults to the first frame.

get_annotations

def get_annotations() -> List[Annotation]

Returns:

A list of ClassificationInstance.Annotation in order of available frames.

set_answer

def set_answer(answer: Union[str, Option, Sequence[Option]],
               attribute: Optional[Attribute] = None,
               overwrite: bool = False) -> None

Set the answer for a given ontology Attribute. This is the equivalent of e.g. selecting a checkbox in the UI after adding a ClassificationInstance. There is only one answer per ClassificationInstance per Attribute.

Arguments:

  • answer - The answer to set.
  • attribute - The ontology attribute to set the answer for. If not set, this will be attempted to be inferred. For answers to :class:encord.objects.common.RadioAttribute or :class:encord.objects.common.ChecklistAttribute, this can be inferred automatically. For :class:encord.objects.common.TextAttribute, this will only be inferred if there is only one possible TextAttribute to set for the entire classification instance. Otherwise, a :class:encord.exceptionsLabelRowError will be thrown.
  • overwrite - If True, the answer will be overwritten if it already exists. If False, this will throw a LabelRowError if the answer already exists.

set_answer_from_list

def set_answer_from_list(answers_list: List[Dict[str, Any]]) -> None

This is a low level helper function and should not be used directly.

Sets the answer for the classification from a dictionary.

Arguments:

  • answers_list - The list to set the answer from.

get_answer

def get_answer(
    attribute: Optional[Attribute] = None
) -> Union[str, Option, Iterable[Option], None]

Get the answer set for a given ontology Attribute. Returns None if the attribute is not yet answered.

For the ChecklistAttribute, it returns None if and only if the attribute is nested and the parent is unselected. Otherwise, if not yet answered it will return an empty list.

Arguments:

  • attribute - The ontology attribute to get the answer for.

delete_answer

def delete_answer(attribute: Optional[Attribute] = None) -> None

This resets the answer of an attribute as if it was never set.

Arguments:

  • attribute - The ontology attribute to delete the answer for. If not provided, the first level attribute is used.

copy

def copy() -> ClassificationInstance

Creates an exact copy of this ClassificationInstance but with a new classification hash and without being associated to any LabelRowV2. This is useful if you want to add the semantically same ClassificationInstance to multiple LabelRowV2s.

get_all_static_answers

def get_all_static_answers() -> List[Answer]

A low level helper function.

Annotation Objects

class Annotation()

This class can be used to set or get data for a specific annotation (i.e. the ClassificationInstance for a given frame number).

created_by

@created_by.setter
def created_by(created_by: Optional[str]) -> None

Set the created_by field with a user email or None if it should default to the current user of the SDK.

last_edited_by

@last_edited_by.setter
def last_edited_by(last_edited_by: Optional[str]) -> None

Set the last_edited_by field with a user email or None if it should default to the current user of the SDK.

reviews

@property
def reviews() -> Optional[List[dict]]

A read only property about the reviews that happened for this object on this frame.