- export JSON file with the following function.
import time
from label_studio_sdk import Client
# https://labelstud.io/guide/export
# https://github.com/HumanSignal/label-studio-sdk/blob/master/examples/export_snapshots.py
def ExportSnapshot(LABEL_STUDIO_URL, API_KEY, PROJECT_ID, SAVE_PATH):
# 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)
# get the first tab
views = project.get_views()
task_filter_options = {'view': views[0]['id']} if views else {}
# create new export snapshot
export_result = project.export_snapshot_create(
title='Export SDK Snapshot', task_filter_options=task_filter_options
)
# assert 'id' in export_result
export_id = export_result['id']
# # wait until snapshot is ready
while project.export_snapshot_status(export_id).is_in_progress():
time.sleep(1.0)
# download snapshot file
status, file_name = project.export_snapshot_download(export_id, export_type='JSON', path=SAVE_PATH)
assert status == 200
assert file_name is not None
print(f"Status of the export is {status}.\nFile name is {file_name}")
- set
LS_UPLOAD_DIR
in.zshrc
or.bashrc
andsource ~/.zshrc
orsource ~/.bashrc
# label studio
export LS_UPLOAD_DIR=/home/epbox/AI/data/media/upload
- save .xml file of the export project
- use
label-studio-converter
to convert JSON to YOLO format
pip install label-studio-converter
label-studio-converter export -i <ExportSnapshot export>.json --config <export project config>.xml -o "train" -f YOLO
- check the convert YOLO train folder
(label) ➜ train -h --filelimit=10 --dirsfirst
train
├── [ 20K] images [208 entries exceeds filelimit, not opening dir]
├── [ 20K] labels [208 entries exceeds filelimit, not opening dir]
├── [ 124] classes.txt
└── [ 840] notes.json
2 directories, 2 files