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>
This commit is contained in:
parent
40137785ec
commit
abd391b633
4 changed files with 10 additions and 7 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
||||||
|
|
||||||
__version__ = "8.2.54"
|
__version__ = "8.2.55"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1017,13 +1017,13 @@ class Exporter:
|
||||||
"""Add metadata to *.tflite models per https://www.tensorflow.org/lite/models/convert/metadata."""
|
"""Add metadata to *.tflite models per https://www.tensorflow.org/lite/models/convert/metadata."""
|
||||||
import flatbuffers
|
import flatbuffers
|
||||||
|
|
||||||
if ARM64:
|
try:
|
||||||
from tflite_support import metadata # noqa
|
|
||||||
from tflite_support import metadata_schema_py_generated as schema # noqa
|
|
||||||
else:
|
|
||||||
# TFLite Support bug https://github.com/tensorflow/tflite-support/issues/954#issuecomment-2108570845
|
# 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 import metadata_schema_py_generated as schema # noqa
|
||||||
from tensorflow_lite_support.metadata.python import metadata # 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
|
# Create model info
|
||||||
model_meta = schema.ModelMetadataT()
|
model_meta = schema.ModelMetadataT()
|
||||||
|
|
|
||||||
|
|
@ -185,7 +185,7 @@ class Events:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Initializes the Events object with default values for events, rate_limit, and metadata."""
|
"""Initializes the Events object with default values for events, rate_limit, and metadata."""
|
||||||
self.events = [] # events list
|
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.t = 0.0 # rate limit timer (seconds)
|
||||||
self.metadata = {
|
self.metadata = {
|
||||||
"cli": Path(ARGV[0]).name == "yolo",
|
"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 ""
|
fs = f", {flops:.1f} GFLOPs" if flops else ""
|
||||||
yaml_file = getattr(model, "yaml_file", "") or getattr(model, "yaml", {}).get("yaml_file", "")
|
yaml_file = getattr(model, "yaml_file", "") or getattr(model, "yaml", {}).get("yaml_file", "")
|
||||||
model_name = Path(yaml_file).stem.replace("yolo", "YOLO") or "Model"
|
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
|
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'):
|
for f in Path('path/to/model/checkpoints').rglob('*.pt'):
|
||||||
strip_optimizer(f)
|
strip_optimizer(f)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Note:
|
||||||
|
Use `ultralytics.nn.torch_safe_load` for missing modules with `x = torch_safe_load(f)[0]`
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
x = torch.load(f, map_location=torch.device("cpu"))
|
x = torch.load(f, map_location=torch.device("cpu"))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue