HumanSignal / label-studio

Label Studio is a multi-type data labeling and annotation tool with standardized output format
https://labelstud.io
Apache License 2.0
19.34k stars 2.4k forks source link

Label Studio SDK doesnt download images with export_tasks and YOLO format #5242

Open JaviMota opened 10 months ago

JaviMota commented 10 months ago

Hi Im filtering the labeled data with the data manager module succesfully and Im getting the list of ids to export them with the "export_tasks" function. The thing is I want to export them in YOLO format and the output looks like a binary file. How can I work with this binary file? I am also setting "download_resources=True" and specifying an "export_location". I would expect to have the same behaviour than exporting them from the UI, with two folders containing the images and the labels.

Thank you.

hogepodge commented 10 months ago

Hi @JaviMota, can you help provide us with more information to help reproduce the issue? A label config, sample data, and steps to reproduce would help us determine if it's a bug.

JaviMota commented 10 months ago

Hi This is the code Im using:

LABEL_STUDIO_URL = os.getenv('LABEL_STUDIO_URL', default='http://virt-entw02.xxx.net:8080') API_KEY = "xxx" PROJECT_ID = 6

// connect to Label Studio ls = Client(url=LABEL_STUDIO_URL, api_key=API_KEY) ls.check_connection()

// get existing project project = ls.get_project(PROJECT_ID)

filters=Filters.create(Filters.OR, [Filters.item(Column.annotations_results, Operator.CONTAINS, Type.String, Filters.value("Person"))]) tasks = project.get_tasks(filters=filters) id_filtered_list = [d["id"] for d in tasks]

project.export_tasks(export_type="YOLO", download_all_tasks=False, download_resources=True, ids=id_filtered_list, export_location="~/label_studio_sdk/export_data")

This is the label configuration:

<View>
  <Image name="image" value="$image" zoom="true"/>

  <Header value="RectangleLabels"/>
  <RectangleLabels name="label" toName="image">
  <Label value="Person" background="#FFA39E"/><Label value="Car" background="#729fcf"/><Label value="Bus" background="#8ae234"/><Label value="Truck" background="#a40000"/><Label value="Motorcycle" background="#e9b96e"/><Label value="Bicycle" background="#ad7fa8"/></RectangleLabels>
</View>

The idea is to filter the images containing a label and download the images and the labels. It would be also nice to be able to download a single label info even if we have multiple labels in the dataset.

Thank you.