From c5ad60213ce2ff47aac476056b52f279ce56a02f Mon Sep 17 00:00:00 2001 From: Francesco Mattioli Date: Fri, 8 Nov 2024 11:42:27 +0100 Subject: [PATCH] fixed tests --- mkdocs.yml | 1 - tests/test_exports.py | 28 +++++++++++++++------------- ultralytics/engine/exporter.py | 6 ++---- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/mkdocs.yml b/mkdocs.yml index a806160628..d8dd6a3c6e 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -407,7 +407,6 @@ nav: - Paperspace Gradient: integrations/paperspace.md - Ray Tune: integrations/ray-tune.md - Roboflow: integrations/roboflow.md - - Sony MCT: integrations/sony-mct.md - TF GraphDef: integrations/tf-graphdef.md - TF SavedModel: integrations/tf-savedmodel.md - TF.js: integrations/tfjs.md diff --git a/tests/test_exports.py b/tests/test_exports.py index d1111a6bab..b8b217132e 100644 --- a/tests/test_exports.py +++ b/tests/test_exports.py @@ -31,6 +31,20 @@ def test_export_onnx(): file = YOLO(MODEL).export(format="onnx", dynamic=True, imgsz=32) YOLO(file)(SOURCE, imgsz=32) # exported model inference +@pytest.mark.skipif(not LINUX or MACOS, reason="Skipping test on Windows and Macos") +def test_export_imx500_ptq(): + """Test YOLOv8n exports to imx500 format.""" + model = YOLO("yolov8n.pt") + file = model.export(format="imx500", imgsz=32, gptq=False) + YOLO(file)(SOURCE, imgsz=32) + +@pytest.mark.slow +@pytest.mark.skipif(IS_RASPBERRYPI or not LINUX or MACOS, reason="Skipping test on Raspberry Pi and Windows") +def test_export_imx500_gptq(): + """Test YOLOv8n exports to imx500 format with gptq.""" + model = YOLO("yolov8n.pt") + file = model.export(format="imx500", imgsz=32, gptq=True) + YOLO(file)(SOURCE, imgsz=32) @pytest.mark.skipif(not TORCH_1_13, reason="OpenVINO requires torch>=1.13") def test_export_openvino(): @@ -207,16 +221,4 @@ def test_export_ncnn(): YOLO(file)(SOURCE, imgsz=32) # exported model inference -@pytest.mark.skipif(not LINUX or MACOS, reason="Skipping test on Windows and Macos") -def test_export_imx500_ptq(): - """Test YOLOv8n exports to imx500 format.""" - model = YOLO("yolov8n.pt") - file = model.export(format="imx500", imgsz=32, gptq=False) - YOLO(file)(SOURCE, imgsz=32) - -@pytest.mark.skipif(IS_RASPBERRYPI or not LINUX or MACOS, reason="Skipping test on Raspberry Pi and Windows") -def test_export_imx500_gptq(): - """Test YOLOv8n exports to imx500 format with gptq.""" - model = YOLO("yolov8n.pt") - file = model.export(format="imx500", imgsz=32, gptq=True) - YOLO(file)(SOURCE, imgsz=32) + diff --git a/ultralytics/engine/exporter.py b/ultralytics/engine/exporter.py index 62a9f201c7..7ea8d3011c 100644 --- a/ultralytics/engine/exporter.py +++ b/ultralytics/engine/exporter.py @@ -1123,10 +1123,8 @@ class Exporter: try: subprocess.run(["java", "--version"], check=True) - except OSError: - raise OSError( - "Java 17 is required for the imx500 conversion. \n Please install Java with: \n sudo apt install openjdk-17-jdk openjdk-17-jre" - ) + except FileNotFoundError: + subprocess.run(["apt", "install", "-y", "openjdk-17-jdk", "openjdk-17-jre"], check=True) def representative_dataset_gen(dataloader=self.get_int8_calibration_dataloader(prefix)): for batch in dataloader: