Skip to main content

No project description provided

Project description

Label Studio Python Library


:warning: Note

The version of label-studio-sdk<1 is deprecated and no longer supported. We recommend updating to the latest version. If you still want to use the old version, you can install it with pip install "label-studio-sdk<1". OR You can find the branch with the old version by cloning the repository and checking out the branch as follows:

git clone https://github.com/HumanSignal/label-studio-sdk.git
cd label-studio-sdk
git fetch origin
git checkout release/0.0.34

OR you can change your import statements as follows:

from label_studio_sdk import Client
from label_studio_sdk.data_manager import Filters, Column, Operator, Type
from label_studio_sdk._legacy import Project

fern shield pypi

The Label Studio Python Library provides convenient access to the Label Studio API from applications written in Python.

Documentation

Explore the Label Studio API documentation here.

Installation

pip install --upgrade label-studio-sdk
# or
poetry add label-studio-sdk

Usage

from label_studio_sdk.client import LabelStudio

ls = LabelStudio(
    base_url='YOUR_LABEL_STUDIO_URL',  
    api_key="YOUR_API_KEY",
)

Examples

Check more examples here.

Create a new project

from label_studio_sdk.label_interface import LabelInterface
from label_studio_sdk.label_interface.create import labels

project = ls.projects.create(
    name="Project name",
    description="Project description",
    label_config=LabelInterface.create({
      "image": "Image",
      "bbox": labels(["cat", "dog"], tag_type="RectangleLabels")
    })
)

Create a new task

task = ls.tasks.create(
    project=project.id,
    data={"image": "https://example.com/image.jpg"}
)

Now you can open the project PROJECT_ID in the Label Studio UI and create annotations for the task.

Export annotations

annotations = [
    task.annotations
    for task in ls.tasks.list(project=project.id, fields='all')
    if task.annotations
]

Async client

from label_studio_sdk.client import AsyncLabelStudio

client = AsyncLabelStudio(
    api_key="YOUR_API_KEY",
)

Advanced

Timeouts

By default, requests time out after 60 seconds. You can configure this with a timeout option at the client or request level.

from label_studio_sdk.client import LabelStudio

ls = LabelStudio(
    # All timeouts set to 20 seconds
    timeout=20.0
)

ls.projects.create(..., {
    # Override timeout for a specific method
    timeout=20.0
})

Custom HTTP client

You can override the httpx client to customize it for your use-case. Some common use-cases include support for proxies and transports.

import httpx

from label_studio_sdk.client import LabelStudio

ls = LabelStudio(
    http_client=httpx.Client(
        proxies="http://my.test.proxy.example.com",
        transport=httpx.HTTPTransport(local_address="0.0.0.0"),
    ),
)

Contributing

Please follow this guide to contribute to the SDK

While we value open-source contributions to this SDK, this library is generated programmatically. Additions made directly to this library would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!

On the other hand, contributions to the README are always very welcome!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

label_studio_sdk-1.0.5.tar.gz (178.9 kB view details)

Uploaded Source

Built Distribution

label_studio_sdk-1.0.5-py3-none-any.whl (318.8 kB view details)

Uploaded Python 3

File details

Details for the file label_studio_sdk-1.0.5.tar.gz.

File metadata

  • Download URL: label_studio_sdk-1.0.5.tar.gz
  • Upload date:
  • Size: 178.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1025-azure

File hashes

Hashes for label_studio_sdk-1.0.5.tar.gz
Algorithm Hash digest
SHA256 8ee436ed5c3a7bc283de68a5708e0438400fd7f5981ae0a516d44d0a77777302
MD5 16cef695f18f4d4071784cad6632dc0b
BLAKE2b-256 e71a02df4df2dbdf8b89635fb2f1879ff259ebd1a0cc7722f40f9f2679559434

See more details on using hashes here.

File details

Details for the file label_studio_sdk-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: label_studio_sdk-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 318.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1025-azure

File hashes

Hashes for label_studio_sdk-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 0298380fd504f1a88c447b7f674157f5361c7c1e5f78f24c1f2907b1fa877d53
MD5 0322efe2fcb59f6a8a9fd37194150a0c
BLAKE2b-256 18d2581b38e782c2e6032bfa8e75df83db9ab2295edc674ea285b469a74d8115

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page