label-studio-sdk 0.0.32__py3-none-any.whl → 1.0.0__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.
- label_studio_sdk/__init__.py +206 -6
- label_studio_sdk/_extensions/label_studio_tools/__init__.py +0 -0
- label_studio_sdk/_extensions/label_studio_tools/core/__init__.py +0 -0
- label_studio_sdk/_extensions/label_studio_tools/core/label_config.py +163 -0
- label_studio_sdk/_extensions/label_studio_tools/core/utils/__init__.py +0 -0
- label_studio_sdk/_extensions/label_studio_tools/core/utils/exceptions.py +2 -0
- label_studio_sdk/_extensions/label_studio_tools/core/utils/io.py +228 -0
- label_studio_sdk/_extensions/label_studio_tools/core/utils/params.py +45 -0
- label_studio_sdk/_extensions/label_studio_tools/etl/__init__.py +1 -0
- label_studio_sdk/_extensions/label_studio_tools/etl/beam.py +34 -0
- label_studio_sdk/_extensions/label_studio_tools/etl/example.py +17 -0
- label_studio_sdk/_extensions/label_studio_tools/etl/registry.py +67 -0
- label_studio_sdk/_extensions/label_studio_tools/postprocessing/__init__.py +0 -0
- label_studio_sdk/_extensions/label_studio_tools/postprocessing/video.py +97 -0
- label_studio_sdk/_legacy/__init__.py +11 -0
- label_studio_sdk/_legacy/client.py +471 -0
- label_studio_sdk/_legacy/exceptions.py +10 -0
- label_studio_sdk/_legacy/label_interface/__init__.py +1 -0
- label_studio_sdk/_legacy/label_interface/base.py +77 -0
- label_studio_sdk/_legacy/label_interface/control_tags.py +756 -0
- label_studio_sdk/_legacy/label_interface/data_examples.json +96 -0
- label_studio_sdk/_legacy/label_interface/interface.py +925 -0
- label_studio_sdk/_legacy/label_interface/label_tags.py +72 -0
- label_studio_sdk/_legacy/label_interface/object_tags.py +292 -0
- label_studio_sdk/_legacy/label_interface/region.py +43 -0
- label_studio_sdk/_legacy/objects.py +35 -0
- label_studio_sdk/{project.py → _legacy/project.py} +711 -258
- label_studio_sdk/_legacy/schema/label_config_schema.json +226 -0
- label_studio_sdk/{users.py → _legacy/users.py} +15 -13
- label_studio_sdk/{utils.py → _legacy/utils.py} +31 -30
- label_studio_sdk/{workspaces.py → _legacy/workspaces.py} +13 -11
- label_studio_sdk/actions/__init__.py +2 -0
- label_studio_sdk/actions/client.py +150 -0
- label_studio_sdk/annotations/__init__.py +2 -0
- label_studio_sdk/annotations/client.py +750 -0
- label_studio_sdk/client.py +164 -436
- label_studio_sdk/converter/__init__.py +7 -0
- label_studio_sdk/converter/audio.py +56 -0
- label_studio_sdk/converter/brush.py +452 -0
- label_studio_sdk/converter/converter.py +1175 -0
- label_studio_sdk/converter/exports/__init__.py +0 -0
- label_studio_sdk/converter/exports/csv.py +82 -0
- label_studio_sdk/converter/exports/csv2.py +103 -0
- label_studio_sdk/converter/funsd.py +85 -0
- label_studio_sdk/converter/imports/__init__.py +0 -0
- label_studio_sdk/converter/imports/coco.py +314 -0
- label_studio_sdk/converter/imports/colors.py +198 -0
- label_studio_sdk/converter/imports/label_config.py +45 -0
- label_studio_sdk/converter/imports/pathtrack.py +269 -0
- label_studio_sdk/converter/imports/yolo.py +236 -0
- label_studio_sdk/converter/main.py +202 -0
- label_studio_sdk/converter/utils.py +473 -0
- label_studio_sdk/core/__init__.py +33 -0
- label_studio_sdk/core/api_error.py +15 -0
- label_studio_sdk/core/client_wrapper.py +55 -0
- label_studio_sdk/core/datetime_utils.py +28 -0
- label_studio_sdk/core/file.py +38 -0
- label_studio_sdk/core/http_client.py +443 -0
- label_studio_sdk/core/jsonable_encoder.py +99 -0
- label_studio_sdk/core/pagination.py +87 -0
- label_studio_sdk/core/pydantic_utilities.py +28 -0
- label_studio_sdk/core/query_encoder.py +33 -0
- label_studio_sdk/core/remove_none_from_dict.py +11 -0
- label_studio_sdk/core/request_options.py +32 -0
- label_studio_sdk/data_manager.py +32 -23
- label_studio_sdk/environment.py +7 -0
- label_studio_sdk/errors/__init__.py +6 -0
- label_studio_sdk/errors/bad_request_error.py +8 -0
- label_studio_sdk/errors/internal_server_error.py +8 -0
- label_studio_sdk/export_storage/__init__.py +28 -0
- label_studio_sdk/export_storage/azure/__init__.py +5 -0
- label_studio_sdk/export_storage/azure/client.py +722 -0
- label_studio_sdk/export_storage/azure/types/__init__.py +6 -0
- label_studio_sdk/export_storage/azure/types/azure_create_response.py +52 -0
- label_studio_sdk/export_storage/azure/types/azure_update_response.py +52 -0
- label_studio_sdk/export_storage/client.py +107 -0
- label_studio_sdk/export_storage/gcs/__init__.py +5 -0
- label_studio_sdk/export_storage/gcs/client.py +722 -0
- label_studio_sdk/export_storage/gcs/types/__init__.py +6 -0
- label_studio_sdk/export_storage/gcs/types/gcs_create_response.py +52 -0
- label_studio_sdk/export_storage/gcs/types/gcs_update_response.py +52 -0
- label_studio_sdk/export_storage/local/__init__.py +5 -0
- label_studio_sdk/export_storage/local/client.py +688 -0
- label_studio_sdk/export_storage/local/types/__init__.py +6 -0
- label_studio_sdk/export_storage/local/types/local_create_response.py +47 -0
- label_studio_sdk/export_storage/local/types/local_update_response.py +47 -0
- label_studio_sdk/export_storage/redis/__init__.py +5 -0
- label_studio_sdk/export_storage/redis/client.py +714 -0
- label_studio_sdk/export_storage/redis/types/__init__.py +6 -0
- label_studio_sdk/export_storage/redis/types/redis_create_response.py +57 -0
- label_studio_sdk/export_storage/redis/types/redis_update_response.py +57 -0
- label_studio_sdk/export_storage/s3/__init__.py +5 -0
- label_studio_sdk/export_storage/s3/client.py +820 -0
- label_studio_sdk/export_storage/s3/types/__init__.py +6 -0
- label_studio_sdk/export_storage/s3/types/s3create_response.py +74 -0
- label_studio_sdk/export_storage/s3/types/s3update_response.py +74 -0
- label_studio_sdk/export_storage/types/__init__.py +5 -0
- label_studio_sdk/export_storage/types/export_storage_list_types_response_item.py +30 -0
- label_studio_sdk/files/__init__.py +2 -0
- label_studio_sdk/files/client.py +556 -0
- label_studio_sdk/import_storage/__init__.py +28 -0
- label_studio_sdk/import_storage/azure/__init__.py +5 -0
- label_studio_sdk/import_storage/azure/client.py +812 -0
- label_studio_sdk/import_storage/azure/types/__init__.py +6 -0
- label_studio_sdk/import_storage/azure/types/azure_create_response.py +72 -0
- label_studio_sdk/import_storage/azure/types/azure_update_response.py +72 -0
- label_studio_sdk/import_storage/client.py +107 -0
- label_studio_sdk/import_storage/gcs/__init__.py +5 -0
- label_studio_sdk/import_storage/gcs/client.py +812 -0
- label_studio_sdk/import_storage/gcs/types/__init__.py +6 -0
- label_studio_sdk/import_storage/gcs/types/gcs_create_response.py +72 -0
- label_studio_sdk/import_storage/gcs/types/gcs_update_response.py +72 -0
- label_studio_sdk/import_storage/local/__init__.py +5 -0
- label_studio_sdk/import_storage/local/client.py +690 -0
- label_studio_sdk/import_storage/local/types/__init__.py +6 -0
- label_studio_sdk/import_storage/local/types/local_create_response.py +47 -0
- label_studio_sdk/import_storage/local/types/local_update_response.py +47 -0
- label_studio_sdk/import_storage/redis/__init__.py +5 -0
- label_studio_sdk/import_storage/redis/client.py +768 -0
- label_studio_sdk/import_storage/redis/types/__init__.py +6 -0
- label_studio_sdk/import_storage/redis/types/redis_create_response.py +62 -0
- label_studio_sdk/import_storage/redis/types/redis_update_response.py +62 -0
- label_studio_sdk/import_storage/s3/__init__.py +5 -0
- label_studio_sdk/import_storage/s3/client.py +912 -0
- label_studio_sdk/import_storage/s3/types/__init__.py +6 -0
- label_studio_sdk/import_storage/s3/types/s3create_response.py +99 -0
- label_studio_sdk/import_storage/s3/types/s3update_response.py +99 -0
- label_studio_sdk/import_storage/types/__init__.py +5 -0
- label_studio_sdk/import_storage/types/import_storage_list_types_response_item.py +30 -0
- label_studio_sdk/ml/__init__.py +19 -0
- label_studio_sdk/ml/client.py +981 -0
- label_studio_sdk/ml/types/__init__.py +17 -0
- label_studio_sdk/ml/types/ml_create_request_auth_method.py +5 -0
- label_studio_sdk/ml/types/ml_create_response.py +78 -0
- label_studio_sdk/ml/types/ml_create_response_auth_method.py +5 -0
- label_studio_sdk/ml/types/ml_update_request_auth_method.py +5 -0
- label_studio_sdk/ml/types/ml_update_response.py +78 -0
- label_studio_sdk/ml/types/ml_update_response_auth_method.py +5 -0
- label_studio_sdk/predictions/__init__.py +2 -0
- label_studio_sdk/predictions/client.py +638 -0
- label_studio_sdk/projects/__init__.py +6 -0
- label_studio_sdk/projects/client.py +1053 -0
- label_studio_sdk/projects/exports/__init__.py +2 -0
- label_studio_sdk/projects/exports/client.py +930 -0
- label_studio_sdk/projects/types/__init__.py +7 -0
- label_studio_sdk/projects/types/projects_create_response.py +96 -0
- label_studio_sdk/projects/types/projects_import_tasks_response.py +71 -0
- label_studio_sdk/projects/types/projects_list_response.py +33 -0
- label_studio_sdk/py.typed +0 -0
- label_studio_sdk/tasks/__init__.py +5 -0
- label_studio_sdk/tasks/client.py +811 -0
- label_studio_sdk/tasks/types/__init__.py +6 -0
- label_studio_sdk/tasks/types/tasks_list_request_fields.py +5 -0
- label_studio_sdk/tasks/types/tasks_list_response.py +48 -0
- label_studio_sdk/types/__init__.py +115 -0
- label_studio_sdk/types/annotation.py +116 -0
- label_studio_sdk/types/annotation_filter_options.py +42 -0
- label_studio_sdk/types/annotation_last_action.py +19 -0
- label_studio_sdk/types/azure_blob_export_storage.py +112 -0
- label_studio_sdk/types/azure_blob_export_storage_status.py +7 -0
- label_studio_sdk/types/azure_blob_import_storage.py +113 -0
- label_studio_sdk/types/azure_blob_import_storage_status.py +7 -0
- label_studio_sdk/types/base_task.py +113 -0
- label_studio_sdk/types/base_user.py +42 -0
- label_studio_sdk/types/converted_format.py +36 -0
- label_studio_sdk/types/converted_format_status.py +5 -0
- label_studio_sdk/types/export.py +48 -0
- label_studio_sdk/types/export_convert.py +32 -0
- label_studio_sdk/types/export_create.py +54 -0
- label_studio_sdk/types/export_create_status.py +5 -0
- label_studio_sdk/types/export_status.py +5 -0
- label_studio_sdk/types/file_upload.py +30 -0
- label_studio_sdk/types/filter.py +53 -0
- label_studio_sdk/types/filter_group.py +35 -0
- label_studio_sdk/types/gcs_export_storage.py +112 -0
- label_studio_sdk/types/gcs_export_storage_status.py +7 -0
- label_studio_sdk/types/gcs_import_storage.py +113 -0
- label_studio_sdk/types/gcs_import_storage_status.py +7 -0
- label_studio_sdk/types/local_files_export_storage.py +97 -0
- label_studio_sdk/types/local_files_export_storage_status.py +7 -0
- label_studio_sdk/types/local_files_import_storage.py +92 -0
- label_studio_sdk/types/local_files_import_storage_status.py +7 -0
- label_studio_sdk/types/ml_backend.py +89 -0
- label_studio_sdk/types/ml_backend_auth_method.py +5 -0
- label_studio_sdk/types/ml_backend_state.py +5 -0
- label_studio_sdk/types/prediction.py +78 -0
- label_studio_sdk/types/project.py +198 -0
- label_studio_sdk/types/project_import.py +63 -0
- label_studio_sdk/types/project_import_status.py +5 -0
- label_studio_sdk/types/project_label_config.py +32 -0
- label_studio_sdk/types/project_sampling.py +7 -0
- label_studio_sdk/types/project_skip_queue.py +5 -0
- label_studio_sdk/types/redis_export_storage.py +117 -0
- label_studio_sdk/types/redis_export_storage_status.py +7 -0
- label_studio_sdk/types/redis_import_storage.py +112 -0
- label_studio_sdk/types/redis_import_storage_status.py +7 -0
- label_studio_sdk/types/s3export_storage.py +134 -0
- label_studio_sdk/types/s3export_storage_status.py +7 -0
- label_studio_sdk/types/s3import_storage.py +140 -0
- label_studio_sdk/types/s3import_storage_status.py +7 -0
- label_studio_sdk/types/serialization_option.py +36 -0
- label_studio_sdk/types/serialization_options.py +45 -0
- label_studio_sdk/types/task.py +157 -0
- label_studio_sdk/types/task_filter_options.py +49 -0
- label_studio_sdk/types/user_simple.py +37 -0
- label_studio_sdk/types/view.py +55 -0
- label_studio_sdk/types/webhook.py +67 -0
- label_studio_sdk/types/webhook_actions_item.py +21 -0
- label_studio_sdk/types/webhook_serializer_for_update.py +67 -0
- label_studio_sdk/types/webhook_serializer_for_update_actions_item.py +21 -0
- label_studio_sdk/users/__init__.py +5 -0
- label_studio_sdk/users/client.py +830 -0
- label_studio_sdk/users/types/__init__.py +6 -0
- label_studio_sdk/users/types/users_get_token_response.py +36 -0
- label_studio_sdk/users/types/users_reset_token_response.py +36 -0
- label_studio_sdk/version.py +4 -0
- label_studio_sdk/views/__init__.py +31 -0
- label_studio_sdk/views/client.py +564 -0
- label_studio_sdk/views/types/__init__.py +29 -0
- label_studio_sdk/views/types/views_create_request_data.py +43 -0
- label_studio_sdk/views/types/views_create_request_data_filters.py +43 -0
- label_studio_sdk/views/types/views_create_request_data_filters_conjunction.py +5 -0
- label_studio_sdk/views/types/views_create_request_data_filters_items_item.py +47 -0
- label_studio_sdk/views/types/views_create_request_data_ordering_item.py +38 -0
- label_studio_sdk/views/types/views_create_request_data_ordering_item_direction.py +5 -0
- label_studio_sdk/views/types/views_update_request_data.py +43 -0
- label_studio_sdk/views/types/views_update_request_data_filters.py +43 -0
- label_studio_sdk/views/types/views_update_request_data_filters_conjunction.py +5 -0
- label_studio_sdk/views/types/views_update_request_data_filters_items_item.py +47 -0
- label_studio_sdk/views/types/views_update_request_data_ordering_item.py +38 -0
- label_studio_sdk/views/types/views_update_request_data_ordering_item_direction.py +5 -0
- label_studio_sdk/webhooks/__init__.py +5 -0
- label_studio_sdk/webhooks/client.py +636 -0
- label_studio_sdk/webhooks/types/__init__.py +5 -0
- label_studio_sdk/webhooks/types/webhooks_update_request_actions_item.py +21 -0
- label_studio_sdk-1.0.0.dist-info/METADATA +307 -0
- label_studio_sdk-1.0.0.dist-info/RECORD +239 -0
- {label_studio_sdk-0.0.32.dist-info → label_studio_sdk-1.0.0.dist-info}/WHEEL +1 -2
- docs/__init__.py +0 -3
- label_studio_sdk-0.0.32.dist-info/LICENSE +0 -201
- label_studio_sdk-0.0.32.dist-info/METADATA +0 -22
- label_studio_sdk-0.0.32.dist-info/RECORD +0 -15
- label_studio_sdk-0.0.32.dist-info/top_level.txt +0 -3
- tests/test_client.py +0 -26
- {tests → label_studio_sdk/_extensions}/__init__.py +0 -0
|
@@ -0,0 +1,638 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
from json.decoder import JSONDecodeError
|
|
5
|
+
|
|
6
|
+
from ..core.api_error import ApiError
|
|
7
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
8
|
+
from ..core.jsonable_encoder import jsonable_encoder
|
|
9
|
+
from ..core.pydantic_utilities import pydantic_v1
|
|
10
|
+
from ..core.request_options import RequestOptions
|
|
11
|
+
from ..types.prediction import Prediction
|
|
12
|
+
|
|
13
|
+
# this is used as the default value for optional parameters
|
|
14
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class PredictionsClient:
|
|
18
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
19
|
+
self._client_wrapper = client_wrapper
|
|
20
|
+
|
|
21
|
+
def list(
|
|
22
|
+
self,
|
|
23
|
+
*,
|
|
24
|
+
task: typing.Optional[int] = None,
|
|
25
|
+
project: typing.Optional[int] = None,
|
|
26
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
27
|
+
) -> typing.List[Prediction]:
|
|
28
|
+
"""
|
|
29
|
+
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
|
+
<Note>The terms "predictions" and pre-annotations" are used interchangeably.</Note>
|
|
32
|
+
|
|
33
|
+
Predictions can be [imported directly into Label Studio](https://labelstud.io/guide/predictions) or [generated by a connected ML backend](https://labelstud.io/guide/ml.html#Pre-annotations-predictions).
|
|
34
|
+
|
|
35
|
+
To import predictions via the API, see [Create prediction](create).
|
|
36
|
+
|
|
37
|
+
Parameters
|
|
38
|
+
----------
|
|
39
|
+
task : typing.Optional[int]
|
|
40
|
+
Filter predictions by task ID
|
|
41
|
+
|
|
42
|
+
project : typing.Optional[int]
|
|
43
|
+
Filter predictions by project ID
|
|
44
|
+
|
|
45
|
+
request_options : typing.Optional[RequestOptions]
|
|
46
|
+
Request-specific configuration.
|
|
47
|
+
|
|
48
|
+
Returns
|
|
49
|
+
-------
|
|
50
|
+
typing.List[Prediction]
|
|
51
|
+
Predictions list
|
|
52
|
+
|
|
53
|
+
Examples
|
|
54
|
+
--------
|
|
55
|
+
from label_studio_sdk.client import LabelStudio
|
|
56
|
+
|
|
57
|
+
client = LabelStudio(
|
|
58
|
+
api_key="YOUR_API_KEY",
|
|
59
|
+
)
|
|
60
|
+
client.predictions.list()
|
|
61
|
+
"""
|
|
62
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
63
|
+
"api/predictions/", method="GET", params={"task": task, "project": project}, request_options=request_options
|
|
64
|
+
)
|
|
65
|
+
if 200 <= _response.status_code < 300:
|
|
66
|
+
return pydantic_v1.parse_obj_as(typing.List[Prediction], _response.json()) # type: ignore
|
|
67
|
+
try:
|
|
68
|
+
_response_json = _response.json()
|
|
69
|
+
except JSONDecodeError:
|
|
70
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
71
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
72
|
+
|
|
73
|
+
def create(
|
|
74
|
+
self,
|
|
75
|
+
*,
|
|
76
|
+
task: typing.Optional[int] = OMIT,
|
|
77
|
+
result: typing.Optional[typing.Sequence[typing.Dict[str, typing.Any]]] = OMIT,
|
|
78
|
+
score: typing.Optional[float] = OMIT,
|
|
79
|
+
model_version: typing.Optional[str] = OMIT,
|
|
80
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
81
|
+
) -> Prediction:
|
|
82
|
+
"""
|
|
83
|
+
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
|
+
|
|
85
|
+
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
|
+
|
|
87
|
+
#### JSON format for predictions
|
|
88
|
+
|
|
89
|
+
Label Studio JSON format for pre-annotations must contain two sections:
|
|
90
|
+
|
|
91
|
+
- 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.
|
|
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.
|
|
93
|
+
|
|
94
|
+
For more information, see [the JSON format reference in the Label Studio documentation](https://labelstud.io/guide/predictions#JSON-format-for-pre-annotations)
|
|
95
|
+
|
|
96
|
+
Parameters
|
|
97
|
+
----------
|
|
98
|
+
task : typing.Optional[int]
|
|
99
|
+
Task ID for which the prediction is created
|
|
100
|
+
|
|
101
|
+
result : typing.Optional[typing.Sequence[typing.Dict[str, typing.Any]]]
|
|
102
|
+
Prediction result in JSON format. Read more about the format in [the Label Studio documentation.](https://labelstud.io/guide/predictions)
|
|
103
|
+
|
|
104
|
+
score : typing.Optional[float]
|
|
105
|
+
Prediction score. Can be used in Data Manager to sort task by model confidence. Task with the lowest score will be shown first.
|
|
106
|
+
|
|
107
|
+
model_version : typing.Optional[str]
|
|
108
|
+
Model version - tag for predictions that can be used to filter tasks in Data Manager, as well as select specific model version for showing preannotations in the labeling interface
|
|
109
|
+
|
|
110
|
+
request_options : typing.Optional[RequestOptions]
|
|
111
|
+
Request-specific configuration.
|
|
112
|
+
|
|
113
|
+
Returns
|
|
114
|
+
-------
|
|
115
|
+
Prediction
|
|
116
|
+
Created prediction
|
|
117
|
+
|
|
118
|
+
Examples
|
|
119
|
+
--------
|
|
120
|
+
from label_studio_sdk.client import LabelStudio
|
|
121
|
+
|
|
122
|
+
client = LabelStudio(
|
|
123
|
+
api_key="YOUR_API_KEY",
|
|
124
|
+
)
|
|
125
|
+
client.predictions.create(
|
|
126
|
+
result=[
|
|
127
|
+
{
|
|
128
|
+
"original_width": 1920,
|
|
129
|
+
"original_height": 1080,
|
|
130
|
+
"image_rotation": 0,
|
|
131
|
+
"from_name": "bboxes",
|
|
132
|
+
"to_name": "image",
|
|
133
|
+
"type": "rectanglelabels",
|
|
134
|
+
"value": {
|
|
135
|
+
"x": 20,
|
|
136
|
+
"y": 30,
|
|
137
|
+
"width": 50,
|
|
138
|
+
"height": 60,
|
|
139
|
+
"rotation": 0,
|
|
140
|
+
"values": {"rectanglelabels": {"0": "Person"}},
|
|
141
|
+
},
|
|
142
|
+
}
|
|
143
|
+
],
|
|
144
|
+
score=0.95,
|
|
145
|
+
model_version="yolo-v8",
|
|
146
|
+
)
|
|
147
|
+
"""
|
|
148
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
149
|
+
"api/predictions/",
|
|
150
|
+
method="POST",
|
|
151
|
+
json={"task": task, "result": result, "score": score, "model_version": model_version},
|
|
152
|
+
request_options=request_options,
|
|
153
|
+
omit=OMIT,
|
|
154
|
+
)
|
|
155
|
+
if 200 <= _response.status_code < 300:
|
|
156
|
+
return pydantic_v1.parse_obj_as(Prediction, _response.json()) # type: ignore
|
|
157
|
+
try:
|
|
158
|
+
_response_json = _response.json()
|
|
159
|
+
except JSONDecodeError:
|
|
160
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
161
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
162
|
+
|
|
163
|
+
def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> Prediction:
|
|
164
|
+
"""
|
|
165
|
+
Get details about a specific prediction by its ID. To find the prediction ID, use [List predictions](list).
|
|
166
|
+
|
|
167
|
+
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).
|
|
168
|
+
|
|
169
|
+
Parameters
|
|
170
|
+
----------
|
|
171
|
+
id : int
|
|
172
|
+
Prediction ID
|
|
173
|
+
|
|
174
|
+
request_options : typing.Optional[RequestOptions]
|
|
175
|
+
Request-specific configuration.
|
|
176
|
+
|
|
177
|
+
Returns
|
|
178
|
+
-------
|
|
179
|
+
Prediction
|
|
180
|
+
Prediction details
|
|
181
|
+
|
|
182
|
+
Examples
|
|
183
|
+
--------
|
|
184
|
+
from label_studio_sdk.client import LabelStudio
|
|
185
|
+
|
|
186
|
+
client = LabelStudio(
|
|
187
|
+
api_key="YOUR_API_KEY",
|
|
188
|
+
)
|
|
189
|
+
client.predictions.get(
|
|
190
|
+
id=1,
|
|
191
|
+
)
|
|
192
|
+
"""
|
|
193
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
194
|
+
f"api/predictions/{jsonable_encoder(id)}/", method="GET", request_options=request_options
|
|
195
|
+
)
|
|
196
|
+
if 200 <= _response.status_code < 300:
|
|
197
|
+
return pydantic_v1.parse_obj_as(Prediction, _response.json()) # type: ignore
|
|
198
|
+
try:
|
|
199
|
+
_response_json = _response.json()
|
|
200
|
+
except JSONDecodeError:
|
|
201
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
202
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
203
|
+
|
|
204
|
+
def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
205
|
+
"""
|
|
206
|
+
Delete a prediction. To find the prediction ID, use [List predictions](list).
|
|
207
|
+
|
|
208
|
+
Parameters
|
|
209
|
+
----------
|
|
210
|
+
id : int
|
|
211
|
+
Prediction ID
|
|
212
|
+
|
|
213
|
+
request_options : typing.Optional[RequestOptions]
|
|
214
|
+
Request-specific configuration.
|
|
215
|
+
|
|
216
|
+
Returns
|
|
217
|
+
-------
|
|
218
|
+
None
|
|
219
|
+
|
|
220
|
+
Examples
|
|
221
|
+
--------
|
|
222
|
+
from label_studio_sdk.client import LabelStudio
|
|
223
|
+
|
|
224
|
+
client = LabelStudio(
|
|
225
|
+
api_key="YOUR_API_KEY",
|
|
226
|
+
)
|
|
227
|
+
client.predictions.delete(
|
|
228
|
+
id=1,
|
|
229
|
+
)
|
|
230
|
+
"""
|
|
231
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
232
|
+
f"api/predictions/{jsonable_encoder(id)}/", method="DELETE", request_options=request_options
|
|
233
|
+
)
|
|
234
|
+
if 200 <= _response.status_code < 300:
|
|
235
|
+
return
|
|
236
|
+
try:
|
|
237
|
+
_response_json = _response.json()
|
|
238
|
+
except JSONDecodeError:
|
|
239
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
240
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
241
|
+
|
|
242
|
+
def update(
|
|
243
|
+
self,
|
|
244
|
+
id: int,
|
|
245
|
+
*,
|
|
246
|
+
task: typing.Optional[int] = OMIT,
|
|
247
|
+
result: typing.Optional[typing.Sequence[typing.Dict[str, typing.Any]]] = OMIT,
|
|
248
|
+
score: typing.Optional[float] = OMIT,
|
|
249
|
+
model_version: typing.Optional[str] = OMIT,
|
|
250
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
251
|
+
) -> Prediction:
|
|
252
|
+
"""
|
|
253
|
+
Update a prediction. To find the prediction ID, use [List predictions](list).
|
|
254
|
+
|
|
255
|
+
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).
|
|
256
|
+
|
|
257
|
+
Parameters
|
|
258
|
+
----------
|
|
259
|
+
id : int
|
|
260
|
+
Prediction ID
|
|
261
|
+
|
|
262
|
+
task : typing.Optional[int]
|
|
263
|
+
Task ID for which the prediction is created
|
|
264
|
+
|
|
265
|
+
result : typing.Optional[typing.Sequence[typing.Dict[str, typing.Any]]]
|
|
266
|
+
Prediction result in JSON format. Read more about the format in [the Label Studio documentation.](https://labelstud.io/guide/predictions)
|
|
267
|
+
|
|
268
|
+
score : typing.Optional[float]
|
|
269
|
+
Prediction score. Can be used in Data Manager to sort task by model confidence. Task with the lowest score will be shown first.
|
|
270
|
+
|
|
271
|
+
model_version : typing.Optional[str]
|
|
272
|
+
Model version - tag for predictions that can be used to filter tasks in Data Manager, as well as select specific model version for showing preannotations in the labeling interface
|
|
273
|
+
|
|
274
|
+
request_options : typing.Optional[RequestOptions]
|
|
275
|
+
Request-specific configuration.
|
|
276
|
+
|
|
277
|
+
Returns
|
|
278
|
+
-------
|
|
279
|
+
Prediction
|
|
280
|
+
Updated prediction
|
|
281
|
+
|
|
282
|
+
Examples
|
|
283
|
+
--------
|
|
284
|
+
from label_studio_sdk.client import LabelStudio
|
|
285
|
+
|
|
286
|
+
client = LabelStudio(
|
|
287
|
+
api_key="YOUR_API_KEY",
|
|
288
|
+
)
|
|
289
|
+
client.predictions.update(
|
|
290
|
+
id=1,
|
|
291
|
+
result=[
|
|
292
|
+
{
|
|
293
|
+
"original_width": 1920,
|
|
294
|
+
"original_height": 1080,
|
|
295
|
+
"image_rotation": 0,
|
|
296
|
+
"from_name": "bboxes",
|
|
297
|
+
"to_name": "image",
|
|
298
|
+
"type": "rectanglelabels",
|
|
299
|
+
"value": {
|
|
300
|
+
"x": 20,
|
|
301
|
+
"y": 30,
|
|
302
|
+
"width": 50,
|
|
303
|
+
"height": 60,
|
|
304
|
+
"rotation": 0,
|
|
305
|
+
"values": {"rectanglelabels": {"0": "Person"}},
|
|
306
|
+
},
|
|
307
|
+
}
|
|
308
|
+
],
|
|
309
|
+
score=0.95,
|
|
310
|
+
model_version="yolo-v8",
|
|
311
|
+
)
|
|
312
|
+
"""
|
|
313
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
314
|
+
f"api/predictions/{jsonable_encoder(id)}/",
|
|
315
|
+
method="PATCH",
|
|
316
|
+
json={"task": task, "result": result, "score": score, "model_version": model_version},
|
|
317
|
+
request_options=request_options,
|
|
318
|
+
omit=OMIT,
|
|
319
|
+
)
|
|
320
|
+
if 200 <= _response.status_code < 300:
|
|
321
|
+
return pydantic_v1.parse_obj_as(Prediction, _response.json()) # type: ignore
|
|
322
|
+
try:
|
|
323
|
+
_response_json = _response.json()
|
|
324
|
+
except JSONDecodeError:
|
|
325
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
326
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
class AsyncPredictionsClient:
|
|
330
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
331
|
+
self._client_wrapper = client_wrapper
|
|
332
|
+
|
|
333
|
+
async def list(
|
|
334
|
+
self,
|
|
335
|
+
*,
|
|
336
|
+
task: typing.Optional[int] = None,
|
|
337
|
+
project: typing.Optional[int] = None,
|
|
338
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
339
|
+
) -> typing.List[Prediction]:
|
|
340
|
+
"""
|
|
341
|
+
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
|
+
|
|
343
|
+
<Note>The terms "predictions" and pre-annotations" are used interchangeably.</Note>
|
|
344
|
+
|
|
345
|
+
Predictions can be [imported directly into Label Studio](https://labelstud.io/guide/predictions) or [generated by a connected ML backend](https://labelstud.io/guide/ml.html#Pre-annotations-predictions).
|
|
346
|
+
|
|
347
|
+
To import predictions via the API, see [Create prediction](create).
|
|
348
|
+
|
|
349
|
+
Parameters
|
|
350
|
+
----------
|
|
351
|
+
task : typing.Optional[int]
|
|
352
|
+
Filter predictions by task ID
|
|
353
|
+
|
|
354
|
+
project : typing.Optional[int]
|
|
355
|
+
Filter predictions by project ID
|
|
356
|
+
|
|
357
|
+
request_options : typing.Optional[RequestOptions]
|
|
358
|
+
Request-specific configuration.
|
|
359
|
+
|
|
360
|
+
Returns
|
|
361
|
+
-------
|
|
362
|
+
typing.List[Prediction]
|
|
363
|
+
Predictions list
|
|
364
|
+
|
|
365
|
+
Examples
|
|
366
|
+
--------
|
|
367
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
368
|
+
|
|
369
|
+
client = AsyncLabelStudio(
|
|
370
|
+
api_key="YOUR_API_KEY",
|
|
371
|
+
)
|
|
372
|
+
await client.predictions.list()
|
|
373
|
+
"""
|
|
374
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
375
|
+
"api/predictions/", method="GET", params={"task": task, "project": project}, request_options=request_options
|
|
376
|
+
)
|
|
377
|
+
if 200 <= _response.status_code < 300:
|
|
378
|
+
return pydantic_v1.parse_obj_as(typing.List[Prediction], _response.json()) # type: ignore
|
|
379
|
+
try:
|
|
380
|
+
_response_json = _response.json()
|
|
381
|
+
except JSONDecodeError:
|
|
382
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
383
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
384
|
+
|
|
385
|
+
async def create(
|
|
386
|
+
self,
|
|
387
|
+
*,
|
|
388
|
+
task: typing.Optional[int] = OMIT,
|
|
389
|
+
result: typing.Optional[typing.Sequence[typing.Dict[str, typing.Any]]] = OMIT,
|
|
390
|
+
score: typing.Optional[float] = OMIT,
|
|
391
|
+
model_version: typing.Optional[str] = OMIT,
|
|
392
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
393
|
+
) -> Prediction:
|
|
394
|
+
"""
|
|
395
|
+
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
|
+
|
|
397
|
+
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
|
+
|
|
399
|
+
#### JSON format for predictions
|
|
400
|
+
|
|
401
|
+
Label Studio JSON format for pre-annotations must contain two sections:
|
|
402
|
+
|
|
403
|
+
- 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.
|
|
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.
|
|
405
|
+
|
|
406
|
+
For more information, see [the JSON format reference in the Label Studio documentation](https://labelstud.io/guide/predictions#JSON-format-for-pre-annotations)
|
|
407
|
+
|
|
408
|
+
Parameters
|
|
409
|
+
----------
|
|
410
|
+
task : typing.Optional[int]
|
|
411
|
+
Task ID for which the prediction is created
|
|
412
|
+
|
|
413
|
+
result : typing.Optional[typing.Sequence[typing.Dict[str, typing.Any]]]
|
|
414
|
+
Prediction result in JSON format. Read more about the format in [the Label Studio documentation.](https://labelstud.io/guide/predictions)
|
|
415
|
+
|
|
416
|
+
score : typing.Optional[float]
|
|
417
|
+
Prediction score. Can be used in Data Manager to sort task by model confidence. Task with the lowest score will be shown first.
|
|
418
|
+
|
|
419
|
+
model_version : typing.Optional[str]
|
|
420
|
+
Model version - tag for predictions that can be used to filter tasks in Data Manager, as well as select specific model version for showing preannotations in the labeling interface
|
|
421
|
+
|
|
422
|
+
request_options : typing.Optional[RequestOptions]
|
|
423
|
+
Request-specific configuration.
|
|
424
|
+
|
|
425
|
+
Returns
|
|
426
|
+
-------
|
|
427
|
+
Prediction
|
|
428
|
+
Created prediction
|
|
429
|
+
|
|
430
|
+
Examples
|
|
431
|
+
--------
|
|
432
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
433
|
+
|
|
434
|
+
client = AsyncLabelStudio(
|
|
435
|
+
api_key="YOUR_API_KEY",
|
|
436
|
+
)
|
|
437
|
+
await client.predictions.create(
|
|
438
|
+
result=[
|
|
439
|
+
{
|
|
440
|
+
"original_width": 1920,
|
|
441
|
+
"original_height": 1080,
|
|
442
|
+
"image_rotation": 0,
|
|
443
|
+
"from_name": "bboxes",
|
|
444
|
+
"to_name": "image",
|
|
445
|
+
"type": "rectanglelabels",
|
|
446
|
+
"value": {
|
|
447
|
+
"x": 20,
|
|
448
|
+
"y": 30,
|
|
449
|
+
"width": 50,
|
|
450
|
+
"height": 60,
|
|
451
|
+
"rotation": 0,
|
|
452
|
+
"values": {"rectanglelabels": {"0": "Person"}},
|
|
453
|
+
},
|
|
454
|
+
}
|
|
455
|
+
],
|
|
456
|
+
score=0.95,
|
|
457
|
+
model_version="yolo-v8",
|
|
458
|
+
)
|
|
459
|
+
"""
|
|
460
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
461
|
+
"api/predictions/",
|
|
462
|
+
method="POST",
|
|
463
|
+
json={"task": task, "result": result, "score": score, "model_version": model_version},
|
|
464
|
+
request_options=request_options,
|
|
465
|
+
omit=OMIT,
|
|
466
|
+
)
|
|
467
|
+
if 200 <= _response.status_code < 300:
|
|
468
|
+
return pydantic_v1.parse_obj_as(Prediction, _response.json()) # type: ignore
|
|
469
|
+
try:
|
|
470
|
+
_response_json = _response.json()
|
|
471
|
+
except JSONDecodeError:
|
|
472
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
473
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
474
|
+
|
|
475
|
+
async def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> Prediction:
|
|
476
|
+
"""
|
|
477
|
+
Get details about a specific prediction by its ID. To find the prediction ID, use [List predictions](list).
|
|
478
|
+
|
|
479
|
+
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).
|
|
480
|
+
|
|
481
|
+
Parameters
|
|
482
|
+
----------
|
|
483
|
+
id : int
|
|
484
|
+
Prediction ID
|
|
485
|
+
|
|
486
|
+
request_options : typing.Optional[RequestOptions]
|
|
487
|
+
Request-specific configuration.
|
|
488
|
+
|
|
489
|
+
Returns
|
|
490
|
+
-------
|
|
491
|
+
Prediction
|
|
492
|
+
Prediction details
|
|
493
|
+
|
|
494
|
+
Examples
|
|
495
|
+
--------
|
|
496
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
497
|
+
|
|
498
|
+
client = AsyncLabelStudio(
|
|
499
|
+
api_key="YOUR_API_KEY",
|
|
500
|
+
)
|
|
501
|
+
await client.predictions.get(
|
|
502
|
+
id=1,
|
|
503
|
+
)
|
|
504
|
+
"""
|
|
505
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
506
|
+
f"api/predictions/{jsonable_encoder(id)}/", method="GET", request_options=request_options
|
|
507
|
+
)
|
|
508
|
+
if 200 <= _response.status_code < 300:
|
|
509
|
+
return pydantic_v1.parse_obj_as(Prediction, _response.json()) # type: ignore
|
|
510
|
+
try:
|
|
511
|
+
_response_json = _response.json()
|
|
512
|
+
except JSONDecodeError:
|
|
513
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
514
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
515
|
+
|
|
516
|
+
async def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
517
|
+
"""
|
|
518
|
+
Delete a prediction. To find the prediction ID, use [List predictions](list).
|
|
519
|
+
|
|
520
|
+
Parameters
|
|
521
|
+
----------
|
|
522
|
+
id : int
|
|
523
|
+
Prediction ID
|
|
524
|
+
|
|
525
|
+
request_options : typing.Optional[RequestOptions]
|
|
526
|
+
Request-specific configuration.
|
|
527
|
+
|
|
528
|
+
Returns
|
|
529
|
+
-------
|
|
530
|
+
None
|
|
531
|
+
|
|
532
|
+
Examples
|
|
533
|
+
--------
|
|
534
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
535
|
+
|
|
536
|
+
client = AsyncLabelStudio(
|
|
537
|
+
api_key="YOUR_API_KEY",
|
|
538
|
+
)
|
|
539
|
+
await client.predictions.delete(
|
|
540
|
+
id=1,
|
|
541
|
+
)
|
|
542
|
+
"""
|
|
543
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
544
|
+
f"api/predictions/{jsonable_encoder(id)}/", method="DELETE", request_options=request_options
|
|
545
|
+
)
|
|
546
|
+
if 200 <= _response.status_code < 300:
|
|
547
|
+
return
|
|
548
|
+
try:
|
|
549
|
+
_response_json = _response.json()
|
|
550
|
+
except JSONDecodeError:
|
|
551
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
552
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
553
|
+
|
|
554
|
+
async def update(
|
|
555
|
+
self,
|
|
556
|
+
id: int,
|
|
557
|
+
*,
|
|
558
|
+
task: typing.Optional[int] = OMIT,
|
|
559
|
+
result: typing.Optional[typing.Sequence[typing.Dict[str, typing.Any]]] = OMIT,
|
|
560
|
+
score: typing.Optional[float] = OMIT,
|
|
561
|
+
model_version: typing.Optional[str] = OMIT,
|
|
562
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
563
|
+
) -> Prediction:
|
|
564
|
+
"""
|
|
565
|
+
Update a prediction. To find the prediction ID, use [List predictions](list).
|
|
566
|
+
|
|
567
|
+
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).
|
|
568
|
+
|
|
569
|
+
Parameters
|
|
570
|
+
----------
|
|
571
|
+
id : int
|
|
572
|
+
Prediction ID
|
|
573
|
+
|
|
574
|
+
task : typing.Optional[int]
|
|
575
|
+
Task ID for which the prediction is created
|
|
576
|
+
|
|
577
|
+
result : typing.Optional[typing.Sequence[typing.Dict[str, typing.Any]]]
|
|
578
|
+
Prediction result in JSON format. Read more about the format in [the Label Studio documentation.](https://labelstud.io/guide/predictions)
|
|
579
|
+
|
|
580
|
+
score : typing.Optional[float]
|
|
581
|
+
Prediction score. Can be used in Data Manager to sort task by model confidence. Task with the lowest score will be shown first.
|
|
582
|
+
|
|
583
|
+
model_version : typing.Optional[str]
|
|
584
|
+
Model version - tag for predictions that can be used to filter tasks in Data Manager, as well as select specific model version for showing preannotations in the labeling interface
|
|
585
|
+
|
|
586
|
+
request_options : typing.Optional[RequestOptions]
|
|
587
|
+
Request-specific configuration.
|
|
588
|
+
|
|
589
|
+
Returns
|
|
590
|
+
-------
|
|
591
|
+
Prediction
|
|
592
|
+
Updated prediction
|
|
593
|
+
|
|
594
|
+
Examples
|
|
595
|
+
--------
|
|
596
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
597
|
+
|
|
598
|
+
client = AsyncLabelStudio(
|
|
599
|
+
api_key="YOUR_API_KEY",
|
|
600
|
+
)
|
|
601
|
+
await client.predictions.update(
|
|
602
|
+
id=1,
|
|
603
|
+
result=[
|
|
604
|
+
{
|
|
605
|
+
"original_width": 1920,
|
|
606
|
+
"original_height": 1080,
|
|
607
|
+
"image_rotation": 0,
|
|
608
|
+
"from_name": "bboxes",
|
|
609
|
+
"to_name": "image",
|
|
610
|
+
"type": "rectanglelabels",
|
|
611
|
+
"value": {
|
|
612
|
+
"x": 20,
|
|
613
|
+
"y": 30,
|
|
614
|
+
"width": 50,
|
|
615
|
+
"height": 60,
|
|
616
|
+
"rotation": 0,
|
|
617
|
+
"values": {"rectanglelabels": {"0": "Person"}},
|
|
618
|
+
},
|
|
619
|
+
}
|
|
620
|
+
],
|
|
621
|
+
score=0.95,
|
|
622
|
+
model_version="yolo-v8",
|
|
623
|
+
)
|
|
624
|
+
"""
|
|
625
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
626
|
+
f"api/predictions/{jsonable_encoder(id)}/",
|
|
627
|
+
method="PATCH",
|
|
628
|
+
json={"task": task, "result": result, "score": score, "model_version": model_version},
|
|
629
|
+
request_options=request_options,
|
|
630
|
+
omit=OMIT,
|
|
631
|
+
)
|
|
632
|
+
if 200 <= _response.status_code < 300:
|
|
633
|
+
return pydantic_v1.parse_obj_as(Prediction, _response.json()) # type: ignore
|
|
634
|
+
try:
|
|
635
|
+
_response_json = _response.json()
|
|
636
|
+
except JSONDecodeError:
|
|
637
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
638
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
from .types import ProjectsCreateResponse, ProjectsImportTasksResponse, ProjectsListResponse
|
|
4
|
+
from . import exports
|
|
5
|
+
|
|
6
|
+
__all__ = ["ProjectsCreateResponse", "ProjectsImportTasksResponse", "ProjectsListResponse", "exports"]
|