From 33d815bb1d8dd80ebf750753778d341981f05bd3 Mon Sep 17 00:00:00 2001 From: nik Date: Wed, 12 Jun 2024 13:28:32 +0100 Subject: [PATCH] Update README ffor release --- README.md | 126 ++++++------------------------------------------------ 1 file changed, 14 insertions(+), 112 deletions(-) diff --git a/README.md b/README.md index dc5eea91..914c0e40 100644 --- a/README.md +++ b/README.md @@ -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/). - # Installation ```sh pip install --upgrade label-studio-sdk ``` - - # Usage ```python from label_studio_sdk.client import LabelStudio -client = LabelStudio( +ls = LabelStudio( + base_url='YOUR_LABEL_STUDIO_URL', api_key="YOUR_API_KEY", ) ``` - # 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=""" @@ -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