Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

YOLO import to LS doesnt import labels #236

Open
KrystianLata opened this issue Aug 8, 2023 · 2 comments
Open

YOLO import to LS doesnt import labels #236

KrystianLata opened this issue Aug 8, 2023 · 2 comments

Comments

@KrystianLata
Copy link

KrystianLata commented Aug 8, 2023

Hi,
I am trying to import pre-annoted images (object detection) to label-studio,

I've followed official guide and other issue on github, but im not able to figure out why it doesnt work.

I am using the following code to create json with predictions:

label-studio-converter import yolo -i /home/krystian/Desktop/label-studio/storage/inventory/ --image-root-url /data/local-files/?d=Desktop/label-studio/storage/inventory/images -o /home/krystian/Desktop/label-studio/storage/inventory/ls-tasks3.json --image-ext png

my storage is set like that:

image

labeling setup is set as in the .xml file

but after loading json i dont see any annotations:

image

is that becouse of problem with json file? it look like that:

[{"data": {"image": "/data/local-files/?d=Desktop/label-studio/storage/inventory/images/652.png"}}, {"data": {"image": "/data/local-files/?d=Desktop/label-studio/storage/inventory/images/1280.png"}}, {"data": {"image": "/data/local-files/?d=Desktop/label-studio/storage/inventory/images/1120.png"}}, {"data": {"image": "/data/local-files/?d=Desktop/label-studio/storage/inventory/images/517.png"}}, {"data": {"image": "/data/local-files/?d=Desktop/label-studio/storage/inventory/images/382.png"}}, {"data": {"image": "/data/local-files/?d=Desktop/label-studio/storage/inventory/images/294.png"}}, {"data": {"image": "/data/local-files/?d=Desktop/label-studio/storage/inventory/images/749.png"}},

also, i dont know if thats matter.

my storage folder is in path:
/home/krystian/Desktop/label-studio/storage/inventory

there are folders:
images
labels
and classes.txt

when I am adding storages i have to set option "Treat every bucket object as a source file" on True becouse without this i have fail in sychoronisation

image

image

@EnvyAlwaysWannaFly
Copy link

I was able to solve this problem.
I use local storage.
I use absolute paths.
I use Win10.
label-studio-converter import yolo -i D:\label-studio\project --image-root-url D:\label-studio\project\images -o D:\label-studio\project\ls-tasks.json
The first way "D:\label-studio\project" - tells you where the input data is images, labels, classes.txt
Second way "D:\label-studio\project\images" - tells us where the images for our project are located, the paths of which will be placed in the .json
Third way "D:\label-studio\project\ls-tasks.json" - tells you where the file will be created under the name "ls-tasks"
I run the command and after a while I have two files created:

  1. "ls-tasks.json"
  2. "ls-tasks.label_config.xml"
    along the way "D:\label-studio\project"
    IMPORTANT! edit the file ls-tasks.json
    First of all, check the slash "", they all have to be in the same direction as in your system.
    I had something like this: "D:\label-studio\project\images/tmp_1%20image.jpg"
    %20 - are the spaces between the characters
    / - in the path to the image correct the entire file to \
    \ - in the path to the image correct the entire file to %5C
    D:\ - should be replaced by local storage, which we will customize in the future, replace it with this one: "/data/local-files/?d="
    "/data/local-files/?d=" - If you had a previously created project with local storage and images, you might have seen this path

It was: "D:\label-studio\project\images/tmp_1%20image.jpg"
It became: "/data/local-files/?d=label-studio%5Cproject%5Cimages%5Ctmp_1%20image.jpg"

Now you need to run LS with local storage access rights.
For Windows: "set LABEL_STUDIO_LOCAL_FILES_SERVING_ENABLED=true"
Make sure everything worked: "echo %LABEL_STUDIO_LOCAL_FILES_SERVING_ENABLED%"
Run LS: "label-studio"
Create a new project:

  1. Left the name as standard
  2. No description
  3. Do not import
  4. The markup is taken from the file "ls-tasks.label_config.xml", and in the "code" mode insert a new markup (Erasing the previous one)
  5. Save the project
  6. Go to the settings of the created project
  7. Create local storage and specify the path where our images were located "D:\label-studio\project\images"
  8. Check connection, synchronize
  9. I delete the created images from the project, and there will be an empty project with connected storage and ready markup.
  10. Press import, and select the file on the path "D:\label-studio\project\ls-tasks.json"
    Done, we'll have all the images we need with markup.

I tried to write more details for those who will have a similar error.

@govindrai
Copy link

govindrai commented Oct 23, 2023

The documentation is not clear at all. The setup and usage is not intuitive either. Eventually trying every single pattern and a lot of unnecessary wasted time this worked (similar to what you found): label-studio-converter import yolo -i PATH_TO_YOUR_YOLO_FOLDER -o tasks.json --image-root-url /data/local-files/\?d=PATH_TO_YOUR_YOLO_FOLER/images --image-ext .IMG_EXTENSION (i.e. .png)

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

No branches or pull requests

3 participants