Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export labeled data from Label Studio to YOLO format with image downloading and correct filenames from uploaded files #6771

Closed
makseq opened this issue Dec 9, 2024 · 0 comments

Comments

@makseq
Copy link
Member

makseq commented Dec 9, 2024

Problems

  1. Images are not exported during the YOLO/COCO export.
  2. Uploaded images to LS don't have original names, because there are hashes in the beginning.

Import note about UI uploads to LS: be aware that uploads are not highly recommended. It's better to use cloud storages and sync them. In this case all image names will stay the same and you will be able to easily download these images.

Downloader Script

This scripts downloads Label Studio JSON snapshot, converts it to yolo and downloads all images from the snapshot. The disadvantage of this script: it downloads all images from the Label Studio host, it will take some time. Abu's approach above is faster, because it just moves images from one folder to another on your hard dri

Install the script:

pip install git+https://github.com/heartexlabs/label-studio-sdk.git
  1. Save script as downloader.py
  2. Copy your API key on the /user/account page.
  3. Run script:
python script.py --api_key <your_api_key> --project_id <your_project_id>

or

export LABEL_STUDIO_API_KEY=<your-api-key>
python script.py --project_id <your_project_id>

The script does these steps specifically:

  1. Creates export snapshot
  2. Waits until export is ready
  3. Downloads export snapshot in JSON format
  4. Create and init Converter from label_studio_converter
  5. Run convert_to_yolo()
  6. After this you get a folder with yolo annotations
  7. Now iterate over all exported tasks from snapshot and download images from each task using label_studio_tools.core.utils.io.get_local_path(url, hostname=None, access_token=None, task_id=None) -> str (path where image was downloaded).
  8. Move downloaded image to yolo images dir

Download the script here:
https://github.com/HumanSignal/label-studio-sdk/blob/master/examples/export_yolo_with_images.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant