ultralytics 8.2.81 fix HUB missing 'best.pt' resumed checkpoint upload (#15754)
This commit is contained in:
parent
a89b316f27
commit
2b7fac4db4
2 changed files with 30 additions and 18 deletions
|
|
@ -1,6 +1,6 @@
|
|||
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
||||
|
||||
__version__ = "8.2.80"
|
||||
__version__ = "8.2.81"
|
||||
|
||||
import os
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
||||
|
||||
import shutil
|
||||
import threading
|
||||
import time
|
||||
from http import HTTPStatus
|
||||
|
|
@ -344,23 +345,34 @@ class HUBTrainingSession:
|
|||
map (float): Mean average precision of the model.
|
||||
final (bool): Indicates if the model is the final model after training.
|
||||
"""
|
||||
if Path(weights).is_file():
|
||||
progress_total = Path(weights).stat().st_size if final else None # Only show progress if final
|
||||
weights = Path(weights)
|
||||
if not weights.is_file():
|
||||
last = weights.with_name("last" + weights.suffix)
|
||||
if final and last.is_file():
|
||||
LOGGER.warning(
|
||||
f"{PREFIX} ARNING ⚠️ Model 'best.pt' not found, copying 'last.pt' to 'best.pt' and uploading. "
|
||||
"This often happens when resuming training in transient environments like Google Colab. "
|
||||
"For more reliable training, consider using Ultralytics HUB Cloud. "
|
||||
"Learn more at https://docs.ultralytics.com/hub/cloud-training/."
|
||||
)
|
||||
shutil.copy(last, weights) # copy last.pt to best.pt
|
||||
else:
|
||||
LOGGER.warning(f"{PREFIX} WARNING ⚠️ Model upload issue. Missing model {weights}.")
|
||||
return
|
||||
|
||||
self.request_queue(
|
||||
self.model.upload_model,
|
||||
epoch=epoch,
|
||||
weights=weights,
|
||||
weights=str(weights),
|
||||
is_best=is_best,
|
||||
map=map,
|
||||
final=final,
|
||||
retry=10,
|
||||
timeout=3600,
|
||||
thread=not final,
|
||||
progress_total=progress_total,
|
||||
progress_total=weights.stat().st_size if final else None, # only show progress if final
|
||||
stream_response=True,
|
||||
)
|
||||
else:
|
||||
LOGGER.warning(f"{PREFIX}WARNING ⚠️ Model upload issue. Missing model {weights}.")
|
||||
|
||||
@staticmethod
|
||||
def _show_upload_progress(content_length: int, response: requests.Response) -> None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue