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:
parent
906b8d31dc
commit
946e18f79c
12 changed files with 98 additions and 48 deletions
|
|
@ -68,7 +68,7 @@ from ultralytics.data.dataset import YOLODataset
|
|||
from ultralytics.data.utils import check_det_dataset
|
||||
from ultralytics.nn.autobackend import check_class_names, default_class_names
|
||||
from ultralytics.nn.modules import C2f, Detect, RTDETRDecoder
|
||||
from ultralytics.nn.tasks import DetectionModel, SegmentationModel
|
||||
from ultralytics.nn.tasks import DetectionModel, SegmentationModel, WorldModel
|
||||
from ultralytics.utils import (
|
||||
ARM64,
|
||||
DEFAULT_CFG,
|
||||
|
|
@ -201,6 +201,14 @@ class Exporter:
|
|||
assert self.device.type == "cpu", "optimize=True not compatible with cuda devices, i.e. use device='cpu'"
|
||||
if edgetpu and not LINUX:
|
||||
raise SystemError("Edge TPU export only supported on Linux. See https://coral.ai/docs/edgetpu/compiler/")
|
||||
print(type(model))
|
||||
if isinstance(model, WorldModel):
|
||||
LOGGER.warning(
|
||||
"WARNING ⚠️ YOLOWorld (original version) export is not supported to any format.\n"
|
||||
"WARNING ⚠️ YOLOWorldv2 models (i.e. 'yolov8s-worldv2.pt') only support export to "
|
||||
"(torchscript, onnx, openvino, engine, coreml) formats. "
|
||||
"See https://docs.ultralytics.com/models/yolo-world for details."
|
||||
)
|
||||
|
||||
# Input
|
||||
im = torch.zeros(self.args.batch, 3, *self.imgsz).to(self.device)
|
||||
|
|
@ -252,9 +260,10 @@ class Exporter:
|
|||
self.metadata = {
|
||||
"description": description,
|
||||
"author": "Ultralytics",
|
||||
"license": "AGPL-3.0 https://ultralytics.com/license",
|
||||
"date": datetime.now().isoformat(),
|
||||
"version": __version__,
|
||||
"license": "AGPL-3.0 License (https://ultralytics.com/license)",
|
||||
"docs": "https://docs.ultralytics.com",
|
||||
"stride": int(max(model.stride)),
|
||||
"task": model.task,
|
||||
"batch": self.args.batch,
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -488,6 +488,8 @@ class BaseTrainer:
|
|||
"train_results": results,
|
||||
"date": datetime.now().isoformat(),
|
||||
"version": __version__,
|
||||
"license": "AGPL-3.0 (https://ultralytics.com/license)",
|
||||
"docs": "https://docs.ultralytics.com",
|
||||
}
|
||||
|
||||
# Save last and best
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue