Skip to content

Commit

Permalink
Merge pull request #239 from HumanSignal/fb-RND-95
Browse files Browse the repository at this point in the history
Release 1.0.1
  • Loading branch information
niklub authored Jun 12, 2024
2 parents 4c960a9 + 33d815b commit f6fb130
Showing 1 changed file with 14 additions and 112 deletions.
126 changes: 14 additions & 112 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,38 +54,29 @@ The Label Studio Python Library provides convenient access to the Label Studio A
Explore the Label Studio API documentation [here](https://api.labelstud.io/).
<!-- Begin Installation, generated by Fern -->
# Installation
```sh
pip install --upgrade label-studio-sdk
```
<!-- End Installation -->
<!-- Begin Usage, generated by Fern -->
# Usage
```python
from label_studio_sdk.client import LabelStudio
client = LabelStudio(
ls = LabelStudio(
base_url='YOUR_LABEL_STUDIO_URL',
api_key="YOUR_API_KEY",
)
```
<!-- End Usage -->
# Examples
## Get all projects
```python
projects = client.projects.list()
```
## Create a new project
```python
project = client.projects.create(
project = ls.projects.create(
name="Project name",
description="Project description",
label_config="""
Expand All @@ -100,115 +91,26 @@ project = client.projects.create(
)
```
## Get project by ID
```python
project = client.projects.get("PROJECT_ID")
```
## Update project
```python
project = client.projects.update(
project="PROJECT_ID",
description="New project description",
)
```
## Delete project
```python
client.projects.delete("PROJECT_ID")
```
## Get tasks with annotations and predictions
```python
tasks = client.tasks.list(project="PROJECT_ID")
```
## Get task by ID
```python
task = client.tasks.get("TASK_ID")
```
## Create a new task
```python
task = client.tasks.create(
project="PROJECT_ID",
data={
"data": {
"image": "https://example.com/image.jpg",
"label": "cat"
}
}
)
```
## Import batch tasks
```python
ls.projects.import_tasks(
id=project.id,
request=[
{"text": "Hello world"},
{"text": "Hello Label Studio"},
{"text": "What a beautiful day"},
]
)
```
## Update task
```python
task = client.tasks.update(
project="PROJECT_ID",
task="TASK_ID",
data={
"data": {
"image": "https://example.com/image.jpg",
"label": "dog"
}
}
)
```
## Delete task
```python
client.tasks.delete(project="PROJECT_ID", task="TASK_ID")
```
## Create prediction
```python
prediction = client.predictions.create(
task="TASK_ID",
result=[{'from_name': 'bbox', 'to_name': 'image', 'type': 'labels', 'value': {'rectanglelabels': [{'x': 10, 'y': 20, 'width': 30, 'height': 40, 'rectanglelabels': ['cat']}]}}],
score=0.9,
model_version='yolov8',
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.
## Update prediction
## Export annotations
```python
prediction = client.predictions.update(
task="TASK_ID",
prediction="PREDICTION_ID",
result=[{'from_name': 'bbox', 'to_name': 'image', 'type': 'labels', 'value': {'rectanglelabels': [{'x': 10, 'y': 20, 'width': 30, 'height': 40, 'rectanglelabels': ['dog']}]}}],
score=0.8,
model_version='yolov8',
)
annotations = [
task.annotations
for task in ls.tasks.list(project=project.id, fields='all')
if task.annotations
]
```
## Delete prediction
```python
client.predictions.delete(task="TASK_ID", prediction="PREDICTION_ID")
```
## Async client
Expand Down

0 comments on commit f6fb130

Please sign in to comment.