LabelRowV2 Objects
is_event_based
True for scenes from self-contained (MCAP) recordings, and False for all other label rows. On an
event-based label row, frame numbers are nanosecond offsets from the start of the recording, and classifications
are stored as ranges instead of one entry per frame.
Geometric objects on an event-based label row are stored as keyframe events. Per-frame reads on an
ObjectInstance return read-only views, and per-frame writes
raise an error. Use ObjectInstance.upsert_event and ObjectInstance.delete_event to write them instead.
Returns:
bool-Trueif the label row is event-based,Falseotherwise.
LabelRowError- If labels have not been initialized.
from_media_metadata
to_encord_dict() for later
bulk ingestion.
Server-dependent operations (save(), initialise_labels(), workflow_reopen(),
workflow_complete(), etc.) will raise LabelRowError on
a detached label row. Use attach_to_project() to connect to a real project.
The serialized dict from to_encord_dict() contains placeholder (zero) UUIDs for
identity fields (label_hash, data_hash, dataset_hash). These are replaced
with real server-side values when attached to a project.
Arguments:
-
ontology- The ontology to use for label creation. -
media_metadata- Metadata describing the media file. The data type is inferred from the metadata class:- CustomerProvidedImageMetadata -> IMAGE
- CustomerProvidedVideoMetadata -> VIDEO
- CustomerProvidedAudioMetadata -> AUDIO
- CustomerProvidedTextMetadata -> PLAIN_TEXT
- CustomerProvidedPdfMetadata -> PDF
List[CustomerProvidedImageMetadata]-> IMG_GROUP
-
branch_name- Branch name for the label row. Defaults to"main".
label_hash
Optional[str]- The label row hash or None if not set.
branch_name
str- The branch name.
data_hash
str- The data row hash.
group_hash
Optional[str]- The data group hash, orNoneif the data unit is not part of a data group.
dataset_hash
str- The dataset hash.
dataset_title
str- The dataset title.
data_title
str- The data row title.
data_type
DataType- The data type.
file_type
image/jpeg, video/mp4, or text/html.
This is None for image groups once labels are initialized, because an image group has no single underlying
file. Use get_frames_metadata() to get the file type of
each image.
Returns:
Optional[str]- The MIME type, orNoneif not set.
client_metadata
include_client_metadata=True, for example
project.list_label_rows_v2(include_client_metadata=True). Otherwise, it is None.
Returns:
Optional[dict]- The client metadata, orNoneif it was not requested or is not set.
label_status
LabelStatus- The current labeling status.
WrongProjectTypeError- If used with a workflow project.
annotation_task_status
AnnotationTaskStatus- The current annotation task status.
WrongProjectTypeError- If used with a workflow project.
workflow_graph_node
Optional[WorkflowGraphNode]- The workflow graph node or None if not set.
is_shadow_data
bool-Trueif the data unit is shadow data,Falseotherwise.
created_at
Optional[datetime]- The creation date or None if not yet created.
last_edited_at
Optional[datetime]- The last edited date or None if not yet edited.
number_of_frames
int- The number of frames.
duration
Optional[float]- The duration or None if not applicable.
fps
Optional[float]- The fps or None if not applicable.
data_link
None
for DICOM series or image groups created without performance optimizations, as there is no single underlying
file for these data types.
This property will contain a signed URL if initialise_labels() was called with include_signed_url=True.
Returns:
Optional[str]- The data link or None if not applicable.
width
None for image groups without performance optimization, as there is no single underlying width
for this data type.
Returns:
Optional[int]- The width or None if not applicable.
height
None for image groups without performance optimization, as there is no single underlying height
for this data type.
Returns:
Optional[int]- The height or None if not applicable.
audio_codec
Optional[str]- The codec or None if not applicable.
audio_sample_rate
Optional[int]- The sample rate or None if not applicable.
audio_bit_depth
Optional[int]- The bit depth or None if not applicable.
audio_num_channels
Optional[int]- The number of channels or None if not applicable.
backing_item_uuid
Optional[UUID]- The backing storage item id or None if not found.
task_uuid
Optional[UUID]- The workflow task UUID, orNoneif not applicable.
WrongProjectTypeError- If used with a project that doesn’t use workflows.
priority
None for label rows in the Complete stage.
Returns:
Optional[float]- The task priority, from 0.0 to 1.0, orNoneif not applicable.
WrongProjectTypeError- If used with a project that doesn’t use workflows.
is_valid
True if the labels have correct structure and match the project ontology.
If it is False, then loading the labels via LabelRowV2 will raise an error, and the label editor
will not be able to load the labels.
You can call get_validation_errors() to get the validation error messages.
Returns:
bool- True if the labels are valid, False otherwise.
ontology_structure
label_row.ontology_structure.get_child_by_title("Car", type_=Object).
Returns:
OntologyStructure- The ontology structure.
is_labelling_initialised
False, call initialise_labels() before you
read or write object or classification instances.
Returns:
bool-Trueif labels are initialized,Falseotherwise.
is_detached
bool-Trueif the label row is detached,Falseotherwise.
assigned_user_email
None when the task is complete or nobody is assigned.
Returns:
Optional[str]- The email of the assigned user, orNone.
last_actioned_by_user_email
Optional[str]- The email of the user who last acted on the task, orNone.
get_storage_item
get_signed_urls only takes effect if the item has not been fetched yet. StorageItem.get_signed_url() fetches
a signed URL on demand if the cached item doesn’t have one.
Arguments:
get_signed_urls- IfTrue, request a signed URL when fetching the storage item.
StorageItem- The storage item.
LabelRowError- If the label row is detached or has no backing storage item.
initialise_storage_item
get_signed_url- IfTrue, request a signed URL for the item. You can then read it withlabel_row.get_storage_item().get_signed_url().bundle- If not provided, the storage item is fetched immediately. If provided, the fetch is deferred and performed together with the other operations in the bundle.
LabelRowError- If the label row is detached or has no backing storage item.
initialise_labels
label_hash is
None), this method creates it.
To download only some labels, filter by feature hash. Only use filters to read labels. If you save a label row
that was initialized with a filter, the labels that were filtered out are deleted from Encord.
Pass a bundle to initialize many label rows in fewer requests.
Arguments:
include_object_feature_hashes- IfNone, all objects are included. Otherwise, only objects with these feature hashes are included. Saving a label row initialized with this filter deletes all other objects from Encord.include_classification_feature_hashes- IfNone, all classifications are included. Otherwise, only classifications with these feature hashes are included. Saving a label row initialized with this filter deletes all other classifications from Encord.include_reviews- IfTrue, also download read-only information about the reviews of the label row.include_archived- IfTrue, also include labels whose ontology features are archived.overwrite- IfTrue, replace any labels already held in this object with the labels stored on Encord. IfFalseand labels are already initialized, an error is raised.bundle- If not provided, labels are downloaded immediately. If provided, the download is deferred and performed together with the other operations in the bundle.include_signed_url- IfTrue, data_link contains a signed URL.
LabelRowError- If labels are already initialized andoverwriteisFalse, or if the label row is detached.
from_labels_dict
label_row_dict- The dictionary of all labels in the Encord format.preserve_identity- If True, the current row’s identity fields (label_hash, data_hash, dataset_hash, branch_name, and IMG_GROUP frame hashes) are preserved instead of being overwritten from the dict.
get_image_hash
frame_number- The frame number.
Optional[str]- The image hash if the frame number is within bounds,Noneotherwise.
LabelRowError- If labels have not been initialized, or if the data type is not an image or image group.
get_frame_number
image_hash- The image hash.
Optional[int]- The frame number of the image.
LabelRowError- If labels have not been initialized, or if the data type is not an image or image group.KeyError- If the image hash is not in the label row.
get_spaces
stream@timestamp_ns key,
time series channels referenced by labels, and spaces that you already requested by ID. The list can be empty
and is not a full inventory of the recording. Use get_space(id=..., type_=...) to get the space you want.
Returns:
list[Space]- All spaces in the label row.
get_space
id, layout_key, stream_id, or file_name. You can’t pass both id and
layout_key.
On a scene from a self-contained (MCAP) recording, requesting type_="point_cloud" with an id of the form
stream@timestamp_ns that has no labels yet creates an empty space, so that you can add segmentations to it.
Requesting type_="time_series" with a non-empty channel ID does the same for time range labels. The label row
has no metadata for these spaces, so the ID and type that you pass are used as given.
Arguments:
id- The ID of the space.layout_key- The layout key of the data unit within its data group layout.type_- The expected space type, for example"image","video", or"point_cloud". The space that is found must be of this type.stream_id- For scenes, the name of the stream.event_index- For scenes, the event index withinstream_id. Defaults to 0.start_frame- For scene images, the frame where the image event starts. Used instead ofevent_indexif set.file_name- The name of the file associated with the space.
Space- The matching space, as the space class that matchestype_.
LabelRowError- If bothidandlayout_keyare passed, if no matching space is found, or if the matching space is not of the type given intype_.
save
bundle- If not provided, labels are saved immediately. If provided, the save is deferred and performed together with the other operations in the bundle.validate_before_saving- IfTrue, Encord validates the labels against the project ontology and rejects the save if they are invalid. IfFalse(default), the labels are saved without this check. You can check them afterwards with is_valid and get_validation_errors().renumber_objects- IfTrue, recompute the number of every object when saving, ignoring anyobject_numbervalues that are set, including values read from Encord. IfFalse(default), existing numbers are kept.
LabelRowError- If labels have not been initialized, if the label row is detached, or if two objects of the same ontology object have the sameobject_number. Object numbers are only checked whenrenumber_objectsisFalse.CorruptedLabelError- Ifvalidate_before_savingisTrueand the labels are invalid.
metadata
DICOMSeriesMetadata for DICOM data,
DataGroupMetadata for data groups, or None for other data types.
Raises:
LabelRowError- If labels have not been initialized.
get_frame_view
frame is a nanosecond offset. Object reads on the view return every object whose
range covers that offset, not only the objects with a keyframe at that offset. Adding objects through the view
raises an error.
Arguments:
frame- The frame number, or the image hash for image and image group data. Defaults to the first frame.
FrameView- A view of the frame.
LabelRowError- If labels have not been initialized, or if the data type is audio or time series.KeyError- Ifframeis an image hash that is not in the label row.
get_frame_metadata
include_images_data=True.
Arguments:
frame- The frame number or the image hash. Defaults to the first frame.
FrameViewMetadata- Metadata for the frame.
LabelRowError- If the frame or image hash is not found, if the data type is not supported, or if image data is missing for an image group.
get_frames_metadata
include_images_data=True.
Returns:
List[FrameViewMetadata]- Metadata for each frame.
LabelRowError- If the data type is not supported, or if image data is missing for an image group.
get_frame_views
List[FrameView]- A list of frame views, in frame order.
LabelRowError- If labels have not been initialized, or if the label row is event-based.
get_object_instances
get_object_instances() method.
Arguments:
filter_ontology_object- Optionally, only return instances of this ontology object.filter_frames- Optionally, only return objects that appear on these frames.
List[ObjectInstance]- The object instances that match the filters.
LabelRowError- If labels have not been initialized.
add_object_instance
ObjectInstance.upsert_event. Saving the label row raises an error until the object has at least one event, or
until you remove the object.
Arguments:
object_instance- The object instance to add.force- IfTrue(default), an object instance with the same object hash that is already on the label row is replaced. IfFalse, an error is raised instead.
LabelRowError- If labels have not been initialized, if the object instance is already on a label row or a space, if an object instance with the same object hash exists andforceisFalse, if the object instance is not on any frames, or if the object instance doesn’t fit the data type. For example, audio and time series data need range-only objects, and HTML files need objects with HTML coordinates.
add_classification_instance
ClassificationInstance.set_for_frames before you add it. For audio, text, and time series data,
and for event-based label rows, create the classification instance with range_only=True.
Arguments:
classification_instance- The classification instance to add.force- IfFalse(default), an error is raised if the label row already has a classification instance with the same classification hash, or an instance of the same classification on any of the same frames. IfTrue, the instance is added anyway. An instance with the same classification hash is replaced, and for a global classification, all other instances of the same classification are removed.
LabelRowError- If labels have not been initialized, if the classification instance is already on a label row or a space, if it conflicts with an existing instance andforceisFalse, if it is not on any frames, or if it was not created withrange_only=Trueon data that requires it.
remove_classification
classification_instance- The classification instance to remove.
LabelRowError- If labels have not been initialized, or if the classification instance is on a space. Use the space’s own methods to remove it.KeyError- If the classification instance is not on the label row.
get_classification_instances
get_classification_instances() method.
Arguments:
filter_ontology_classification- Optionally, only return instances of this ontology classification.filter_frames- Optionally, only return classifications that appear on these frames.
List[ClassificationInstance]- The classification instances that match the filters.
LabelRowError- If labels have not been initialized.
remove_object
object_instance- The object instance to remove.
LabelRowError- If labels have not been initialized, or if the object instance is on a space. Use the space’s own methods to remove it.
to_encord_dict
classification_answers, with their ranges and metadata.
Arguments:
renumber_objects- IfTrue, leave out theobjectNumberof every object so that Encord recomputes the numbers when the labels are uploaded. Defaults toFalse.
LabelRowError- If labels have not been initialized.
workflow_reopen
label_hash yet, this method does
nothing.
This method acts on the main branch and doesn’t update this object. To see the new workflow stage, list the
label row again with project.list_label_rows_v2().
For more details, see the
workflow documentation.
Arguments:
bundle- If not provided, the task is moved immediately. If provided, the operation is deferred and performed together with the other operations in the bundle.
LabelRowError- If the label row is detached.WrongProjectTypeError- If the project doesn’t use workflows.InvalidArgumentsError- If the first annotation stage of the workflow is a consensus stage.
workflow_complete
label_hash is set. You don’t need to initialize them
each time you call this method.
This method acts on the main branch and doesn’t update this object. To see the new workflow stage, list the
label row again with project.list_label_rows_v2().
For more details, see the
workflow documentation.
Arguments:
bundle- If not provided, the task is moved immediately. If provided, the operation is deferred and performed together with the other operations in the bundle.
LabelRowError- Iflabel_hashisNone, or if the label row is detached.WrongProjectTypeError- If the project doesn’t use workflows.
set_priority
priority- A value from 0.0 to 1.0, where 1.0 is the highest priority. Encord rejects values outside this range.bundle- If not provided, the priority is set immediately. If provided, the operation is deferred and performed together with the other operations in the bundle.
LabelRowError- If the label row is detached.WrongProjectTypeError- If the project doesn’t use workflows.
get_validation_errors
Optional[List[str]]- The error messages if the labels are invalid, orNoneif the labels are valid or the label row has nolabel_hashyet.
LabelRowError- If the label row is detached.
attach_to_project
label_hash, data_hash, and dataset_hash) from
the project and applies it to this label row, keeping its labels. If the label row doesn’t exist on Encord yet,
it is created. After this call, you can upload the labels with
save().
The ontology used to create the detached label row must match the project’s ontology (the same feature hashes),
or Encord rejects the save. Labels on frames beyond the data unit’s frame count may also be rejected.
Arguments:
project- The project to attach to.data_hash- The data hash of the data unit in the project.
LabelRowError- If the project has no label row fordata_hash.
FrameViewMetadata Objects
title
str- The title.
file_type
image/jpeg.
Returns:
str- The MIME type, or an empty string if it is not known.
width
int- The width, or 0 if it is not known.
height
int- The height, or 0 if it is not known.
image_hash
str- The image hash.
frame_number
int- The frame number.
FrameView Objects
image_hash
str- The image hash.
LabelRowError- If the data type is not IMAGE or IMG_GROUP.
image_title
str- The image title.
LabelRowError- If the data type is not IMAGE or IMG_GROUP.
file_type
str- The file type.
LabelRowError- If the data type is not IMAGE or IMG_GROUP.
frame
int- The frame number.
width
int- The width.
LabelRowError- If the width is not set for this data type.
height
int- The height.
LabelRowError- If the height is not set for this data type.
data_link
Optional[str]- The data link, orNoneif not available.
LabelRowError- If the data type is not IMAGE or IMG_GROUP.
metadata
Optional[DICOMSliceMetadata]- The slice metadata, orNonefor data types other than DICOM.
add_object_instance
object_instance- The object instance to add.coordinates- The coordinates for the object instance.overwrite- Whether to overwrite existing instance data (default is False).created_at- Optional creation timestamp.created_by- Optional creator identifier.last_edited_at- Optional last edited timestamp.last_edited_by- Optional last editor identifier.confidence- Optional confidence score.manual_annotation- Optional flag indicating manual annotation.
LabelRowError- If the row is event-based or the object belongs to a different label row.
add_classification_instance
classification_instance- The classification instance to add.overwrite- Whether to overwrite existing instance data (default is False).created_at- Optional creation timestamp.created_by- Optional creator identifier.confidence- Confidence score. Defaults to 1.0.manual_annotation- Whether the classification was created manually. Defaults toTrue.last_edited_at- Optional last edited timestamp.last_edited_by- Optional last editor identifier.
LabelRowError- If the classification instance is already assigned to a different label row.
get_object_instances
filter_ontology_object- Optionally filter by a specific ontology object.
List[ObjectInstance]- AllObjectInstances that match the filter.
get_classification_instances
filter_ontology_classification- Optionally filter by a specific ontology classification.
List[ClassificationInstance]- AllClassificationInstances that match the filter.
FrameLevelImageGroupData Objects
image_hash- Hash of the image.image_title- Title of the image.file_type- MIME type of the image, for exampleimage/jpeg.frame_number- The number of the frame in the sequence.width- Width of the image.height- Height of the image.data_link- Optional URL of the image.
LabelRowReadOnlyDataImagesDataEntry Objects
index- Index of the image.title- Title of the image.file_type- MIME type of the image, for exampleimage/jpeg.height- Height of the image.width- Width of the image.image_hash- Hash of the image.
LabelRowReadOnlyData Objects
label_hash- Optional hash for the label.Noneif not initialized for labeling.created_at- Optional creation timestamp.Noneif not initialized for labeling.last_edited_at- Optional last edited timestamp.Noneif not initialized for labeling.data_hash- Hash of the data.group_hash- Optional hash of the data group that the data belongs to.data_type- Type of the data (e.g., IMAGE, VIDEO).label_status- Status of the label.annotation_task_status- Optional status of the annotation task.workflow_graph_node- Optional workflow graph node related to the data.is_shadow_data- Boolean indicating if the data is a per-user shadow copy for Benchmark QA or training.number_of_frames- Number of frames in the data.duration- Optional duration of the video or sequence.fps- Optional frames per second for video.dataset_hash- Hash of the dataset.dataset_title- Title of the dataset.data_title- Title of the data.backing_item_uuid- Optional UUID of the storage item that backs the data.audio_codec- Codec for audio data.audio_bit_depth- Bit depth for audio data.audio_sample_rate- Sample Rate for audio data.audio_num_channels- Number of channels for audio data.width- Optional width of the data.height- Optional height of the data.data_link- Optional URL of the underlying file.task_uuid- Optional task uuid of the data.priority- Optional priority of the data.file_type- Optional MIME type of the file.client_metadata- Optional metadata provided by the client.images_data- Optional list of image data entries.branch_name- Name of the branch associated with the data.frame_level_data- Mapping from frame number to frame level data.image_hash_to_frame- Mapping from image hash to frame number.frame_to_image_hash- Mapping from frame number to image hash.is_valid- Boolean indicating if the data is valid.assigned_user_email- Optional email of the user assigned to the data.last_actioned_by_user_email- Optional email of the user who last actioned the data.

