label-studio-sdk 1.0.8__py3-none-any.whl → 1.0.10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of label-studio-sdk might be problematic. Click here for more details.
- label_studio_sdk/__init__.py +20 -7
- label_studio_sdk/_extensions/label_studio_tools/core/utils/io.py +16 -4
- label_studio_sdk/_extensions/pager_ext.py +8 -0
- label_studio_sdk/actions/client.py +91 -40
- label_studio_sdk/actions/types/actions_create_request_filters.py +14 -24
- label_studio_sdk/actions/types/actions_create_request_filters_items_item.py +16 -26
- label_studio_sdk/actions/types/actions_create_request_filters_items_item_value.py +3 -1
- label_studio_sdk/actions/types/actions_create_request_selected_items.py +1 -2
- label_studio_sdk/actions/types/actions_create_request_selected_items_excluded.py +15 -25
- label_studio_sdk/actions/types/actions_create_request_selected_items_included.py +15 -25
- label_studio_sdk/annotations/__init__.py +2 -2
- label_studio_sdk/annotations/client.py +278 -104
- label_studio_sdk/annotations/types/__init__.py +2 -1
- label_studio_sdk/annotations/types/annotations_create_bulk_request_selected_items.py +34 -0
- label_studio_sdk/annotations/types/annotations_create_bulk_response_item.py +11 -21
- label_studio_sdk/base_client.py +46 -27
- label_studio_sdk/client.py +1 -0
- label_studio_sdk/comments/client.py +190 -44
- label_studio_sdk/converter/converter.py +56 -13
- label_studio_sdk/converter/imports/yolo.py +1 -1
- label_studio_sdk/converter/utils.py +3 -2
- label_studio_sdk/core/__init__.py +21 -4
- label_studio_sdk/core/client_wrapper.py +9 -10
- label_studio_sdk/core/file.py +37 -8
- label_studio_sdk/core/http_client.py +52 -28
- label_studio_sdk/core/jsonable_encoder.py +33 -31
- label_studio_sdk/core/pagination.py +5 -4
- label_studio_sdk/core/pydantic_utilities.py +272 -4
- label_studio_sdk/core/query_encoder.py +38 -13
- label_studio_sdk/core/request_options.py +3 -0
- label_studio_sdk/core/serialization.py +272 -0
- label_studio_sdk/errors/bad_request_error.py +2 -3
- label_studio_sdk/export_storage/azure/client.py +228 -58
- label_studio_sdk/export_storage/azure/types/azure_create_response.py +19 -29
- label_studio_sdk/export_storage/azure/types/azure_update_response.py +19 -29
- label_studio_sdk/export_storage/client.py +48 -18
- label_studio_sdk/export_storage/gcs/client.py +228 -58
- label_studio_sdk/export_storage/gcs/types/gcs_create_response.py +19 -29
- label_studio_sdk/export_storage/gcs/types/gcs_update_response.py +19 -29
- label_studio_sdk/export_storage/local/client.py +222 -56
- label_studio_sdk/export_storage/local/types/local_create_response.py +17 -27
- label_studio_sdk/export_storage/local/types/local_update_response.py +17 -27
- label_studio_sdk/export_storage/redis/client.py +228 -58
- label_studio_sdk/export_storage/redis/types/redis_create_response.py +20 -30
- label_studio_sdk/export_storage/redis/types/redis_update_response.py +20 -30
- label_studio_sdk/export_storage/s3/client.py +228 -58
- label_studio_sdk/export_storage/s3/types/s3create_response.py +27 -35
- label_studio_sdk/export_storage/s3/types/s3update_response.py +27 -35
- label_studio_sdk/export_storage/s3s/client.py +187 -43
- label_studio_sdk/export_storage/types/export_storage_list_types_response_item.py +11 -21
- label_studio_sdk/files/client.py +172 -56
- label_studio_sdk/import_storage/azure/client.py +223 -53
- label_studio_sdk/import_storage/azure/types/azure_create_response.py +22 -32
- label_studio_sdk/import_storage/azure/types/azure_update_response.py +22 -32
- label_studio_sdk/import_storage/client.py +48 -18
- label_studio_sdk/import_storage/gcs/client.py +223 -53
- label_studio_sdk/import_storage/gcs/types/gcs_create_response.py +22 -32
- label_studio_sdk/import_storage/gcs/types/gcs_update_response.py +22 -32
- label_studio_sdk/import_storage/local/client.py +223 -53
- label_studio_sdk/import_storage/local/types/local_create_response.py +17 -27
- label_studio_sdk/import_storage/local/types/local_update_response.py +17 -27
- label_studio_sdk/import_storage/redis/client.py +223 -53
- label_studio_sdk/import_storage/redis/types/redis_create_response.py +20 -30
- label_studio_sdk/import_storage/redis/types/redis_update_response.py +20 -30
- label_studio_sdk/import_storage/s3/client.py +223 -53
- label_studio_sdk/import_storage/s3/types/s3create_response.py +31 -39
- label_studio_sdk/import_storage/s3/types/s3update_response.py +31 -39
- label_studio_sdk/import_storage/s3s/client.py +222 -52
- label_studio_sdk/import_storage/types/import_storage_list_types_response_item.py +11 -21
- label_studio_sdk/label_interface/control_tags.py +1 -1
- label_studio_sdk/ml/client.py +280 -78
- label_studio_sdk/ml/types/ml_create_response.py +21 -31
- label_studio_sdk/ml/types/ml_update_response.py +21 -31
- label_studio_sdk/model_providers/client.py +173 -56
- label_studio_sdk/predictions/client.py +247 -101
- label_studio_sdk/projects/__init__.py +3 -0
- label_studio_sdk/projects/client.py +309 -115
- label_studio_sdk/projects/client_ext.py +16 -0
- label_studio_sdk/projects/exports/__init__.py +3 -0
- label_studio_sdk/projects/exports/client.py +447 -296
- label_studio_sdk/projects/exports/client_ext.py +134 -0
- label_studio_sdk/projects/exports/types/__init__.py +6 -0
- label_studio_sdk/projects/exports/types/exports_convert_response.py +24 -0
- label_studio_sdk/projects/exports/types/exports_list_formats_response_item.py +44 -0
- label_studio_sdk/projects/types/projects_create_response.py +29 -34
- label_studio_sdk/projects/types/projects_import_tasks_response.py +19 -29
- label_studio_sdk/projects/types/projects_list_response.py +11 -21
- label_studio_sdk/projects/types/projects_update_response.py +24 -34
- label_studio_sdk/prompts/client.py +309 -92
- label_studio_sdk/prompts/indicators/client.py +67 -23
- label_studio_sdk/prompts/runs/client.py +95 -40
- label_studio_sdk/prompts/types/prompts_batch_failed_predictions_request_failed_predictions_item.py +14 -24
- label_studio_sdk/prompts/types/prompts_batch_failed_predictions_response.py +11 -21
- label_studio_sdk/prompts/types/prompts_batch_predictions_request_results_item.py +26 -29
- label_studio_sdk/prompts/types/prompts_batch_predictions_response.py +11 -21
- label_studio_sdk/prompts/versions/client.py +277 -88
- label_studio_sdk/tasks/client.py +263 -90
- label_studio_sdk/tasks/types/tasks_list_response.py +15 -25
- label_studio_sdk/types/__init__.py +10 -6
- label_studio_sdk/types/annotation.py +29 -38
- label_studio_sdk/types/annotation_filter_options.py +14 -24
- label_studio_sdk/types/annotations_dm_field.py +30 -39
- label_studio_sdk/types/azure_blob_export_storage.py +28 -37
- label_studio_sdk/types/azure_blob_import_storage.py +28 -37
- label_studio_sdk/types/base_task.py +30 -39
- label_studio_sdk/types/base_task_updated_by.py +3 -1
- label_studio_sdk/types/base_user.py +14 -21
- label_studio_sdk/types/comment.py +12 -21
- label_studio_sdk/types/comment_created_by.py +1 -1
- label_studio_sdk/types/converted_format.py +12 -22
- label_studio_sdk/types/data_manager_task_serializer.py +31 -40
- label_studio_sdk/types/data_manager_task_serializer_annotators_item.py +1 -1
- label_studio_sdk/types/data_manager_task_serializer_drafts_item.py +13 -22
- label_studio_sdk/types/data_manager_task_serializer_predictions_item.py +15 -24
- label_studio_sdk/types/export.py +17 -26
- label_studio_sdk/types/export_format.py +25 -0
- label_studio_sdk/types/export_snapshot.py +45 -0
- label_studio_sdk/types/export_snapshot_status.py +5 -0
- label_studio_sdk/types/file_upload.py +11 -21
- label_studio_sdk/types/filter.py +16 -26
- label_studio_sdk/types/filter_group.py +12 -22
- label_studio_sdk/types/gcs_export_storage.py +28 -37
- label_studio_sdk/types/gcs_import_storage.py +28 -37
- label_studio_sdk/types/inference_run.py +14 -23
- label_studio_sdk/types/inference_run_cost_estimate.py +17 -27
- label_studio_sdk/types/inference_run_created_by.py +1 -1
- label_studio_sdk/types/inference_run_organization.py +1 -1
- label_studio_sdk/types/key_indicator_value.py +12 -22
- label_studio_sdk/types/key_indicators.py +0 -1
- label_studio_sdk/types/key_indicators_item.py +15 -25
- label_studio_sdk/types/key_indicators_item_additional_kpis_item.py +13 -23
- label_studio_sdk/types/key_indicators_item_extra_kpis_item.py +13 -23
- label_studio_sdk/types/local_files_export_storage.py +25 -34
- label_studio_sdk/types/local_files_import_storage.py +24 -33
- label_studio_sdk/types/ml_backend.py +23 -32
- label_studio_sdk/types/model_provider_connection.py +22 -31
- label_studio_sdk/types/model_provider_connection_created_by.py +1 -1
- label_studio_sdk/types/model_provider_connection_organization.py +1 -1
- label_studio_sdk/types/model_provider_connection_provider.py +3 -1
- label_studio_sdk/types/prediction.py +21 -30
- label_studio_sdk/types/project.py +48 -55
- label_studio_sdk/types/project_import.py +21 -30
- label_studio_sdk/types/project_label_config.py +12 -22
- label_studio_sdk/types/prompt.py +24 -32
- label_studio_sdk/types/prompt_associated_projects_item.py +6 -0
- label_studio_sdk/types/prompt_associated_projects_item_id.py +20 -0
- label_studio_sdk/types/prompt_created_by.py +1 -1
- label_studio_sdk/types/prompt_organization.py +1 -1
- label_studio_sdk/types/prompt_version.py +13 -22
- label_studio_sdk/types/prompt_version_created_by.py +1 -1
- label_studio_sdk/types/prompt_version_organization.py +1 -1
- label_studio_sdk/types/prompt_version_provider.py +3 -1
- label_studio_sdk/types/redis_export_storage.py +29 -38
- label_studio_sdk/types/redis_import_storage.py +28 -37
- label_studio_sdk/types/refined_prompt_response.py +19 -29
- label_studio_sdk/types/s3export_storage.py +36 -43
- label_studio_sdk/types/s3import_storage.py +37 -44
- label_studio_sdk/types/s3s_export_storage.py +26 -33
- label_studio_sdk/types/s3s_import_storage.py +35 -42
- label_studio_sdk/types/serialization_option.py +12 -22
- label_studio_sdk/types/serialization_options.py +18 -28
- label_studio_sdk/types/task.py +44 -47
- label_studio_sdk/types/task_annotators_item.py +1 -1
- label_studio_sdk/types/task_comment_authors_item.py +1 -1
- label_studio_sdk/types/task_filter_options.py +15 -25
- label_studio_sdk/types/user_simple.py +11 -21
- label_studio_sdk/types/view.py +16 -26
- label_studio_sdk/types/webhook.py +19 -28
- label_studio_sdk/types/webhook_serializer_for_update.py +19 -28
- label_studio_sdk/types/workspace.py +22 -31
- label_studio_sdk/users/client.py +257 -63
- label_studio_sdk/users/types/users_get_token_response.py +12 -22
- label_studio_sdk/users/types/users_reset_token_response.py +12 -22
- label_studio_sdk/version.py +0 -1
- label_studio_sdk/versions/__init__.py +5 -0
- label_studio_sdk/versions/client.py +112 -0
- label_studio_sdk/versions/types/__init__.py +6 -0
- label_studio_sdk/versions/types/versions_get_response.py +73 -0
- label_studio_sdk/versions/types/versions_get_response_edition.py +5 -0
- label_studio_sdk/views/client.py +219 -52
- label_studio_sdk/views/types/views_create_request_data.py +13 -23
- label_studio_sdk/views/types/views_create_request_data_filters.py +14 -24
- label_studio_sdk/views/types/views_create_request_data_filters_items_item.py +16 -26
- label_studio_sdk/views/types/views_create_request_data_filters_items_item_value.py +3 -1
- label_studio_sdk/views/types/views_update_request_data.py +13 -23
- label_studio_sdk/views/types/views_update_request_data_filters.py +14 -24
- label_studio_sdk/views/types/views_update_request_data_filters_items_item.py +16 -26
- label_studio_sdk/views/types/views_update_request_data_filters_items_item_value.py +3 -1
- label_studio_sdk/webhooks/client.py +191 -61
- label_studio_sdk/workspaces/client.py +164 -41
- label_studio_sdk/workspaces/members/client.py +109 -31
- label_studio_sdk/workspaces/members/types/members_create_response.py +12 -22
- label_studio_sdk/workspaces/members/types/members_list_response_item.py +12 -22
- {label_studio_sdk-1.0.8.dist-info → label_studio_sdk-1.0.10.dist-info}/METADATA +7 -5
- {label_studio_sdk-1.0.8.dist-info → label_studio_sdk-1.0.10.dist-info}/RECORD +197 -184
- {label_studio_sdk-1.0.8.dist-info → label_studio_sdk-1.0.10.dist-info}/WHEEL +1 -1
- label_studio_sdk/types/export_convert.py +0 -32
- label_studio_sdk/types/export_create.py +0 -54
- label_studio_sdk/types/export_create_status.py +0 -5
- {label_studio_sdk-1.0.8.dist-info → label_studio_sdk-1.0.10.dist-info}/LICENSE +0 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
3
|
import typing
|
|
4
|
+
from ..core.client_wrapper import SyncClientWrapper
|
|
5
|
+
from ..core.request_options import RequestOptions
|
|
6
|
+
from ..types.prediction import Prediction
|
|
7
|
+
from ..core.pydantic_utilities import parse_obj_as
|
|
4
8
|
from json.decoder import JSONDecodeError
|
|
5
|
-
|
|
6
9
|
from ..core.api_error import ApiError
|
|
7
|
-
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
8
10
|
from ..core.jsonable_encoder import jsonable_encoder
|
|
9
|
-
from ..core.
|
|
10
|
-
from ..core.request_options import RequestOptions
|
|
11
|
-
from ..types.prediction import Prediction
|
|
11
|
+
from ..core.client_wrapper import AsyncClientWrapper
|
|
12
12
|
|
|
13
13
|
# this is used as the default value for optional parameters
|
|
14
14
|
OMIT = typing.cast(typing.Any, ...)
|
|
@@ -26,6 +26,7 @@ class PredictionsClient:
|
|
|
26
26
|
request_options: typing.Optional[RequestOptions] = None,
|
|
27
27
|
) -> typing.List[Prediction]:
|
|
28
28
|
"""
|
|
29
|
+
|
|
29
30
|
Get a list of all predictions. You can optionally filter these by task or by project. If you want to filter, you will need the project ID and/or task ID. Both of these can be found in the Label Studio URL when viewing a task, or you can use [List all projects](../projects/list) and [Get tasks list](../tasks/list).
|
|
30
31
|
|
|
31
32
|
<Note>The terms "predictions" and pre-annotations" are used interchangeably.</Note>
|
|
@@ -52,7 +53,7 @@ class PredictionsClient:
|
|
|
52
53
|
|
|
53
54
|
Examples
|
|
54
55
|
--------
|
|
55
|
-
from label_studio_sdk
|
|
56
|
+
from label_studio_sdk import LabelStudio
|
|
56
57
|
|
|
57
58
|
client = LabelStudio(
|
|
58
59
|
api_key="YOUR_API_KEY",
|
|
@@ -60,11 +61,23 @@ class PredictionsClient:
|
|
|
60
61
|
client.predictions.list()
|
|
61
62
|
"""
|
|
62
63
|
_response = self._client_wrapper.httpx_client.request(
|
|
63
|
-
"api/predictions/",
|
|
64
|
+
"api/predictions/",
|
|
65
|
+
method="GET",
|
|
66
|
+
params={
|
|
67
|
+
"task": task,
|
|
68
|
+
"project": project,
|
|
69
|
+
},
|
|
70
|
+
request_options=request_options,
|
|
64
71
|
)
|
|
65
72
|
try:
|
|
66
73
|
if 200 <= _response.status_code < 300:
|
|
67
|
-
return
|
|
74
|
+
return typing.cast(
|
|
75
|
+
typing.List[Prediction],
|
|
76
|
+
parse_obj_as(
|
|
77
|
+
type_=typing.List[Prediction], # type: ignore
|
|
78
|
+
object_=_response.json(),
|
|
79
|
+
),
|
|
80
|
+
)
|
|
68
81
|
_response_json = _response.json()
|
|
69
82
|
except JSONDecodeError:
|
|
70
83
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
@@ -74,22 +87,21 @@ class PredictionsClient:
|
|
|
74
87
|
self,
|
|
75
88
|
*,
|
|
76
89
|
task: typing.Optional[int] = OMIT,
|
|
77
|
-
result: typing.Optional[typing.Sequence[typing.Dict[str, typing.Any]]] = OMIT,
|
|
90
|
+
result: typing.Optional[typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]] = OMIT,
|
|
78
91
|
score: typing.Optional[float] = OMIT,
|
|
79
92
|
model_version: typing.Optional[str] = OMIT,
|
|
80
93
|
request_options: typing.Optional[RequestOptions] = None,
|
|
81
94
|
) -> Prediction:
|
|
82
95
|
"""
|
|
96
|
+
|
|
83
97
|
If you have predictions generated for your dataset from a model, either as pre-annotated tasks or pre-labeled tasks, you can import the predictions with your dataset into Label Studio for review and correction.
|
|
84
98
|
|
|
85
99
|
To import predicted labels into Label Studio, you must use the [Basic Label Studio JSON format](https://labelstud.io/guide/tasks#Basic-Label-Studio-JSON-format) and set up your tasks with the predictions JSON key. The Label Studio ML backend also outputs tasks in this format.
|
|
86
100
|
|
|
87
101
|
#### JSON format for predictions
|
|
88
|
-
|
|
89
102
|
Label Studio JSON format for pre-annotations must contain two sections:
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
- A predictions array that contains the pre-annotation results for the different types of labeling. See how to add results to the predictions array.
|
|
103
|
+
* A data object which references the source of the data that the pre-annotations apply to. This can be a URL to an audio file, a pre-signed cloud storage link to an image, plain text, a reference to a CSV file stored in Label Studio, or something else.
|
|
104
|
+
* A predictions array that contains the pre-annotation results for the different types of labeling. See how to add results to the predictions array.
|
|
93
105
|
|
|
94
106
|
For more information, see [the JSON format reference in the Label Studio documentation](https://labelstud.io/guide/predictions#JSON-format-for-pre-annotations)
|
|
95
107
|
|
|
@@ -98,7 +110,7 @@ class PredictionsClient:
|
|
|
98
110
|
task : typing.Optional[int]
|
|
99
111
|
Task ID for which the prediction is created
|
|
100
112
|
|
|
101
|
-
result : typing.Optional[typing.Sequence[typing.Dict[str, typing.Any]]]
|
|
113
|
+
result : typing.Optional[typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]]
|
|
102
114
|
Prediction result in JSON format. Read more about the format in [the Label Studio documentation.](https://labelstud.io/guide/predictions)
|
|
103
115
|
|
|
104
116
|
score : typing.Optional[float]
|
|
@@ -117,7 +129,7 @@ class PredictionsClient:
|
|
|
117
129
|
|
|
118
130
|
Examples
|
|
119
131
|
--------
|
|
120
|
-
from label_studio_sdk
|
|
132
|
+
from label_studio_sdk import LabelStudio
|
|
121
133
|
|
|
122
134
|
client = LabelStudio(
|
|
123
135
|
api_key="YOUR_API_KEY",
|
|
@@ -148,13 +160,27 @@ class PredictionsClient:
|
|
|
148
160
|
_response = self._client_wrapper.httpx_client.request(
|
|
149
161
|
"api/predictions/",
|
|
150
162
|
method="POST",
|
|
151
|
-
json={
|
|
163
|
+
json={
|
|
164
|
+
"task": task,
|
|
165
|
+
"result": result,
|
|
166
|
+
"score": score,
|
|
167
|
+
"model_version": model_version,
|
|
168
|
+
},
|
|
169
|
+
headers={
|
|
170
|
+
"content-type": "application/json",
|
|
171
|
+
},
|
|
152
172
|
request_options=request_options,
|
|
153
173
|
omit=OMIT,
|
|
154
174
|
)
|
|
155
175
|
try:
|
|
156
176
|
if 200 <= _response.status_code < 300:
|
|
157
|
-
return
|
|
177
|
+
return typing.cast(
|
|
178
|
+
Prediction,
|
|
179
|
+
parse_obj_as(
|
|
180
|
+
type_=Prediction, # type: ignore
|
|
181
|
+
object_=_response.json(),
|
|
182
|
+
),
|
|
183
|
+
)
|
|
158
184
|
_response_json = _response.json()
|
|
159
185
|
except JSONDecodeError:
|
|
160
186
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
@@ -162,6 +188,7 @@ class PredictionsClient:
|
|
|
162
188
|
|
|
163
189
|
def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> Prediction:
|
|
164
190
|
"""
|
|
191
|
+
|
|
165
192
|
Get details about a specific prediction by its ID. To find the prediction ID, use [List predictions](list).
|
|
166
193
|
|
|
167
194
|
For information about the prediction format, see [the JSON format reference in the Label Studio documentation](https://labelstud.io/guide/predictions#JSON-format-for-pre-annotations).
|
|
@@ -181,7 +208,7 @@ class PredictionsClient:
|
|
|
181
208
|
|
|
182
209
|
Examples
|
|
183
210
|
--------
|
|
184
|
-
from label_studio_sdk
|
|
211
|
+
from label_studio_sdk import LabelStudio
|
|
185
212
|
|
|
186
213
|
client = LabelStudio(
|
|
187
214
|
api_key="YOUR_API_KEY",
|
|
@@ -191,11 +218,19 @@ class PredictionsClient:
|
|
|
191
218
|
)
|
|
192
219
|
"""
|
|
193
220
|
_response = self._client_wrapper.httpx_client.request(
|
|
194
|
-
f"api/predictions/{jsonable_encoder(id)}/",
|
|
221
|
+
f"api/predictions/{jsonable_encoder(id)}/",
|
|
222
|
+
method="GET",
|
|
223
|
+
request_options=request_options,
|
|
195
224
|
)
|
|
196
225
|
try:
|
|
197
226
|
if 200 <= _response.status_code < 300:
|
|
198
|
-
return
|
|
227
|
+
return typing.cast(
|
|
228
|
+
Prediction,
|
|
229
|
+
parse_obj_as(
|
|
230
|
+
type_=Prediction, # type: ignore
|
|
231
|
+
object_=_response.json(),
|
|
232
|
+
),
|
|
233
|
+
)
|
|
199
234
|
_response_json = _response.json()
|
|
200
235
|
except JSONDecodeError:
|
|
201
236
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
@@ -203,6 +238,7 @@ class PredictionsClient:
|
|
|
203
238
|
|
|
204
239
|
def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
205
240
|
"""
|
|
241
|
+
|
|
206
242
|
Delete a prediction. To find the prediction ID, use [List predictions](list).
|
|
207
243
|
|
|
208
244
|
Parameters
|
|
@@ -219,7 +255,7 @@ class PredictionsClient:
|
|
|
219
255
|
|
|
220
256
|
Examples
|
|
221
257
|
--------
|
|
222
|
-
from label_studio_sdk
|
|
258
|
+
from label_studio_sdk import LabelStudio
|
|
223
259
|
|
|
224
260
|
client = LabelStudio(
|
|
225
261
|
api_key="YOUR_API_KEY",
|
|
@@ -229,7 +265,9 @@ class PredictionsClient:
|
|
|
229
265
|
)
|
|
230
266
|
"""
|
|
231
267
|
_response = self._client_wrapper.httpx_client.request(
|
|
232
|
-
f"api/predictions/{jsonable_encoder(id)}/",
|
|
268
|
+
f"api/predictions/{jsonable_encoder(id)}/",
|
|
269
|
+
method="DELETE",
|
|
270
|
+
request_options=request_options,
|
|
233
271
|
)
|
|
234
272
|
try:
|
|
235
273
|
if 200 <= _response.status_code < 300:
|
|
@@ -244,12 +282,13 @@ class PredictionsClient:
|
|
|
244
282
|
id: int,
|
|
245
283
|
*,
|
|
246
284
|
task: typing.Optional[int] = OMIT,
|
|
247
|
-
result: typing.Optional[typing.Sequence[typing.Dict[str, typing.Any]]] = OMIT,
|
|
285
|
+
result: typing.Optional[typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]] = OMIT,
|
|
248
286
|
score: typing.Optional[float] = OMIT,
|
|
249
287
|
model_version: typing.Optional[str] = OMIT,
|
|
250
288
|
request_options: typing.Optional[RequestOptions] = None,
|
|
251
289
|
) -> Prediction:
|
|
252
290
|
"""
|
|
291
|
+
|
|
253
292
|
Update a prediction. To find the prediction ID, use [List predictions](list).
|
|
254
293
|
|
|
255
294
|
For information about the prediction format, see [the JSON format reference in the Label Studio documentation](https://labelstud.io/guide/predictions#JSON-format-for-pre-annotations).
|
|
@@ -262,7 +301,7 @@ class PredictionsClient:
|
|
|
262
301
|
task : typing.Optional[int]
|
|
263
302
|
Task ID for which the prediction is created
|
|
264
303
|
|
|
265
|
-
result : typing.Optional[typing.Sequence[typing.Dict[str, typing.Any]]]
|
|
304
|
+
result : typing.Optional[typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]]
|
|
266
305
|
Prediction result in JSON format. Read more about the format in [the Label Studio documentation.](https://labelstud.io/guide/predictions)
|
|
267
306
|
|
|
268
307
|
score : typing.Optional[float]
|
|
@@ -281,7 +320,7 @@ class PredictionsClient:
|
|
|
281
320
|
|
|
282
321
|
Examples
|
|
283
322
|
--------
|
|
284
|
-
from label_studio_sdk
|
|
323
|
+
from label_studio_sdk import LabelStudio
|
|
285
324
|
|
|
286
325
|
client = LabelStudio(
|
|
287
326
|
api_key="YOUR_API_KEY",
|
|
@@ -313,13 +352,27 @@ class PredictionsClient:
|
|
|
313
352
|
_response = self._client_wrapper.httpx_client.request(
|
|
314
353
|
f"api/predictions/{jsonable_encoder(id)}/",
|
|
315
354
|
method="PATCH",
|
|
316
|
-
json={
|
|
355
|
+
json={
|
|
356
|
+
"task": task,
|
|
357
|
+
"result": result,
|
|
358
|
+
"score": score,
|
|
359
|
+
"model_version": model_version,
|
|
360
|
+
},
|
|
361
|
+
headers={
|
|
362
|
+
"content-type": "application/json",
|
|
363
|
+
},
|
|
317
364
|
request_options=request_options,
|
|
318
365
|
omit=OMIT,
|
|
319
366
|
)
|
|
320
367
|
try:
|
|
321
368
|
if 200 <= _response.status_code < 300:
|
|
322
|
-
return
|
|
369
|
+
return typing.cast(
|
|
370
|
+
Prediction,
|
|
371
|
+
parse_obj_as(
|
|
372
|
+
type_=Prediction, # type: ignore
|
|
373
|
+
object_=_response.json(),
|
|
374
|
+
),
|
|
375
|
+
)
|
|
323
376
|
_response_json = _response.json()
|
|
324
377
|
except JSONDecodeError:
|
|
325
378
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
@@ -338,6 +391,7 @@ class AsyncPredictionsClient:
|
|
|
338
391
|
request_options: typing.Optional[RequestOptions] = None,
|
|
339
392
|
) -> typing.List[Prediction]:
|
|
340
393
|
"""
|
|
394
|
+
|
|
341
395
|
Get a list of all predictions. You can optionally filter these by task or by project. If you want to filter, you will need the project ID and/or task ID. Both of these can be found in the Label Studio URL when viewing a task, or you can use [List all projects](../projects/list) and [Get tasks list](../tasks/list).
|
|
342
396
|
|
|
343
397
|
<Note>The terms "predictions" and pre-annotations" are used interchangeably.</Note>
|
|
@@ -364,19 +418,39 @@ class AsyncPredictionsClient:
|
|
|
364
418
|
|
|
365
419
|
Examples
|
|
366
420
|
--------
|
|
367
|
-
|
|
421
|
+
import asyncio
|
|
422
|
+
|
|
423
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
368
424
|
|
|
369
425
|
client = AsyncLabelStudio(
|
|
370
426
|
api_key="YOUR_API_KEY",
|
|
371
427
|
)
|
|
372
|
-
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
async def main() -> None:
|
|
431
|
+
await client.predictions.list()
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
asyncio.run(main())
|
|
373
435
|
"""
|
|
374
436
|
_response = await self._client_wrapper.httpx_client.request(
|
|
375
|
-
"api/predictions/",
|
|
437
|
+
"api/predictions/",
|
|
438
|
+
method="GET",
|
|
439
|
+
params={
|
|
440
|
+
"task": task,
|
|
441
|
+
"project": project,
|
|
442
|
+
},
|
|
443
|
+
request_options=request_options,
|
|
376
444
|
)
|
|
377
445
|
try:
|
|
378
446
|
if 200 <= _response.status_code < 300:
|
|
379
|
-
return
|
|
447
|
+
return typing.cast(
|
|
448
|
+
typing.List[Prediction],
|
|
449
|
+
parse_obj_as(
|
|
450
|
+
type_=typing.List[Prediction], # type: ignore
|
|
451
|
+
object_=_response.json(),
|
|
452
|
+
),
|
|
453
|
+
)
|
|
380
454
|
_response_json = _response.json()
|
|
381
455
|
except JSONDecodeError:
|
|
382
456
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
@@ -386,22 +460,21 @@ class AsyncPredictionsClient:
|
|
|
386
460
|
self,
|
|
387
461
|
*,
|
|
388
462
|
task: typing.Optional[int] = OMIT,
|
|
389
|
-
result: typing.Optional[typing.Sequence[typing.Dict[str, typing.Any]]] = OMIT,
|
|
463
|
+
result: typing.Optional[typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]] = OMIT,
|
|
390
464
|
score: typing.Optional[float] = OMIT,
|
|
391
465
|
model_version: typing.Optional[str] = OMIT,
|
|
392
466
|
request_options: typing.Optional[RequestOptions] = None,
|
|
393
467
|
) -> Prediction:
|
|
394
468
|
"""
|
|
469
|
+
|
|
395
470
|
If you have predictions generated for your dataset from a model, either as pre-annotated tasks or pre-labeled tasks, you can import the predictions with your dataset into Label Studio for review and correction.
|
|
396
471
|
|
|
397
472
|
To import predicted labels into Label Studio, you must use the [Basic Label Studio JSON format](https://labelstud.io/guide/tasks#Basic-Label-Studio-JSON-format) and set up your tasks with the predictions JSON key. The Label Studio ML backend also outputs tasks in this format.
|
|
398
473
|
|
|
399
474
|
#### JSON format for predictions
|
|
400
|
-
|
|
401
475
|
Label Studio JSON format for pre-annotations must contain two sections:
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
- A predictions array that contains the pre-annotation results for the different types of labeling. See how to add results to the predictions array.
|
|
476
|
+
* A data object which references the source of the data that the pre-annotations apply to. This can be a URL to an audio file, a pre-signed cloud storage link to an image, plain text, a reference to a CSV file stored in Label Studio, or something else.
|
|
477
|
+
* A predictions array that contains the pre-annotation results for the different types of labeling. See how to add results to the predictions array.
|
|
405
478
|
|
|
406
479
|
For more information, see [the JSON format reference in the Label Studio documentation](https://labelstud.io/guide/predictions#JSON-format-for-pre-annotations)
|
|
407
480
|
|
|
@@ -410,7 +483,7 @@ class AsyncPredictionsClient:
|
|
|
410
483
|
task : typing.Optional[int]
|
|
411
484
|
Task ID for which the prediction is created
|
|
412
485
|
|
|
413
|
-
result : typing.Optional[typing.Sequence[typing.Dict[str, typing.Any]]]
|
|
486
|
+
result : typing.Optional[typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]]
|
|
414
487
|
Prediction result in JSON format. Read more about the format in [the Label Studio documentation.](https://labelstud.io/guide/predictions)
|
|
415
488
|
|
|
416
489
|
score : typing.Optional[float]
|
|
@@ -429,44 +502,66 @@ class AsyncPredictionsClient:
|
|
|
429
502
|
|
|
430
503
|
Examples
|
|
431
504
|
--------
|
|
432
|
-
|
|
505
|
+
import asyncio
|
|
506
|
+
|
|
507
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
433
508
|
|
|
434
509
|
client = AsyncLabelStudio(
|
|
435
510
|
api_key="YOUR_API_KEY",
|
|
436
511
|
)
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
"
|
|
448
|
-
"
|
|
449
|
-
"
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
async def main() -> None:
|
|
515
|
+
await client.predictions.create(
|
|
516
|
+
result=[
|
|
517
|
+
{
|
|
518
|
+
"original_width": 1920,
|
|
519
|
+
"original_height": 1080,
|
|
520
|
+
"image_rotation": 0,
|
|
521
|
+
"from_name": "bboxes",
|
|
522
|
+
"to_name": "image",
|
|
523
|
+
"type": "rectanglelabels",
|
|
524
|
+
"value": {
|
|
525
|
+
"x": 20,
|
|
526
|
+
"y": 30,
|
|
527
|
+
"width": 50,
|
|
528
|
+
"height": 60,
|
|
529
|
+
"rotation": 0,
|
|
530
|
+
"values": {"rectanglelabels": ["Person"]},
|
|
531
|
+
},
|
|
532
|
+
}
|
|
533
|
+
],
|
|
534
|
+
score=0.95,
|
|
535
|
+
model_version="yolo-v8",
|
|
536
|
+
)
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
asyncio.run(main())
|
|
459
540
|
"""
|
|
460
541
|
_response = await self._client_wrapper.httpx_client.request(
|
|
461
542
|
"api/predictions/",
|
|
462
543
|
method="POST",
|
|
463
|
-
json={
|
|
544
|
+
json={
|
|
545
|
+
"task": task,
|
|
546
|
+
"result": result,
|
|
547
|
+
"score": score,
|
|
548
|
+
"model_version": model_version,
|
|
549
|
+
},
|
|
550
|
+
headers={
|
|
551
|
+
"content-type": "application/json",
|
|
552
|
+
},
|
|
464
553
|
request_options=request_options,
|
|
465
554
|
omit=OMIT,
|
|
466
555
|
)
|
|
467
556
|
try:
|
|
468
557
|
if 200 <= _response.status_code < 300:
|
|
469
|
-
return
|
|
558
|
+
return typing.cast(
|
|
559
|
+
Prediction,
|
|
560
|
+
parse_obj_as(
|
|
561
|
+
type_=Prediction, # type: ignore
|
|
562
|
+
object_=_response.json(),
|
|
563
|
+
),
|
|
564
|
+
)
|
|
470
565
|
_response_json = _response.json()
|
|
471
566
|
except JSONDecodeError:
|
|
472
567
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
@@ -474,6 +569,7 @@ class AsyncPredictionsClient:
|
|
|
474
569
|
|
|
475
570
|
async def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> Prediction:
|
|
476
571
|
"""
|
|
572
|
+
|
|
477
573
|
Get details about a specific prediction by its ID. To find the prediction ID, use [List predictions](list).
|
|
478
574
|
|
|
479
575
|
For information about the prediction format, see [the JSON format reference in the Label Studio documentation](https://labelstud.io/guide/predictions#JSON-format-for-pre-annotations).
|
|
@@ -493,21 +589,37 @@ class AsyncPredictionsClient:
|
|
|
493
589
|
|
|
494
590
|
Examples
|
|
495
591
|
--------
|
|
496
|
-
|
|
592
|
+
import asyncio
|
|
593
|
+
|
|
594
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
497
595
|
|
|
498
596
|
client = AsyncLabelStudio(
|
|
499
597
|
api_key="YOUR_API_KEY",
|
|
500
598
|
)
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
)
|
|
599
|
+
|
|
600
|
+
|
|
601
|
+
async def main() -> None:
|
|
602
|
+
await client.predictions.get(
|
|
603
|
+
id=1,
|
|
604
|
+
)
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
asyncio.run(main())
|
|
504
608
|
"""
|
|
505
609
|
_response = await self._client_wrapper.httpx_client.request(
|
|
506
|
-
f"api/predictions/{jsonable_encoder(id)}/",
|
|
610
|
+
f"api/predictions/{jsonable_encoder(id)}/",
|
|
611
|
+
method="GET",
|
|
612
|
+
request_options=request_options,
|
|
507
613
|
)
|
|
508
614
|
try:
|
|
509
615
|
if 200 <= _response.status_code < 300:
|
|
510
|
-
return
|
|
616
|
+
return typing.cast(
|
|
617
|
+
Prediction,
|
|
618
|
+
parse_obj_as(
|
|
619
|
+
type_=Prediction, # type: ignore
|
|
620
|
+
object_=_response.json(),
|
|
621
|
+
),
|
|
622
|
+
)
|
|
511
623
|
_response_json = _response.json()
|
|
512
624
|
except JSONDecodeError:
|
|
513
625
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
@@ -515,6 +627,7 @@ class AsyncPredictionsClient:
|
|
|
515
627
|
|
|
516
628
|
async def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
517
629
|
"""
|
|
630
|
+
|
|
518
631
|
Delete a prediction. To find the prediction ID, use [List predictions](list).
|
|
519
632
|
|
|
520
633
|
Parameters
|
|
@@ -531,17 +644,27 @@ class AsyncPredictionsClient:
|
|
|
531
644
|
|
|
532
645
|
Examples
|
|
533
646
|
--------
|
|
534
|
-
|
|
647
|
+
import asyncio
|
|
648
|
+
|
|
649
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
535
650
|
|
|
536
651
|
client = AsyncLabelStudio(
|
|
537
652
|
api_key="YOUR_API_KEY",
|
|
538
653
|
)
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
)
|
|
654
|
+
|
|
655
|
+
|
|
656
|
+
async def main() -> None:
|
|
657
|
+
await client.predictions.delete(
|
|
658
|
+
id=1,
|
|
659
|
+
)
|
|
660
|
+
|
|
661
|
+
|
|
662
|
+
asyncio.run(main())
|
|
542
663
|
"""
|
|
543
664
|
_response = await self._client_wrapper.httpx_client.request(
|
|
544
|
-
f"api/predictions/{jsonable_encoder(id)}/",
|
|
665
|
+
f"api/predictions/{jsonable_encoder(id)}/",
|
|
666
|
+
method="DELETE",
|
|
667
|
+
request_options=request_options,
|
|
545
668
|
)
|
|
546
669
|
try:
|
|
547
670
|
if 200 <= _response.status_code < 300:
|
|
@@ -556,12 +679,13 @@ class AsyncPredictionsClient:
|
|
|
556
679
|
id: int,
|
|
557
680
|
*,
|
|
558
681
|
task: typing.Optional[int] = OMIT,
|
|
559
|
-
result: typing.Optional[typing.Sequence[typing.Dict[str, typing.Any]]] = OMIT,
|
|
682
|
+
result: typing.Optional[typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]] = OMIT,
|
|
560
683
|
score: typing.Optional[float] = OMIT,
|
|
561
684
|
model_version: typing.Optional[str] = OMIT,
|
|
562
685
|
request_options: typing.Optional[RequestOptions] = None,
|
|
563
686
|
) -> Prediction:
|
|
564
687
|
"""
|
|
688
|
+
|
|
565
689
|
Update a prediction. To find the prediction ID, use [List predictions](list).
|
|
566
690
|
|
|
567
691
|
For information about the prediction format, see [the JSON format reference in the Label Studio documentation](https://labelstud.io/guide/predictions#JSON-format-for-pre-annotations).
|
|
@@ -574,7 +698,7 @@ class AsyncPredictionsClient:
|
|
|
574
698
|
task : typing.Optional[int]
|
|
575
699
|
Task ID for which the prediction is created
|
|
576
700
|
|
|
577
|
-
result : typing.Optional[typing.Sequence[typing.Dict[str, typing.Any]]]
|
|
701
|
+
result : typing.Optional[typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]]
|
|
578
702
|
Prediction result in JSON format. Read more about the format in [the Label Studio documentation.](https://labelstud.io/guide/predictions)
|
|
579
703
|
|
|
580
704
|
score : typing.Optional[float]
|
|
@@ -593,45 +717,67 @@ class AsyncPredictionsClient:
|
|
|
593
717
|
|
|
594
718
|
Examples
|
|
595
719
|
--------
|
|
596
|
-
|
|
720
|
+
import asyncio
|
|
721
|
+
|
|
722
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
597
723
|
|
|
598
724
|
client = AsyncLabelStudio(
|
|
599
725
|
api_key="YOUR_API_KEY",
|
|
600
726
|
)
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
"
|
|
613
|
-
"
|
|
614
|
-
"
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
async def main() -> None:
|
|
730
|
+
await client.predictions.update(
|
|
731
|
+
id=1,
|
|
732
|
+
result=[
|
|
733
|
+
{
|
|
734
|
+
"original_width": 1920,
|
|
735
|
+
"original_height": 1080,
|
|
736
|
+
"image_rotation": 0,
|
|
737
|
+
"from_name": "bboxes",
|
|
738
|
+
"to_name": "image",
|
|
739
|
+
"type": "rectanglelabels",
|
|
740
|
+
"value": {
|
|
741
|
+
"x": 20,
|
|
742
|
+
"y": 30,
|
|
743
|
+
"width": 50,
|
|
744
|
+
"height": 60,
|
|
745
|
+
"rotation": 0,
|
|
746
|
+
"values": {"rectanglelabels": ["Person"]},
|
|
747
|
+
},
|
|
748
|
+
}
|
|
749
|
+
],
|
|
750
|
+
score=0.95,
|
|
751
|
+
model_version="yolo-v8",
|
|
752
|
+
)
|
|
753
|
+
|
|
754
|
+
|
|
755
|
+
asyncio.run(main())
|
|
624
756
|
"""
|
|
625
757
|
_response = await self._client_wrapper.httpx_client.request(
|
|
626
758
|
f"api/predictions/{jsonable_encoder(id)}/",
|
|
627
759
|
method="PATCH",
|
|
628
|
-
json={
|
|
760
|
+
json={
|
|
761
|
+
"task": task,
|
|
762
|
+
"result": result,
|
|
763
|
+
"score": score,
|
|
764
|
+
"model_version": model_version,
|
|
765
|
+
},
|
|
766
|
+
headers={
|
|
767
|
+
"content-type": "application/json",
|
|
768
|
+
},
|
|
629
769
|
request_options=request_options,
|
|
630
770
|
omit=OMIT,
|
|
631
771
|
)
|
|
632
772
|
try:
|
|
633
773
|
if 200 <= _response.status_code < 300:
|
|
634
|
-
return
|
|
774
|
+
return typing.cast(
|
|
775
|
+
Prediction,
|
|
776
|
+
parse_obj_as(
|
|
777
|
+
type_=Prediction, # type: ignore
|
|
778
|
+
object_=_response.json(),
|
|
779
|
+
),
|
|
780
|
+
)
|
|
635
781
|
_response_json = _response.json()
|
|
636
782
|
except JSONDecodeError:
|
|
637
783
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
from .types import ProjectsCreateResponse, ProjectsImportTasksResponse, ProjectsListResponse, ProjectsUpdateResponse
|
|
4
4
|
from . import exports
|
|
5
|
+
from .exports import ExportsConvertResponse, ExportsListFormatsResponseItem
|
|
5
6
|
|
|
6
7
|
__all__ = [
|
|
8
|
+
"ExportsConvertResponse",
|
|
9
|
+
"ExportsListFormatsResponseItem",
|
|
7
10
|
"ProjectsCreateResponse",
|
|
8
11
|
"ProjectsImportTasksResponse",
|
|
9
12
|
"ProjectsListResponse",
|