ultralytics 8.1.21 Add YOLOv8-World-v2 models (#8580)

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
Laughing 2024-03-04 05:56:57 +08:00 committed by GitHub
parent 906b8d31dc
commit 946e18f79c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 98 additions and 48 deletions

View file

@ -295,7 +295,7 @@ class Model(nn.Module):
self.model.load(weights)
return self
def save(self, filename: Union[str, Path] = "saved_model.pt") -> None:
def save(self, filename: Union[str, Path] = "saved_model.pt", use_dill=True) -> None:
"""
Saves the current model state to a file.
@ -303,12 +303,22 @@ class Model(nn.Module):
Args:
filename (str | Path): The name of the file to save the model to. Defaults to 'saved_model.pt'.
use_dill (bool): Whether to try using dill for serialization if available. Defaults to True.
Raises:
AssertionError: If the model is not a PyTorch model.
"""
self._check_is_pytorch_model()
torch.save(self.ckpt, filename)
from ultralytics import __version__
from datetime import datetime
updates = {
"date": datetime.now().isoformat(),
"version": __version__,
"license": "AGPL-3.0 License (https://ultralytics.com/license)",
"docs": "https://docs.ultralytics.com",
}
torch.save({**self.ckpt, **updates}, filename, use_dill=use_dill)
def info(self, detailed: bool = False, verbose: bool = True):
"""