From 37ebf6e89b2ca962d2e66219fde7ff87d44d8c98 Mon Sep 17 00:00:00 2001 From: Muhammad Rizwan Munawar Date: Thu, 15 May 2025 17:55:40 +0500 Subject: [PATCH] `ultralytics 8.3.135` TF.js fix with `onnx>=1.12.0,<1.18.0` pin (#20640) Signed-off-by: Glenn Jocher Co-authored-by: Mohammed Yasin <32206511+Y-T-G@users.noreply.github.com> Co-authored-by: Laughing-q <1185102784@qq.com> Co-authored-by: Glenn Jocher --- ultralytics/__init__.py | 2 +- ultralytics/engine/exporter.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ultralytics/__init__.py b/ultralytics/__init__.py index 6c958443..b0ea6b89 100644 --- a/ultralytics/__init__.py +++ b/ultralytics/__init__.py @@ -1,6 +1,6 @@ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license -__version__ = "8.3.134" +__version__ = "8.3.135" import os diff --git a/ultralytics/engine/exporter.py b/ultralytics/engine/exporter.py index 0f601117..3d37905f 100644 --- a/ultralytics/engine/exporter.py +++ b/ultralytics/engine/exporter.py @@ -926,7 +926,7 @@ class Exporter: "sng4onnx>=1.0.1", # required by 'onnx2tf' package "onnx_graphsurgeon>=0.3.26", # required by 'onnx2tf' package "ai-edge-litert>=1.2.0", # required by 'onnx2tf' package - "onnx>=1.12.0", + "onnx>=1.12.0,<1.18.0", "onnx2tf>=1.26.3", "onnxslim>=0.1.46", "onnxruntime-gpu" if cuda else "onnxruntime", @@ -943,8 +943,6 @@ class Exporter: verbose=True, msg="https://github.com/ultralytics/ultralytics/issues/5161", ) - import onnx2tf - f = Path(str(self.file).replace(self.file.suffix, "_saved_model")) if f.is_dir(): shutil.rmtree(f) # delete output folder @@ -971,6 +969,8 @@ class Exporter: np.save(str(tmp_file), images.numpy().astype(np.float32)) # BHWC np_data = [["images", tmp_file, [[[[0, 0, 0]]]], [[[[255, 255, 255]]]]]] + import onnx2tf # scoped for after ONNX export for reduced conflict during import + LOGGER.info(f"{prefix} starting TFLite export with onnx2tf {onnx2tf.__version__}...") keras_model = onnx2tf.convert( input_onnx_file_path=f_onnx,