Handling Import and file not found Error for non-arm devices.

This commit is contained in:
yoni13 2025-01-11 15:19:53 +08:00
parent 66004e3b83
commit d10147f478

View File

@ -2,22 +2,24 @@
# Following Apache License 2.0 # Following Apache License 2.0
from queue import Queue from queue import Queue
from rknnlite.api import RKNNLite
from concurrent.futures import ThreadPoolExecutor, as_completed from concurrent.futures import ThreadPoolExecutor, as_completed
supported_socs = ["rk3566","rk3568","rk3588"] supported_socs = ["rk3566","rk3568","rk3588"]
with open('/proc/device-tree/compatible') as f: try:
# Keep in mind that this is not in container by default. from rknn.api import RKNNLite
# and this way of checking can't check if the rknpu driver is running or not. with open('/proc/device-tree/compatible') as f:
device_compatible_str = f.read() # Keep in mind that this is not in container by default.
for soc in supported_socs: # and this way of checking can't check if the rknpu driver is running or not.
if soc in device_compatible_str: device_compatible_str = f.read()
is_available = True for soc in supported_socs:
break if soc in device_compatible_str:
else: is_available = True
is_available = False break
else:
is_available = False
except (FileNotFoundError, ImportError):
is_available = False
def initRKNN(rknnModel="./rknnModel/yolov5s.rknn", id=0): def initRKNN(rknnModel="./rknnModel/yolov5s.rknn", id=0):