From 7e4416f64f635883826b3f98a6d5db41036c74ff Mon Sep 17 00:00:00 2001 From: Lakshantha Dissanayake Date: Thu, 2 Jan 2025 12:34:35 -0800 Subject: [PATCH] `ultralytics 8.3.57` Support `is_jetson()` and `is_raspberrypi()` in Docker images (#18449) Signed-off-by: Glenn Jocher Co-authored-by: UltralyticsAssistant Co-authored-by: Glenn Jocher Co-authored-by: Ultralytics Assistant <135830346+UltralyticsAssistant@users.noreply.github.com> --- ultralytics/__init__.py | 2 +- ultralytics/utils/__init__.py | 14 +++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/ultralytics/__init__.py b/ultralytics/__init__.py index 4cf03a48..2f8c25be 100644 --- a/ultralytics/__init__.py +++ b/ultralytics/__init__.py @@ -1,6 +1,6 @@ # Ultralytics YOLO 🚀, AGPL-3.0 license -__version__ = "8.3.56" +__version__ = "8.3.57" import os diff --git a/ultralytics/utils/__init__.py b/ultralytics/utils/__init__.py index 126c823a..f5ff78c1 100644 --- a/ultralytics/utils/__init__.py +++ b/ultralytics/utils/__init__.py @@ -524,13 +524,9 @@ def read_device_model() -> str: is_raspberrypi(). Returns: - (str): Model file contents if read successfully or empty string otherwise. + (str): Kernel release information. """ - try: - with open("/proc/device-tree/model") as f: - return f.read() - except Exception: - return "" + return platform.release().lower() def is_ubuntu() -> bool: @@ -602,7 +598,7 @@ def is_raspberrypi() -> bool: Returns: (bool): True if running on a Raspberry Pi, False otherwise. """ - return "Raspberry Pi" in PROC_DEVICE_MODEL + return "rpi" in DEVICE_MODEL def is_jetson() -> bool: @@ -612,7 +608,7 @@ def is_jetson() -> bool: Returns: (bool): True if running on an NVIDIA Jetson device, False otherwise. """ - return any(keyword in PROC_DEVICE_MODEL.lower() for keyword in ("nvidia", "jetson")) + return "tegra" in DEVICE_MODEL def is_online() -> bool: @@ -802,7 +798,7 @@ def get_user_config_dir(sub_dir="Ultralytics"): # Define constants (required below) -PROC_DEVICE_MODEL = read_device_model() # is_jetson() and is_raspberrypi() depend on this constant +DEVICE_MODEL = read_device_model() # is_jetson() and is_raspberrypi() depend on this constant ONLINE = is_online() IS_COLAB = is_colab() IS_KAGGLE = is_kaggle()