Question
Is there a way within Label Studio to export a single annotation array for each task when using tools like the brush and magic wand?
Answer:
Label Studio does not natively provide a feature to automatically combine multiple annotations into a single numpy array per task upon export. However, you can achieve this by writing a custom script in Python that processes the exported annotations. The script would iterate over each task, collect all associated annotations, and merge them into one array. Here’s a skeleton of how you’d do that:
import numpy as np
import json
# Assume you have an exported JSON file with annotations from Label Studio
with open('annotations.json', 'r') as file:
annotations = json.load(file)
combined_annotations = {}
for ann in annotations:
task_id = ann['task']
annotation_array = np.array(ann['result'])
# Update combined_annotations[task_id] with the new array
# You might need to use np.vstack or np.hstack depending on your annotation structure
# You now have combined_annotations dict with task_id as keys and unified numpy arrays as values