Reference for ultralytics/hub/session.py
Note
This file is available at https://github.com/ultralytics/ultralytics/blob/main/ultralytics/hub/session.py. If you spot a problem please help fix it by contributing a Pull Request 🛠️. Thank you 🙏!
ultralytics.hub.session.HUBTrainingSession
HUB training session for Ultralytics HUB YOLO models. Handles model initialization, heartbeats, and checkpointing.
Attributes:
Name | Type | Description |
---|---|---|
model_id |
str
|
Identifier for the YOLO model being trained. |
model_url |
str
|
URL for the model in Ultralytics HUB. |
rate_limits |
dict
|
Rate limits for different API calls (in seconds). |
timers |
dict
|
Timers for rate limiting. |
metrics_queue |
dict
|
Queue for the model's metrics. |
model |
dict
|
Model data fetched from Ultralytics HUB. |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier |
str
|
Model identifier used to initialize the HUB training session. It can be a URL string or a model key with specific format. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If the provided model identifier is invalid. |
ConnectionError
|
If connecting with global API key is not supported. |
ModuleNotFoundError
|
If hub-sdk package is not installed. |
Source code in ultralytics/hub/session.py
create_model
Initializes a HUB training session with the specified model identifier.
Source code in ultralytics/hub/session.py
create_session
classmethod
Class method to create an authenticated HUBTrainingSession or return None.
Source code in ultralytics/hub/session.py
load_model
Loads an existing model from Ultralytics HUB using the provided model identifier.
Source code in ultralytics/hub/session.py
request_queue
request_queue(request_func, retry=3, timeout=30, thread=True, verbose=True, progress_total=None, stream_response=None, *args, **kwargs)
Attempts to execute request_func
with retries, timeout handling, optional threading, and progress.
Source code in ultralytics/hub/session.py
upload_metrics
upload_model
upload_model(epoch: int, weights: str, is_best: bool = False, map: float = 0.0, final: bool = False) -> None
Upload a model checkpoint to Ultralytics HUB.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
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
|