How do I upload annotations in the MS COCO format for images?

Hello, thank you very much for you instructions and explanations.

I tried to do them.

I tried to install Label Studio SDK by pip and command

pip install label-studio-sdk

in conda virtual environment and docker with Label studio.
Also I tried to do it in poetry env by command:

poetry add label-studio-sdk

After that I tried to run Label Studio Converter by command:

label-studio-converter import \
 --input-format COCO \
 --input-file data/my_coco_annotation.json \
 --output-file data/label_studio_annotations.json

And I got this error:

label-studio-converter: command not found

I searching for it and I found this git repo(link).

As I understand it, this tool is now in the archive and its code has been included in the Label Studio SDK.

I found the converter classes:

from label_studio_sdk.converter import Converter

c = Converter()

c.convert_to_json()

Unfortunately, I didn’t able to figure out how to use them properly.

I decided to use this tool from the repository.
I install Label Studio Converter by command:

pip install label-studio-converter

I was able to convert my MS COCO annotation to Label Studio project json by command:

label-studio-converter import coco\
  -i data/my_coco_annotation.json \
  -o data/label_studio_annotations.json

After completing the conversion process, Label Studio Converter printed me the following instructions in the console:

INFO:root:Reading COCO notes and categories from /data/my_coco_annotation.json
INFO:root:Found 2 categories, 5 images and 75 annotations
WARNING:root:Segmentation in COCO is experimental
INFO:root:Saving Label Studio JSON to /data/label_studio_annotations.json

  1. Create a new project in Label Studio
  2. Use Labeling Config from "/data/label_studio_annotations.label_config.xml"
  3. Setup serving for images [e.g. you can use Local Storage (or others):
     https://labelstud.io/guide/storage.html#Local-storage]
  4. Import "/data/label_studio_annotations.json" to the project

According to the documentation from the terminal:

  1. I create a new project in Label Studio.
  2. I insert the Labeling Config provided by the converter data/label_studio_annotations.label_config.xml in project’s Labeling Config by Web UI.
  3. I import a json file with the project from Label Studio data/label_studio_annotations.json by Web UI.

After this step, the paths to the pictures will appear in the project, but the pictures themselves will not be:

I connect the local storage according to the documentation [link](https://label stud.io/guide/storage.html#Local-storage) to place images in it that will be in our project.

In order to activate Local storage, we register additional environment variables in the mydata/.new file with environment variables for the Docker container link, launching Label Studio:

LABEL_STUDIO_LOCAL_FILES_SERVING_ENABLED=true
LABEL_STUDIO_LOCAL_FILES_DOCUMENT_ROOT=/label-studio/data/local_storage

Launching Label Studio with support for the new environment variables we have set:

docker run -it -p 8080:8080 --env-file $(pwd)/mydata/.env -v $(pwd)/mydata:/label-studio/data heartexlabs/label-studio:latest 

We point the folder to dataset1:

/label-studio/data/local_storage/images

Images from the dataset appear in the project and their markup is displayed on them.

Everything works, thank you )

1 Like