dragoneye-python 0.5.1__tar.gz → 1.0.1__tar.gz
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.
- dragoneye_python-1.0.1/LICENSE +21 -0
- dragoneye_python-1.0.1/PKG-INFO +505 -0
- dragoneye_python-1.0.1/README.md +471 -0
- dragoneye_python-1.0.1/dragoneye_python.egg-info/PKG-INFO +505 -0
- {dragoneye_python-0.5.1 → dragoneye_python-1.0.1}/dragoneye_python.egg-info/SOURCES.txt +2 -0
- dragoneye_python-0.5.1/requirements.txt → dragoneye_python-1.0.1/dragoneye_python.egg-info/requires.txt +2 -1
- dragoneye_python-1.0.1/pyproject.toml +47 -0
- dragoneye_python-0.5.1/dragoneye_python.egg-info/requires.txt → dragoneye_python-1.0.1/requirements.txt +1 -0
- {dragoneye_python-0.5.1 → dragoneye_python-1.0.1}/src/dragoneye/__init__.py +12 -0
- {dragoneye_python-0.5.1 → dragoneye_python-1.0.1}/src/dragoneye/classification.py +56 -15
- dragoneye_python-1.0.1/src/dragoneye/parquet_deserializer.py +136 -0
- dragoneye_python-0.5.1/PKG-INFO +0 -10
- dragoneye_python-0.5.1/README.md +0 -1
- dragoneye_python-0.5.1/dragoneye_python.egg-info/PKG-INFO +0 -10
- dragoneye_python-0.5.1/pyproject.toml +0 -16
- {dragoneye_python-0.5.1 → dragoneye_python-1.0.1}/dragoneye_python.egg-info/dependency_links.txt +0 -0
- {dragoneye_python-0.5.1 → dragoneye_python-1.0.1}/dragoneye_python.egg-info/top_level.txt +0 -0
- {dragoneye_python-0.5.1 → dragoneye_python-1.0.1}/setup.cfg +0 -0
- {dragoneye_python-0.5.1 → dragoneye_python-1.0.1}/src/dragoneye/client.py +0 -0
- {dragoneye_python-0.5.1 → dragoneye_python-1.0.1}/src/dragoneye/constants.py +0 -0
- {dragoneye_python-0.5.1 → dragoneye_python-1.0.1}/src/dragoneye/models.py +0 -0
- {dragoneye_python-0.5.1 → dragoneye_python-1.0.1}/src/dragoneye/types/__init__.py +0 -0
- {dragoneye_python-0.5.1 → dragoneye_python-1.0.1}/src/dragoneye/types/common.py +0 -0
- {dragoneye_python-0.5.1 → dragoneye_python-1.0.1}/src/dragoneye/types/exception.py +0 -0
- {dragoneye_python-0.5.1 → dragoneye_python-1.0.1}/src/dragoneye/types/media.py +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Dragoneye
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dragoneye-python
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: Official Python SDK for the Dragoneye computer vision API
|
|
5
|
+
Author-email: Dragoneye <support@dragoneye.ai>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://dragoneye.ai
|
|
8
|
+
Project-URL: Documentation, https://docs.dragoneye.ai/integrating/python-sdk
|
|
9
|
+
Project-URL: Repository, https://github.com/dragoneyeAI/dragoneye-python
|
|
10
|
+
Project-URL: Playground, https://playground.dragoneye.ai/
|
|
11
|
+
Project-URL: Issues, https://github.com/dragoneyeAI/dragoneye-python/issues
|
|
12
|
+
Keywords: dragoneye,computer-vision,image-classification,video-classification,machine-learning,ai
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Image Recognition
|
|
24
|
+
Requires-Python: >=3.8
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Requires-Dist: requests
|
|
28
|
+
Requires-Dist: pydantic>=2
|
|
29
|
+
Requires-Dist: typing-extensions>=4.0.0
|
|
30
|
+
Requires-Dist: backoff>=2.0.0
|
|
31
|
+
Requires-Dist: aiohttp
|
|
32
|
+
Requires-Dist: polars>=1.0.0
|
|
33
|
+
Dynamic: license-file
|
|
34
|
+
|
|
35
|
+
# dragoneye-python
|
|
36
|
+
|
|
37
|
+
[](https://pypi.org/project/dragoneye-python/)
|
|
38
|
+
[](https://pypi.org/project/dragoneye-python/)
|
|
39
|
+
[](https://github.com/dragoneyeAI/dragoneye-python/blob/main/LICENSE)
|
|
40
|
+
|
|
41
|
+
The official Python SDK for [Dragoneye](https://dragoneye.ai) — build and call custom computer vision models from Python.
|
|
42
|
+
|
|
43
|
+
Describe what you want to detect in plain English on the [Dragoneye Playground](https://playground.dragoneye.ai/), and the AI Model Builder assembles a vision model with your categories and attributes. This SDK lets you run that model on images and videos and get back structured predictions with bounding boxes, category scores, and attribute scores.
|
|
44
|
+
|
|
45
|
+
- 📘 **Full documentation:** https://docs.dragoneye.ai/integrating/python-sdk
|
|
46
|
+
- 🎮 **Playground:** https://playground.dragoneye.ai/
|
|
47
|
+
- 🐍 **PyPI:** https://pypi.org/project/dragoneye-python/
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Using the Python SDK
|
|
52
|
+
|
|
53
|
+
If you're integrating with our APIs using Python, the Dragoneye SDK streamlines the process with minimal setup. Here's how you can get started and explore the types and endpoints in detail.
|
|
54
|
+
|
|
55
|
+
## Installation
|
|
56
|
+
|
|
57
|
+
Install the package using pip.
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pip install dragoneye-python
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Quick Start
|
|
64
|
+
|
|
65
|
+
> **Tip — Prerequisites**: Don't have an API key yet? See [Creating an Access Token](https://docs.dragoneye.ai/account-management/creating-access-token).
|
|
66
|
+
|
|
67
|
+
To call the classifier, follow these steps:
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
import asyncio
|
|
71
|
+
from dragoneye import Dragoneye, Image, Video
|
|
72
|
+
|
|
73
|
+
async def main():
|
|
74
|
+
# The api_key can also be set via the DRAGONEYE_API_KEY environment variable.
|
|
75
|
+
client = Dragoneye(api_key="<YOUR_ACCESS_TOKEN>")
|
|
76
|
+
|
|
77
|
+
# Example: predict from an image
|
|
78
|
+
image = Image.from_path("photo.jpg")
|
|
79
|
+
image_result = await client.classification.predict_image(
|
|
80
|
+
media=image,
|
|
81
|
+
model_name="recognize_anything/your_model_name", # change to your desired model
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
# Example: predict from a video
|
|
85
|
+
# NOTE! When loading a file, you can optionally pass a file name or identifier
|
|
86
|
+
# that you use to identify your own files.
|
|
87
|
+
video = Video.from_path(
|
|
88
|
+
path="example.mp4",
|
|
89
|
+
name="any-file-name",
|
|
90
|
+
)
|
|
91
|
+
video_result = await client.classification.predict_video(
|
|
92
|
+
media=video,
|
|
93
|
+
model_name="recognize_anything/your_model_name",
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
# Accessing image results
|
|
97
|
+
for obj in image_result.object_predictions:
|
|
98
|
+
bbox = obj.normalizedBbox
|
|
99
|
+
for pred in obj.predictions:
|
|
100
|
+
print(f"Category: {pred.category.name} ({pred.category.score:.2f})")
|
|
101
|
+
for attr in pred.attributes:
|
|
102
|
+
top_option = max(attr.options, key=lambda o: o.score)
|
|
103
|
+
print(f" {attr.name}: {top_option.name} ({top_option.score:.2f})")
|
|
104
|
+
|
|
105
|
+
asyncio.run(main())
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
> **Note — Model names**: Model names follow the format `recognize_anything/model_name`. Use the name you specified when creating the model.
|
|
109
|
+
|
|
110
|
+
### Example Video Response
|
|
111
|
+
|
|
112
|
+
Below is an example of what a `ClassificationPredictVideoResponse` looks like for a Building Detection model. The response maps each sampled frame's timestamp (in microseconds) to the objects detected in that frame:
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
ClassificationPredictVideoResponse(
|
|
116
|
+
prediction_task_uuid="a1b2c3d4-e5f6-7890-abcd-ef1234567890",
|
|
117
|
+
original_file_name="any-file-name",
|
|
118
|
+
frames_per_second=1,
|
|
119
|
+
timestamp_us_to_predictions={
|
|
120
|
+
0: [
|
|
121
|
+
ClassificationVideoObjectPrediction(
|
|
122
|
+
frame_id="frame_0",
|
|
123
|
+
timestamp_microseconds=0,
|
|
124
|
+
normalizedBbox=(0.12, 0.25, 0.55, 0.78),
|
|
125
|
+
predictions=[
|
|
126
|
+
ClassificationCategoryPrediction(
|
|
127
|
+
category=ClassificationCategory(
|
|
128
|
+
id=2084323334,
|
|
129
|
+
name="House (detached)",
|
|
130
|
+
score=0.92,
|
|
131
|
+
),
|
|
132
|
+
attributes=[
|
|
133
|
+
ClassificationAttributeResponse(
|
|
134
|
+
attribute_id=1371766615,
|
|
135
|
+
name="Building Exterior Color",
|
|
136
|
+
options=[
|
|
137
|
+
ClassificationAttributeOption(option_id=3498033303, name="White / Off-white", score=0.85),
|
|
138
|
+
ClassificationAttributeOption(option_id=496739380, name="Light gray", score=0.10),
|
|
139
|
+
# ... remaining options omitted for brevity
|
|
140
|
+
],
|
|
141
|
+
),
|
|
142
|
+
ClassificationAttributeResponse(
|
|
143
|
+
attribute_id=448392115,
|
|
144
|
+
name="Building Exterior Material",
|
|
145
|
+
options=[
|
|
146
|
+
ClassificationAttributeOption(option_id=3887467550, name="Wood (incl. timber siding)", score=0.78),
|
|
147
|
+
ClassificationAttributeOption(option_id=562768697, name="Brick", score=0.12),
|
|
148
|
+
# ...
|
|
149
|
+
],
|
|
150
|
+
),
|
|
151
|
+
ClassificationAttributeResponse(
|
|
152
|
+
attribute_id=4240554102,
|
|
153
|
+
name="Building Size (Stories)",
|
|
154
|
+
options=[
|
|
155
|
+
ClassificationAttributeOption(option_id=3067238669, name="2 stories", score=0.91),
|
|
156
|
+
ClassificationAttributeOption(option_id=2398426374, name="1 story", score=0.06),
|
|
157
|
+
# ...
|
|
158
|
+
],
|
|
159
|
+
),
|
|
160
|
+
],
|
|
161
|
+
),
|
|
162
|
+
],
|
|
163
|
+
),
|
|
164
|
+
ClassificationVideoObjectPrediction(
|
|
165
|
+
frame_id="frame_0",
|
|
166
|
+
timestamp_microseconds=0,
|
|
167
|
+
normalizedBbox=(0.60, 0.30, 0.88, 0.75),
|
|
168
|
+
predictions=[
|
|
169
|
+
ClassificationCategoryPrediction(
|
|
170
|
+
category=ClassificationCategory(
|
|
171
|
+
id=3212613421,
|
|
172
|
+
name="Garage (detached)",
|
|
173
|
+
score=0.87,
|
|
174
|
+
),
|
|
175
|
+
attributes=[
|
|
176
|
+
# ... attributes omitted for brevity
|
|
177
|
+
],
|
|
178
|
+
),
|
|
179
|
+
],
|
|
180
|
+
),
|
|
181
|
+
],
|
|
182
|
+
1000000: [
|
|
183
|
+
# Objects detected at t=1s (1,000,000 microseconds)
|
|
184
|
+
# ...
|
|
185
|
+
],
|
|
186
|
+
},
|
|
187
|
+
)
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Each timestamp key (e.g., `0`, `1000000`) corresponds to a sampled frame. Within each frame, every detected object has its own bounding box, category prediction with a confidence score, and attribute predictions with scored options.
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## Client
|
|
195
|
+
|
|
196
|
+
**`Dragoneye`**
|
|
197
|
+
|
|
198
|
+
The main client used to interact with the API.
|
|
199
|
+
|
|
200
|
+
```python
|
|
201
|
+
client = Dragoneye(
|
|
202
|
+
api_key="<YOUR_ACCESS_TOKEN>",
|
|
203
|
+
max_retries=10,
|
|
204
|
+
max_backoff_time=120,
|
|
205
|
+
)
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
**Arguments:**
|
|
209
|
+
|
|
210
|
+
- `api_key` (Optional[str]): Your API key. If omitted, the SDK reads from the `DRAGONEYE_API_KEY` environment variable.
|
|
211
|
+
- `max_retries` (int): Maximum retry attempts on rate-limit (429) responses. Default: `10`.
|
|
212
|
+
- `max_backoff_time` (int): Maximum backoff time in seconds for exponential backoff. Default: `120`.
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## Media Classes
|
|
217
|
+
|
|
218
|
+
`Image` and `Video` are used to wrap media before passing it to a prediction endpoint. Each class restricts the MIME type to its respective media type (`image/*` or `video/*`).
|
|
219
|
+
|
|
220
|
+
### Constructors
|
|
221
|
+
|
|
222
|
+
**`from_path`**
|
|
223
|
+
|
|
224
|
+
```python
|
|
225
|
+
media = Image.from_path(
|
|
226
|
+
path="photo.jpg",
|
|
227
|
+
name="my-photo", # optional identifier
|
|
228
|
+
mime_type=None, # auto-detected from extension by default
|
|
229
|
+
guess_from_extension=True, # set False to require explicit mime_type
|
|
230
|
+
read_into_memory=False, # set True to load bytes into memory immediately
|
|
231
|
+
)
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
**`from_bytes`**
|
|
235
|
+
|
|
236
|
+
```python
|
|
237
|
+
media = Image.from_bytes(
|
|
238
|
+
data=raw_bytes,
|
|
239
|
+
mime_type="image/jpeg",
|
|
240
|
+
name="my-photo", # optional
|
|
241
|
+
)
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
**`from_stream`**
|
|
245
|
+
|
|
246
|
+
```python
|
|
247
|
+
media = Video.from_stream(
|
|
248
|
+
stream=open("clip.mp4", "rb"),
|
|
249
|
+
mime_type="video/mp4",
|
|
250
|
+
name="my-clip", # optional
|
|
251
|
+
)
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
## Types and Endpoints
|
|
257
|
+
|
|
258
|
+
### Types
|
|
259
|
+
|
|
260
|
+
The response types form a nested hierarchy. Here's how they fit together for image predictions:
|
|
261
|
+
|
|
262
|
+
```
|
|
263
|
+
ClassificationPredictImageResponse
|
|
264
|
+
└── object_predictions: [ClassificationObjectPrediction]
|
|
265
|
+
├── normalizedBbox: (x1, y1, x2, y2)
|
|
266
|
+
└── predictions: [ClassificationCategoryPrediction]
|
|
267
|
+
├── category: ClassificationCategory (id, name, score)
|
|
268
|
+
└── attributes: [ClassificationAttributeResponse]
|
|
269
|
+
└── options: [ClassificationAttributeOption] (option_id, name, score)
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
For video predictions, `ClassificationPredictVideoResponse` maps timestamps to lists of `ClassificationVideoObjectPrediction` (which extends `ClassificationObjectPrediction` with `frame_id` and `timestamp_microseconds`).
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
**`ClassificationCategory`**
|
|
277
|
+
Represents a predicted category.
|
|
278
|
+
|
|
279
|
+
Attributes:
|
|
280
|
+
|
|
281
|
+
- `id` (int): Unique identifier for the category.
|
|
282
|
+
- `name` (str): The name of the category.
|
|
283
|
+
- `score` (float): Confidence score for the prediction.
|
|
284
|
+
|
|
285
|
+
**`ClassificationAttributeOption`**
|
|
286
|
+
Represents a single option within an attribute prediction.
|
|
287
|
+
|
|
288
|
+
Attributes:
|
|
289
|
+
|
|
290
|
+
- `option_id` (int): Unique identifier for the option.
|
|
291
|
+
- `name` (str): The name of the option.
|
|
292
|
+
- `score` (float): Confidence score for this option.
|
|
293
|
+
|
|
294
|
+
**`ClassificationAttributeResponse`**
|
|
295
|
+
Represents a predicted attribute with its possible options.
|
|
296
|
+
|
|
297
|
+
Attributes:
|
|
298
|
+
|
|
299
|
+
- `attribute_id` (int): Unique identifier for the attribute.
|
|
300
|
+
- `name` (str): The name of the attribute.
|
|
301
|
+
- `options` (List[ClassificationAttributeOption]): The predicted options for this attribute.
|
|
302
|
+
|
|
303
|
+
**`ClassificationCategoryPrediction`**
|
|
304
|
+
Represents a category prediction along with its associated attribute predictions.
|
|
305
|
+
|
|
306
|
+
Attributes:
|
|
307
|
+
|
|
308
|
+
- `category` (ClassificationCategory): The predicted category.
|
|
309
|
+
- `attributes` (List[ClassificationAttributeResponse]): Attribute predictions for this category.
|
|
310
|
+
|
|
311
|
+
**`ClassificationObjectPrediction`**
|
|
312
|
+
Represents the prediction of a detected object in an image.
|
|
313
|
+
|
|
314
|
+
Attributes:
|
|
315
|
+
|
|
316
|
+
- `normalizedBbox` (NormalizedBbox): A bounding box for the detected object (coordinates are normalized).
|
|
317
|
+
- `predictions` (List[ClassificationCategoryPrediction]): Category and attribute predictions for this object.
|
|
318
|
+
|
|
319
|
+
**`ClassificationVideoObjectPrediction`**
|
|
320
|
+
Extends `ClassificationObjectPrediction` with video-specific fields.
|
|
321
|
+
|
|
322
|
+
Attributes:
|
|
323
|
+
|
|
324
|
+
- `normalizedBbox` (NormalizedBbox): A bounding box for the detected object.
|
|
325
|
+
- `predictions` (List[ClassificationCategoryPrediction]): Category and attribute predictions.
|
|
326
|
+
- `frame_id` (str): Identifier for the frame.
|
|
327
|
+
- `timestamp_microseconds` (int): Timestamp of the frame in microseconds.
|
|
328
|
+
|
|
329
|
+
**`ClassificationPredictImageResponse`**
|
|
330
|
+
The response object returned after predicting an image.
|
|
331
|
+
|
|
332
|
+
Attributes:
|
|
333
|
+
|
|
334
|
+
- `object_predictions` (List[ClassificationObjectPrediction]): Detected objects and their predictions.
|
|
335
|
+
- `prediction_task_uuid` (str): The unique identifier for the prediction task.
|
|
336
|
+
- `original_file_name` (Optional[str]): The file name of the original media, if provided.
|
|
337
|
+
|
|
338
|
+
**`ClassificationPredictVideoResponse`**
|
|
339
|
+
The response object returned after predicting a video.
|
|
340
|
+
|
|
341
|
+
Attributes:
|
|
342
|
+
|
|
343
|
+
- `timestamp_us_to_predictions` (Dict[int, List[ClassificationVideoObjectPrediction]]): A mapping from timestamp (in microseconds) to object predictions for that frame.
|
|
344
|
+
- `frames_per_second` (int): The number of frames per second that were sampled.
|
|
345
|
+
- `prediction_task_uuid` (str): The unique identifier for the prediction task.
|
|
346
|
+
- `original_file_name` (Optional[str]): The file name of the original media, if provided.
|
|
347
|
+
|
|
348
|
+
**`PredictionTaskStatusResponse`**
|
|
349
|
+
Represents the status of a prediction task.
|
|
350
|
+
|
|
351
|
+
Attributes:
|
|
352
|
+
|
|
353
|
+
- `prediction_task_uuid` (str): The unique identifier for the task.
|
|
354
|
+
- `prediction_type` (str): Either `"image"` or `"video"`.
|
|
355
|
+
- `status` (str): The current task status (`predicted`, `failed`, etc.).
|
|
356
|
+
|
|
357
|
+
**`NormalizedBbox`**
|
|
358
|
+
Type alias for normalized bounding boxes, represented as a tuple of four float values.
|
|
359
|
+
|
|
360
|
+
---
|
|
361
|
+
|
|
362
|
+
### Endpoints
|
|
363
|
+
|
|
364
|
+
#### `client.classification.predict_image`
|
|
365
|
+
|
|
366
|
+
```python
|
|
367
|
+
await client.classification.predict_image(
|
|
368
|
+
media: Image,
|
|
369
|
+
model_name: str,
|
|
370
|
+
timeout_seconds: Optional[int] = None,
|
|
371
|
+
) -> ClassificationPredictImageResponse
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
Performs a classification prediction on a single image.
|
|
375
|
+
|
|
376
|
+
| Parameter | Type | Default | Description |
|
|
377
|
+
|-----------|------|---------|-------------|
|
|
378
|
+
| `media` | `Image` | *required* | An `Image` object (from `from_path`, `from_bytes`, or `from_stream`). |
|
|
379
|
+
| `model_name` | `str` | *required* | The name of the model to use for prediction. |
|
|
380
|
+
| `timeout_seconds` | `Optional[int]` | `None` | Maximum wait time in seconds. Raises `PredictionTimeoutException` on timeout. `None` polls indefinitely. |
|
|
381
|
+
|
|
382
|
+
**Returns:** `ClassificationPredictImageResponse` — detected objects and their predictions.
|
|
383
|
+
|
|
384
|
+
---
|
|
385
|
+
|
|
386
|
+
#### `client.classification.predict_video`
|
|
387
|
+
|
|
388
|
+
```python
|
|
389
|
+
await client.classification.predict_video(
|
|
390
|
+
media: Video,
|
|
391
|
+
model_name: str,
|
|
392
|
+
frames_per_second: int = 1,
|
|
393
|
+
timeout_seconds: Optional[int] = None,
|
|
394
|
+
) -> ClassificationPredictVideoResponse
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
Performs a classification prediction on a video.
|
|
398
|
+
|
|
399
|
+
| Parameter | Type | Default | Description |
|
|
400
|
+
|-----------|------|---------|-------------|
|
|
401
|
+
| `media` | `Video` | *required* | A `Video` object (from `from_path`, `from_bytes`, or `from_stream`). |
|
|
402
|
+
| `model_name` | `str` | *required* | The name of the model to use for prediction. |
|
|
403
|
+
| `frames_per_second` | `int` | `1` | How many frames per second to sample from the video. |
|
|
404
|
+
| `timeout_seconds` | `Optional[int]` | `None` | Maximum wait time in seconds. Raises `PredictionTimeoutException` on timeout. `None` polls indefinitely. |
|
|
405
|
+
|
|
406
|
+
**Returns:** `ClassificationPredictVideoResponse` — frame-level prediction results.
|
|
407
|
+
|
|
408
|
+
---
|
|
409
|
+
|
|
410
|
+
#### `client.classification.status`
|
|
411
|
+
|
|
412
|
+
```python
|
|
413
|
+
await client.classification.status(
|
|
414
|
+
prediction_task_uuid: str,
|
|
415
|
+
) -> PredictionTaskStatusResponse
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
Checks the status of a prediction task.
|
|
419
|
+
|
|
420
|
+
| Parameter | Type | Default | Description |
|
|
421
|
+
|-----------|------|---------|-------------|
|
|
422
|
+
| `prediction_task_uuid` | `str` | *required* | The UUID of the prediction task. |
|
|
423
|
+
|
|
424
|
+
**Returns:** `PredictionTaskStatusResponse` — the task's current status.
|
|
425
|
+
|
|
426
|
+
---
|
|
427
|
+
|
|
428
|
+
#### `client.classification.get_image_results`
|
|
429
|
+
|
|
430
|
+
```python
|
|
431
|
+
await client.classification.get_image_results(
|
|
432
|
+
prediction_task_uuid: str,
|
|
433
|
+
) -> ClassificationPredictImageResponse
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
Retrieves the results of a completed image prediction task.
|
|
437
|
+
|
|
438
|
+
| Parameter | Type | Default | Description |
|
|
439
|
+
|-----------|------|---------|-------------|
|
|
440
|
+
| `prediction_task_uuid` | `str` | *required* | The UUID of the prediction task. |
|
|
441
|
+
|
|
442
|
+
**Returns:** `ClassificationPredictImageResponse`
|
|
443
|
+
|
|
444
|
+
---
|
|
445
|
+
|
|
446
|
+
#### `client.classification.get_video_results`
|
|
447
|
+
|
|
448
|
+
```python
|
|
449
|
+
await client.classification.get_video_results(
|
|
450
|
+
prediction_task_uuid: str,
|
|
451
|
+
) -> ClassificationPredictVideoResponse
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
Retrieves the results of a completed video prediction task.
|
|
455
|
+
|
|
456
|
+
| Parameter | Type | Default | Description |
|
|
457
|
+
|-----------|------|---------|-------------|
|
|
458
|
+
| `prediction_task_uuid` | `str` | *required* | The UUID of the prediction task. |
|
|
459
|
+
|
|
460
|
+
**Returns:** `ClassificationPredictVideoResponse`
|
|
461
|
+
|
|
462
|
+
---
|
|
463
|
+
|
|
464
|
+
## Error Handling
|
|
465
|
+
|
|
466
|
+
The SDK defines the following exception types:
|
|
467
|
+
|
|
468
|
+
| Exception | When it's raised |
|
|
469
|
+
|-----------|-----------------|
|
|
470
|
+
| `PredictionTimeoutException` | The prediction did not complete within the specified `timeout_seconds`. |
|
|
471
|
+
| `PredictionTaskError` | The prediction task failed on the server. |
|
|
472
|
+
| `PredictionUploadError` | The media file could not be uploaded. |
|
|
473
|
+
| `PredictionTaskBeginError` | The prediction task could not be started. |
|
|
474
|
+
| `PredictionTaskResultsUnavailableError` | Results were requested for a task that has not completed. |
|
|
475
|
+
|
|
476
|
+
```python
|
|
477
|
+
from dragoneye import Dragoneye, Image
|
|
478
|
+
from dragoneye.types.exception import (
|
|
479
|
+
PredictionTimeoutException,
|
|
480
|
+
PredictionTaskError,
|
|
481
|
+
PredictionUploadError,
|
|
482
|
+
)
|
|
483
|
+
|
|
484
|
+
try:
|
|
485
|
+
result = await client.classification.predict_image(
|
|
486
|
+
media=image,
|
|
487
|
+
model_name="recognize_anything/your_model_name",
|
|
488
|
+
timeout_seconds=60,
|
|
489
|
+
)
|
|
490
|
+
except PredictionTimeoutException:
|
|
491
|
+
print("Prediction timed out — try increasing timeout_seconds")
|
|
492
|
+
except PredictionUploadError:
|
|
493
|
+
print("Failed to upload media — check file path and format")
|
|
494
|
+
except PredictionTaskError:
|
|
495
|
+
print("Prediction task failed on the server")
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
---
|
|
499
|
+
|
|
500
|
+
## Notes
|
|
501
|
+
|
|
502
|
+
- All public methods are **asynchronous**. Use `asyncio.run` or an async loop to call them.
|
|
503
|
+
- For images, use `predict_image` with an `Image` object. For videos, use `predict_video` with a `Video` object. Passing the wrong media type will raise a `ValueError`.
|
|
504
|
+
- Predictions are executed as tasks: the SDK automatically handles task creation, media upload, polling, and result retrieval.
|
|
505
|
+
- The SDK automatically retries on rate-limit (429) responses using exponential backoff. You can configure this behavior via the `max_retries` and `max_backoff_time` parameters on the `Dragoneye` client.
|