Apply ruff==0.9.0 formatting (#18624)
Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
parent
c196a82bfa
commit
34b339d033
12 changed files with 17 additions and 30 deletions
|
|
@ -15,16 +15,14 @@ def on_pretrain_routine_start(trainer):
|
|||
|
||||
def on_pretrain_routine_end(trainer):
|
||||
"""Logs info before starting timer for upload rate limit."""
|
||||
session = getattr(trainer, "hub_session", None)
|
||||
if session:
|
||||
if session := getattr(trainer, "hub_session", None):
|
||||
# Start timer for upload rate limit
|
||||
session.timers = {"metrics": time(), "ckpt": time()} # start timer on session.rate_limit
|
||||
|
||||
|
||||
def on_fit_epoch_end(trainer):
|
||||
"""Uploads training progress metrics at the end of each epoch."""
|
||||
session = getattr(trainer, "hub_session", None)
|
||||
if session:
|
||||
if session := getattr(trainer, "hub_session", None):
|
||||
# Upload metrics after val end
|
||||
all_plots = {
|
||||
**trainer.label_loss_items(trainer.tloss, prefix="train"),
|
||||
|
|
@ -49,8 +47,7 @@ def on_fit_epoch_end(trainer):
|
|||
|
||||
def on_model_save(trainer):
|
||||
"""Saves checkpoints to Ultralytics HUB with rate limiting."""
|
||||
session = getattr(trainer, "hub_session", None)
|
||||
if session:
|
||||
if session := getattr(trainer, "hub_session", None):
|
||||
# Upload checkpoints with rate limiting
|
||||
is_best = trainer.best_fitness == trainer.fitness
|
||||
if time() - session.timers["ckpt"] > session.rate_limits["ckpt"]:
|
||||
|
|
@ -61,8 +58,7 @@ def on_model_save(trainer):
|
|||
|
||||
def on_train_end(trainer):
|
||||
"""Upload final model and metrics to Ultralytics HUB at the end of training."""
|
||||
session = getattr(trainer, "hub_session", None)
|
||||
if session:
|
||||
if session := getattr(trainer, "hub_session", None):
|
||||
# Upload final model and metrics with exponential standoff
|
||||
LOGGER.info(f"{PREFIX}Syncing final model...")
|
||||
session.upload_model(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue