Update events (#20456)
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: UltralyticsAssistant <web@ultralytics.com> Co-authored-by: Ultralytics Assistant <135830346+UltralyticsAssistant@users.noreply.github.com> Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
parent
434a75a755
commit
90d6493deb
@ -244,7 +244,6 @@ class Exporter:
|
||||
|
||||
def __call__(self, model=None) -> str:
|
||||
"""Return list of exported files/dirs after running callbacks."""
|
||||
self.run_callbacks("on_export_start")
|
||||
t = time.time()
|
||||
fmt = self.args.format.lower() # to lowercase
|
||||
if fmt in {"tensorrt", "trt"}: # 'engine' aliases
|
||||
@ -450,7 +449,7 @@ class Exporter:
|
||||
f"\n{colorstr('PyTorch:')} starting from '{file}' with input shape {tuple(im.shape)} BCHW and "
|
||||
f"output shape(s) {self.output_shape} ({file_size(file):.1f} MB)"
|
||||
)
|
||||
|
||||
self.run_callbacks("on_export_start")
|
||||
# Exports
|
||||
f = [""] * len(fmts) # exported filenames
|
||||
if jit or ncnn: # TorchScript
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||
|
||||
import os
|
||||
import platform
|
||||
import random
|
||||
import threading
|
||||
import time
|
||||
@ -18,6 +17,7 @@ from ultralytics.utils import (
|
||||
IS_PIP_PACKAGE,
|
||||
LOGGER,
|
||||
ONLINE,
|
||||
PYTHON_VERSION,
|
||||
RANK,
|
||||
SETTINGS,
|
||||
TESTS_RUNNING,
|
||||
@ -27,6 +27,7 @@ from ultralytics.utils import (
|
||||
get_git_origin_url,
|
||||
)
|
||||
from ultralytics.utils.downloads import GITHUB_ASSETS_NAMES
|
||||
from ultralytics.utils.torch_utils import get_cpu_info
|
||||
|
||||
HUB_API_ROOT = os.environ.get("ULTRALYTICS_HUB_API", "https://api.ultralytics.com")
|
||||
HUB_WEB_ROOT = os.environ.get("ULTRALYTICS_HUB_WEB", "https://hub.ultralytics.com")
|
||||
@ -191,7 +192,9 @@ class Events:
|
||||
self.metadata = {
|
||||
"cli": Path(ARGV[0]).name == "yolo",
|
||||
"install": "git" if IS_GIT_DIR else "pip" if IS_PIP_PACKAGE else "other",
|
||||
"python": ".".join(platform.python_version_tuple()[:2]), # i.e. 3.10
|
||||
"python": PYTHON_VERSION.rsplit(".", 1)[0], # i.e. 3.13
|
||||
"CPU": get_cpu_info(),
|
||||
# "GPU": get_gpu_info(index=0) if cuda else None,
|
||||
"version": __version__,
|
||||
"env": ENVIRONMENT,
|
||||
"session_id": round(random.random() * 1e15),
|
||||
@ -205,12 +208,13 @@ class Events:
|
||||
and (IS_PIP_PACKAGE or get_git_origin_url() == "https://github.com/ultralytics/ultralytics.git")
|
||||
)
|
||||
|
||||
def __call__(self, cfg):
|
||||
def __call__(self, cfg, device=None):
|
||||
"""
|
||||
Attempt to add a new event to the events list and send events if the rate limit is reached.
|
||||
|
||||
Args:
|
||||
cfg (IterableSimpleNamespace): The configuration object containing mode and task information.
|
||||
device (torch.device | str): The device type (e.g., 'cpu', 'cuda').
|
||||
"""
|
||||
if not self.enabled:
|
||||
# Events disabled, do nothing
|
||||
@ -222,6 +226,7 @@ class Events:
|
||||
**self.metadata,
|
||||
"task": cfg.task,
|
||||
"model": cfg.model if cfg.model in GITHUB_ASSETS_NAMES else "custom",
|
||||
"device": str(device),
|
||||
}
|
||||
if cfg.mode == "export":
|
||||
params["format"] = cfg.format
|
||||
|
||||
@ -73,22 +73,23 @@ def on_train_end(trainer):
|
||||
|
||||
def on_train_start(trainer):
|
||||
"""Run events on train start."""
|
||||
events(trainer.args)
|
||||
events(trainer.args, trainer.device)
|
||||
|
||||
|
||||
def on_val_start(validator):
|
||||
"""Run events on validation start."""
|
||||
events(validator.args)
|
||||
if not validator.training:
|
||||
events(validator.args, validator.device)
|
||||
|
||||
|
||||
def on_predict_start(predictor):
|
||||
"""Run events on predict start."""
|
||||
events(predictor.args)
|
||||
events(predictor.args, predictor.device)
|
||||
|
||||
|
||||
def on_export_start(exporter):
|
||||
"""Run events on export start."""
|
||||
events(exporter.args)
|
||||
events(exporter.args, exporter.device)
|
||||
|
||||
|
||||
callbacks = (
|
||||
|
||||
@ -423,6 +423,7 @@ def check_torchvision():
|
||||
to the compatibility table based on: https://github.com/pytorch/vision#installation.
|
||||
"""
|
||||
compatibility_table = {
|
||||
"2.7": ["0.22"],
|
||||
"2.6": ["0.21"],
|
||||
"2.5": ["0.20"],
|
||||
"2.4": ["0.19"],
|
||||
@ -655,7 +656,7 @@ def collect_system_info():
|
||||
from ultralytics.utils.torch_utils import get_cpu_info, get_gpu_info
|
||||
|
||||
gib = 1 << 30 # bytes per GiB
|
||||
cuda = torch and torch.cuda.is_available()
|
||||
cuda = torch.cuda.is_available()
|
||||
check_yolo()
|
||||
total, used, free = shutil.disk_usage("/")
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||
|
||||
import functools
|
||||
import gc
|
||||
import math
|
||||
import os
|
||||
@ -101,6 +102,7 @@ def autocast(enabled: bool, device: str = "cuda"):
|
||||
return torch.cuda.amp.autocast(enabled)
|
||||
|
||||
|
||||
@functools.lru_cache
|
||||
def get_cpu_info():
|
||||
"""Return a string with system CPU information, i.e. 'Apple M2'."""
|
||||
from ultralytics.utils import PERSISTENT_CACHE # avoid circular import error
|
||||
@ -118,6 +120,7 @@ def get_cpu_info():
|
||||
return PERSISTENT_CACHE.get("cpu_info", "unknown")
|
||||
|
||||
|
||||
@functools.lru_cache
|
||||
def get_gpu_info(index):
|
||||
"""Return a string with system GPU information, i.e. 'Tesla T4, 15102MiB'."""
|
||||
properties = torch.cuda.get_device_properties(index)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user