`ultralytics 8.2.55` adaptive `tflite_support` logic (#14385)

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: Ultralytics Assistant <135830346+UltralyticsAssistant@users.noreply.github.com>
Co-authored-by: Nguyễn Anh Bình <sometimesocrazy@gmail.com>
Co-authored-by: Johnny <johnnynuca14@gmail.com>
Co-authored-by: Muhammad Rizwan Munawar <muhammadrizwanmunawar123@gmail.com>
Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
pull/14269/head v8.2.55
Glenn Jocher 5 months ago committed by GitHub
parent 40137785ec
commit abd391b633
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      ultralytics/__init__.py
  2. 8
      ultralytics/engine/exporter.py
  3. 2
      ultralytics/hub/utils.py
  4. 5
      ultralytics/utils/torch_utils.py

@ -1,6 +1,6 @@
# Ultralytics YOLO 🚀, AGPL-3.0 license
__version__ = "8.2.54"
__version__ = "8.2.55"
import os

@ -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()

@ -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",

@ -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"))

Loading…
Cancel
Save