Label studio 이미지 데이터가 많을 때 yolo format으로 다운로드 하는 법

MonteB·2023년 8월 18일
0

https://labelstud.io/sdk/project.html
label studio sdk를 사용해서 snapshot을 만들어 충분히 다운로드 가능한 크기로 만들어 다운로드 하는 방법입니다.

https://labelstud.io/guide/api.html

Label Studio Access token 가져오는 방법

  1. In the Label Studio UI, click the user icon in the upper right.
  2. Click Account & Settings.
  3. Copy the access token.
# Import the SDK and the client module
from label_studio_sdk import Client
import json
import os

# Define the URL where Label Studio is accessible and the API key for your user account
LABEL_STUDIO_URL = 'http://localhost:8080'
API_KEY = '여기에 API 키를 복사해서 입력하세요'
project_id = 2

# Connect to the Label Studio API and check the connection
ls = Client(url=LABEL_STUDIO_URL, api_key=API_KEY)
ls.check_connection()

print('Connection to Label Studio established successfully.')

# snapshot create
# export snapsho create
result = ls.get_project(project_id).export_snapshot_create('snapshot_create')

# print result
print(result)

# snapshot list
# export snapshot list
result = ls.get_project(project_id).export_snapshot_list()

# print result
print(json.dumps(result, indent=4, sort_keys=True))

# delte snapshot
# export snapshot delete
result = ls.get_project(project_id).export_snapshot_delete(3)

print(result)

# snapshot download
code = ls.get_project(project_id).export_snapshot_download(1, export_type='YOLO', path='.')

# print(code) # 200 is success

# upload image using folder path and project id
code = ls.get_project(project_id).import_tasks([{ 'image': 

# get image list
ls.get_project(project_id).get_image_list()
result = ls.get_project(project_id).get_image_list()

ls.get_project(project_id).export_snapshot_create('snapshot name')이 함수를 통해 snapshot을 만들수 있다.

https://github.com/HumanSignal/label-studio-sdk/blob/master/examples/export_snapshots.py#L29

위 코드는 snapshot을 사용하는 예제이다. tab으로 filter된 task들로 구성된 snapshot을 만들수 있다.

https://github.com/HumanSignal/label-studio/issues/1114
위의 github 이슈는 선택된 아이템만 snapshot 하기 위한 방법에 관한 이슈이다.

snapshot GUI 기능은 label studio 유료 버전에서만 사용 가능해서 API, SDK를 사용하는 방법이 필요하다.

profile
안녕하세요

1개의 댓글

comment-user-thumbnail
2023년 8월 18일

많은 도움이 되었습니다, 감사합니다.

답글 달기