From abd391b63338b79cebee808b6679498dcc94956f Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Fri, 12 Jul 2024 13:47:05 +0200 Subject: [PATCH] `ultralytics 8.2.55` adaptive `tflite_support` logic (#14385) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Glenn Jocher Co-authored-by: Ultralytics Assistant <135830346+UltralyticsAssistant@users.noreply.github.com> Co-authored-by: Nguyễn Anh Bình Co-authored-by: Johnny Co-authored-by: Muhammad Rizwan Munawar Co-authored-by: UltralyticsAssistant --- ultralytics/__init__.py | 2 +- ultralytics/engine/exporter.py | 8 ++++---- ultralytics/hub/utils.py | 2 +- ultralytics/utils/torch_utils.py | 5 ++++- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ultralytics/__init__.py b/ultralytics/__init__.py index 9caf612852..3ab357bd9c 100644 --- a/ultralytics/__init__.py +++ b/ultralytics/__init__.py @@ -1,6 +1,6 @@ # Ultralytics YOLO 🚀, AGPL-3.0 license -__version__ = "8.2.54" +__version__ = "8.2.55" import os diff --git a/ultralytics/engine/exporter.py b/ultralytics/engine/exporter.py index 9bb6fefdd4..47466e30ff 100644 --- a/ultralytics/engine/exporter.py +++ b/ultralytics/engine/exporter.py @@ -1017,13 +1017,13 @@ class Exporter: """Add metadata to *.tflite models per https://www.tensorflow.org/lite/models/convert/metadata.""" import flatbuffers - if ARM64: - from tflite_support import metadata # noqa - from tflite_support import metadata_schema_py_generated as schema # noqa - else: + try: # TFLite Support bug https://github.com/tensorflow/tflite-support/issues/954#issuecomment-2108570845 from tensorflow_lite_support.metadata import metadata_schema_py_generated as schema # noqa from tensorflow_lite_support.metadata.python import metadata # noqa + except ImportError: # ARM64 systems may not have the 'tensorflow_lite_support' package available + from tflite_support import metadata # noqa + from tflite_support import metadata_schema_py_generated as schema # noqa # Create model info model_meta = schema.ModelMetadataT() diff --git a/ultralytics/hub/utils.py b/ultralytics/hub/utils.py index 2e84c7d3a8..6005609f81 100644 --- a/ultralytics/hub/utils.py +++ b/ultralytics/hub/utils.py @@ -185,7 +185,7 @@ class Events: def __init__(self): """Initializes the Events object with default values for events, rate_limit, and metadata.""" self.events = [] # events list - self.rate_limit = 60.0 # rate limit (seconds) + self.rate_limit = 30.0 # rate limit (seconds) self.t = 0.0 # rate limit timer (seconds) self.metadata = { "cli": Path(ARGV[0]).name == "yolo", diff --git a/ultralytics/utils/torch_utils.py b/ultralytics/utils/torch_utils.py index 0016c97034..ca814b602c 100644 --- a/ultralytics/utils/torch_utils.py +++ b/ultralytics/utils/torch_utils.py @@ -271,7 +271,7 @@ def model_info(model, detailed=False, verbose=True, imgsz=640): fs = f", {flops:.1f} GFLOPs" if flops else "" yaml_file = getattr(model, "yaml_file", "") or getattr(model, "yaml", {}).get("yaml_file", "") model_name = Path(yaml_file).stem.replace("yolo", "YOLO") or "Model" - LOGGER.info(f"{model_name} summary{fused}: {n_l} layers, {n_p} parameters, {n_g} gradients{fs}") + LOGGER.info(f"{model_name} summary{fused}: {n_l:,} layers, {n_p:,} parameters, {n_g:,} gradients{fs}") return n_l, n_p, n_g, flops @@ -513,6 +513,9 @@ def strip_optimizer(f: Union[str, Path] = "best.pt", s: str = "") -> None: for f in Path('path/to/model/checkpoints').rglob('*.pt'): strip_optimizer(f) ``` + + Note: + Use `ultralytics.nn.torch_safe_load` for missing modules with `x = torch_safe_load(f)[0]` """ try: x = torch.load(f, map_location=torch.device("cpu"))