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 checkout previous-version

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

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

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

project = ls.projects.create(
    name="Project name",
    description="Project description",
    label_config="""
    <View>
        <Image name="image" value="$image" />
        <RectangleLabels name="label" toName="image">
            <Label value="cat" />
            <Label value="dog" />
        </RectangleLabels>
    </View>
    """
)

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",
)

Beta Status

This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning the package version to a specific version. This way, you can install the same version each time without breaking changes.

Contributing

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.1.tar.gz (167.3 kB view hashes)

Uploaded Source

Built Distribution

label_studio_sdk-1.0.1-py3-none-any.whl (290.0 kB view hashes)

Uploaded Python 3

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