Reference for hub_sdk/base/server_clients.py
Note
This file is available at https://github.com/ultralytics/hub-sdk/blob/main/hub_sdk/base/server_clients.py. If you spot a problem please help fix it by contributing a Pull Request 🛠️. Thank you 🙏!
hub_sdk.base.server_clients.ModelUpload
ModelUpload(headers)
Bases: APIClient
Manages uploading and exporting model files and metrics to Ultralytics HUB and heartbeat updates.
This class handles the communication with Ultralytics HUB API for model-related operations including uploading model checkpoints, metrics, exporting models to different formats, and maintaining heartbeat connections to track model training status.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
Identifier for the model upload instance. |
alive |
bool
|
Flag indicating if the heartbeat thread should continue running. |
agent_id |
str
|
Unique identifier for the agent sending heartbeats. |
rate_limits |
Dict
|
Dictionary containing rate limits for different API operations in seconds. |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
headers
|
Dict
|
HTTP headers to use for API requests. |
required |
Source code in hub_sdk/base/server_clients.py
47 48 49 50 51 52 53 54 55 56 57 58 |
|
export
export(id: str, format: str) -> Optional[Response]
Export a model to a specific format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
str
|
The unique identifier of the model to be exported. |
required |
format
|
str
|
The format to export the model to. |
required |
Returns:
Type | Description |
---|---|
Optional[Response]
|
Response object from the export request, or None if it fails. |
Source code in hub_sdk/base/server_clients.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
predict
predict(id: str, image: str, config: Dict[str, Any]) -> Optional[Response]
Perform a prediction using the specified image and configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
str
|
Unique identifier for the model to use for prediction. |
required |
image
|
str
|
Image path for prediction. |
required |
config
|
Dict[str, Any]
|
Configuration parameters for the prediction. |
required |
Returns:
Type | Description |
---|---|
Optional[Response]
|
Response object from the predict request, or None if upload fails. |
Source code in hub_sdk/base/server_clients.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
|
upload_metrics
upload_metrics(id: str, data: dict) -> Optional[Response]
Upload metrics data for a specific model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
str
|
The unique identifier of the model to which the metrics are being uploaded. |
required |
data
|
dict
|
The metrics data to upload. |
required |
Returns:
Type | Description |
---|---|
Optional[Response]
|
Response object from the upload_metrics request, or None if it fails. |
Source code in hub_sdk/base/server_clients.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
|
upload_model
upload_model(id, epoch, weights, is_best=False, map=0.0, final=False)
Upload a model checkpoint to Ultralytics HUB.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
str
|
The unique identifier of the model. |
required |
epoch
|
int
|
The current training epoch. |
required |
weights
|
str
|
Path to the model weights file. |
required |
is_best
|
bool
|
Indicates if the current model is the best one so far. |
False
|
map
|
float
|
Mean average precision of the model. |
0.0
|
final
|
bool
|
Indicates if the model is the final model after training. |
False
|
Returns:
Type | Description |
---|---|
Optional[Response]
|
Response object from the upload request, or None if it fails. |
Source code in hub_sdk/base/server_clients.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
|
hub_sdk.base.server_clients.ProjectUpload
ProjectUpload(headers: dict)
Bases: APIClient
Handle project file uploads to Ultralytics HUB via API requests.
This class manages the uploading of project-related files to Ultralytics HUB, providing methods to handle image uploads for projects.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
Identifier for the project upload instance. |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
headers
|
dict
|
The headers to use for API requests. |
required |
Source code in hub_sdk/base/server_clients.py
246 247 248 249 250 251 252 253 254 |
|
upload_image
upload_image(id: str, file: str) -> Optional[Response]
Upload a project image to the hub.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
str
|
The ID of the project to upload the image to. |
required |
file
|
str
|
The path to the image file to upload. |
required |
Returns:
Type | Description |
---|---|
Optional[Response]
|
Response object from the upload image request, or None if it fails. |
Source code in hub_sdk/base/server_clients.py
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
|
hub_sdk.base.server_clients.DatasetUpload
DatasetUpload(headers: dict)
Bases: APIClient
Manages uploading dataset files to Ultralytics HUB via API requests.
This class handles the uploading of dataset files to Ultralytics HUB, providing methods to manage dataset uploads.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
Identifier for the dataset upload instance. |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
headers
|
dict
|
The headers to use for API requests. |
required |
Source code in hub_sdk/base/server_clients.py
294 295 296 297 298 299 300 301 302 |
|
upload_dataset
upload_dataset(id, file) -> Optional[Response]
Upload a dataset file to the hub.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
str
|
The ID of the dataset to upload. |
required |
file
|
str
|
The path to the dataset file to upload. |
required |
Returns:
Type | Description |
---|---|
Optional[Response]
|
Response object from the upload dataset request, or None if it fails. |
Source code in hub_sdk/base/server_clients.py
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
|
hub_sdk.base.server_clients.is_colab
is_colab()
Check if the current script is running inside a Google Colab notebook.
Returns:
Type | Description |
---|---|
bool
|
True if running inside a Colab notebook, False otherwise. |
Source code in hub_sdk/base/server_clients.py
17 18 19 20 21 22 23 24 |
|