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 withpip 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.34OR 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
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"),
),
)
Enterprise features
Create comments
comment = ls.comments.create(
project=project.id,
annotation=annotation.id,
text="Comment text"
)
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file label_studio_sdk-1.0.7.tar.gz
.
File metadata
- Download URL: label_studio_sdk-1.0.7.tar.gz
- Upload date:
- Size: 198.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.10.12 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 392a5274e12e33263afefb92327824e3a79e1f1f570cab83a5fbfa5454cd8b4a |
|
MD5 | 95314c11cefe31b4a69f6a9990b6f978 |
|
BLAKE2b-256 | 332a50c1a8d1f8b1cccaa2f7b87aa495c6a8e97336e62a5e6c05188f436c6cf1 |
File details
Details for the file label_studio_sdk-1.0.7-py3-none-any.whl
.
File metadata
- Download URL: label_studio_sdk-1.0.7-py3-none-any.whl
- Upload date:
- Size: 358.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.10.12 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2220a8012d9a5affd6224ca9c56a60a83e7fc037c3a3e9ffa78ade227d13957 |
|
MD5 | 0b82804a9ac420e78e11a6a0841b0c69 |
|
BLAKE2b-256 | b093d8ba35c12b5bb5e16cbd64578009aacaf5f490231267e044e2ab9ca49c8d |