Tutorial: Importing Local YOLO Pre-Annotated Images to Label Studio
Today, we're diving into Label Studio Format Converter, a handy tool that helps you encode labels into formats compatible with your favorite machine learning libraries, enhancing workflow efficiency.
In this tutorial, we'll explore the process of importing YOLO pre-annotated images into Label Studio for further annotation.
Here's an overview of the integration process:
Prerequisites
Before we begin, make sure you have the following:
- Label Studio installed on your local environment. If you haven't set it up yet, follow the instructions here.
- YOLO annotated images and their corresponding .txt label files, organized within the directory
/yolo/datasets/one
. - label-studio-converter installed (this is included in Label Studio by default, so no additional action needed)
Step 1: Set Up Your Environment and Label Studio
To get started, configure your environment and launch Label Studio.
For Unix systems:
export LABEL_STUDIO_LOCAL_FILES_SERVING_ENABLED=true
export LABEL_STUDIO_LOCAL_FILES_DOCUMENT_ROOT=/yolo/datasets
label-studio
For Windows:
set LABEL_STUDIO_LOCAL_FILES_SERVING_ENABLED=true
set LABEL_STUDIO_LOCAL_FILES_DOCUMENT_ROOT=C:\\yolo\\datasets
Label-studio
Note: Make sure to replace /yolo/datasets
with the actual path to your YOLO datasets directory.
Step 2: Configure Local Storage
Next, you'll configure Local Storage to seamlessly integrate your dataset into the Label Studio platform.
- Create a new project in Label Studio.
- Head to the project settings and select Cloud Storage.
- Click Add Source Storage and choose Local files from the Storage Type options.
- Set the Absolute local path to
/yolo/datasets/one/images
. If you're a Windows user, set it toc:\yolo\datasets\one\images
. - Select Add storage to confirm the setup.
Step 3: Check Image Access
Before moving forward, ensure you are able to access images stored in Local storage via Label Studio.
Open up a browser tab and paste in this URL:
http://localhost:8080/data/local-files/?d=one/images/<your_image>.jpg
Replace <your_image>.jpg
with the path to an image within your dataset. If all is well, you should see your image pop up.
However, if the image doesn't open, it means there's an issue with the Local Storage setup. It's possible the issue stems from an error in specifying the Path in Local Storage settings or in LABEL_STUDIO_LOCAL_FILES_DOCUMENT_ROOT
.
Note: The URL path after ?d=
should match the structure of LABEL_STUDIO_LOCAL_FILES_DOCUMENT_ROOT=/yolo/datasets
.
For example, if your image is located at /yolo/datasets/one/images/<your_image>.jpg
, the URL path should be /yolo/datasets/one/images/<your_image>.jpg
.
Step 4: Convert the YOLO Annotations
Time to work some magic with the Label Studio Converter!
Pop open your terminal and enter:
label-studio-converter import yolo -i /yolo/datasets/one -o output.json --image-root-url "/data/local-files/?d=one/images"
Step 5: Import the Converted Annotations
Now that you're done with the conversion process, you'll then import the annotations into your Label Studio project.
Here's how to go about it:
- Return to your Label Studio project.
- In the Data Manager, select Import.
- Choose the output.json file for import.
Step 6: Double-check the Annotations
After importing, take a moment to review your images in Label Studio.
Your pre-annotated bounding boxes should be visible and ready for action. Ensure everything looks good, and if needed, make any necessary adjustments.
Bonus: Troubleshooting Issues
If you're encountering any issues with paths or image accessibility, here's what you can do:
1) Double-check that your LABEL_STUDIO_LOCAL_FILES_DOCUMENT_ROOT
is configured correctly. This ensures that Label Studio knows where to find your dataset.
2) Make sure the --image-root-url
in the conversion command matches the relative path. You can find this path by subtracting LABEL_STUDIO_LOCAL_FILES_DOCUMENT_ROOT
from the Absolute local path specified in your Local Storage settings.
Here's what we mean:
`Absolute local path from Local Storage Settings` — `LABEL_STUDIO_LOCAL_FILES_DOCUMENT_ROOT` = `path for --image_root_url`
So, if your absolute local path is /yolo/datasets/one/images
and your LABEL_STUDIO_LOCAL_FILES_DOCUMENT_ROOT
is /yolo/datasets/
, then the path for --image_root_url
would be one/images
.
3) Ensure that your Local Storage setup in Label Studio is accurate, particularly the Absolute local path to your images (/yolo/datasets/one/images
).
For more help, check out our detailed guides on importing importing pre-annotated data and setting up Cloud Storages. It covers everything you need to know to troubleshoot any problems you run into.