Export Labels
The Encord SDK is designed to offer a versatile and targeted approach to accessing label information. This approach allows for a more customized handling of label information, catering to various needs and scenarios in data processing.
The following table describes all values exported by the scripts on this page.
Key | Description |
---|---|
objectHash | The unique ID of the object instance. Two instances of the same object have different object hashes |
Object name | The name of the object as defined in the Ontology. For example “Chicken”. |
featureHash | The unique ID of the Ontology element. For example, the object “Chicken” in the Ontology. All instances have the same featureHash. |
uid | The unique identifier for the object instance. Two instances of the same object have different uids. |
Object color | The color used to label the object, as defined in the Ontology and seen in the Encord platform. |
Ontology shape | The shape used to label the object, as defined in the Ontology. For example, polygon. |
Classification name | The name of the Classification, as defined in the Ontology. For example “Day or night?” |
Classification answer | The value of the Classification, as defined in the Ontology. For example “Day” |
classificationHash | The unique identifier for the Classification instance. |
Classification answer hash | The unique identifier for the Classification value |
Attribute name | The name of the attribute, as defined in the Ontology. For example “Standing or sitting?” |
Attribute answer | The name of the attribute value, as defined in the Ontology. For example “Sitting” |
Attribute answer featureHash | The unique identifier for the attribute value. |
Export labels as JSON
The following script prints a JSON file containing all the labels in your Project.
Make sure you substitute:
- The <file-path-to-ssh-key> with the full path to your SSH private key.
- The <project_unique-id> with the hash of your Project.
- The <file-path> with the file path to save the JSON file, with your labels.
Export attributes
The following scripts get the attributes for all labels in a Project, as well as the frames that the attributes appear on. Single images only have a single frame.
In the following scripts, ensure that you:
- Replace <private_key_path> with the full path to your private key.
- Replace <project_hash> with the hash of the Project you want to export attributes for.
- Replace <task_name> with the name of the data unit you want to export attributes for. Remove
data_title_eq="<task_name>"
if you want to export attributes for all tasks.
Export objects, classifications, and attributes by frame
Range of consecutive frames
The following scripts download and print the labels for a specified range of frames in videos.
Make sure you substitute:
- The <private_key_path> with the full path to your private key.
- The <project_hash> with the hash of your Project.
- The <task_name> with the name of the task you want to export labels for (if using the task-specific script).
- The <start_frame_number> with the first frame of the range you want to export labels for.
- The <end_frame_number> with the last frame of the range you want to export labels for.
List of non-consecutive frames
The following scripts download and print the labels for specific frames in videos.
Make sure you substitute:
- The <private_key_path> with the full path to your private key.
- The <project_hash> with the hash of your Project.
- The <task_name> with the name of the file (in Encord) you want to export labels for (if using the task-specific script).
- Replace the numbers in the list
[10, 20, 30, 40]
with the frames you want to export labels for.
Saving frames with labels on them
ffmpeg
can be used to save all frames with labels as an image, to be used in machine learning applications. The script below shows how this is done when exporting a list of non-consecutive frames from a specific video.
Make sure you substitute:
- The <output_folder_path> with the full path to the output folder you want the output image files to be saved.
- The <private_key_path> with the full path to your private key.
- The <project_hash> with the hash of your Project.
- The <task_name> with the name of the file in Encord you want to export labels for.
- The <path_to_your_video_file> with the full path to the video file you are exporting labels for.
- Replace the numbers in the list
[10, 20, 30, 40]
with the frames you want to export labels for.
Label editor coordinates
All label locations are exported as normalized coordinates ranging from 0 to 1. This means that the corners of the frame or image correspond to the coordinates (1,1), (1,0), (0,0), (0,1) regardless of frame dimensions.
To get the pixel values of any normalized coordinates, multiply them by the width or height of the label (given in pixels).
- “x” and “h” coordinates of a label should be multiplied by the pixel width.
- “y” and “w” coordinates of a label should be multiplied by the pixel height.
Export all Consensus labels
Consensus Projects introduce the concept of BRANCHES within the task workflow. A Consensus annotation task consists of a MAIN branch and one sub-branch for each Annotator. Each time an annotator saves or submits a task, the annotator creates their own branch on a task. The MAIN branch remains empty of labels until a reviewer specifies that a task is in consensus. When consensus is reached, the labels that are the best representative set move to the MAIN branch. To export all labels (labels generated for every branch on every data unit) from your Consensus Project, use include_all_branches=True
.
Make sure you:
- Substitute the <private_key_path> with the full path to your private key.
- Substitute the <project_hash> with the hash of your Project.
- If you only want to export the MAIN branch, remove
include_all_label_branches=True
.
Export labels in bulk
Use the bundle function to significantly improve export performance.
In the following code, ensure you replace:
<private_key_path>
with the full path to your private key.<project-hash>
with the unique hash of your Project.#Perform label row operation before in this loop
with the label row operations you want to perform.- Optionally, change the value of
BUNDLE_SIZE
to suit your needs. We strongly recommend NOT bundling more than 1000 operations at once, because bundling more than 1000 operations can reduce performance instead of improving performance.
Was this page helpful?