ExportLabel.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. from label_studio_sdk import Client
  2. from label_studio_sdk.data_manager import Filters, Column, Operator, Type
  3. LABEL_STUDIO_URL = "http://192.168.10.18:8081" # 或者是你的Label Studio的URL
  4. API_KEY = "b614d8c956495f52ea3f3f598c0be3f11866d9a0" # 从Label Studio获得你的API密钥
  5. #LABEL_STUDIO_URL = "http://localhost:8080" # 或者是你的Label Studio的URL
  6. #API_KEY = "87ae9ca430852c3b9753bacf214b7f90bedf5bdd" # 从Label Studio获得你的API密钥
  7. # 初始化 Label Studio 客户端
  8. ls = Client(url=LABEL_STUDIO_URL, api_key=API_KEY)
  9. projects = ls.get_projects()
  10. for project in projects:
  11. print(f"Project ID: {project.id}, Project Title: {project.title}")
  12. # Project ID: 22, Project Title: LA_Table_Figure_V1.3_20230208
  13. # Project ID: 16, Project Title: LA_KR_1.0.0
  14. # Project ID: 14, Project Title: LA_VAL_1.0.0
  15. # Project ID: 12, Project Title: Demo1
  16. # Project ID: 10, Project Title: LA_0.1.0
  17. # Project ID: 4, Project Title: Test Project #1
  18. PROJECT_ID = 22 # 项目 ID
  19. # 获取项目
  20. project = ls.get_project(PROJECT_ID)
  21. filters = Filters.create(Filters.AND, [
  22. Filters.item(
  23. Column.inner_id,
  24. Operator.GREATER_OR_EQUAL,
  25. Type.Number,
  26. Filters.value(1)
  27. ),
  28. Filters.item(
  29. Column.inner_id,
  30. Operator.LESS_OR_EQUAL,
  31. Type.Number,
  32. Filters.value(3000)
  33. )
  34. ])
  35. export_result = project.export(filters=filters, export_type='YOLO')
  36. # 导出数据
  37. # export_result = project.export_tasks(export_type = "YOLO",
  38. # download_all_tasks = False,
  39. # download_resources = True,
  40. # export_location = 'C:/test/yolo_export.zip')
  41. print('导出完成')