Hi guys. I need help with a problem (summarized below). Basically, I tried to create 2 custom templates (one in yolov5s and one in yolov8n) based on Luiz_doleron’s tutorials (Run custom YOLOv8 Model on RPI5 with Hailo AI Shield - #6 by Luiz_doleron - General - Hailo Community) . Both have a problem where the execution of my python script informs me that it couldn’t locate the correct directory for my files.
Regarding my script, the idea is to use a custom model that contains a single class (‘minerio’). With the Degirum library, I’m performing class count tests within a space. Here’s a question: as I’m using a raspberry pi 5 with AI HAT+ Hailo 8, would I be able to trigger any GPIO (I’m thinking of using the ‘lgpio’ library) for external triggers, such as manipulating relays?
In summary, my current script has a control of the FPS of the camera (I had to do it, because it was overloading and crashing my system), and as I mentioned, I’m trying to count classes within a specific region. The desirable thing in the future would be to trigger GPIOs as soon as my ‘minerio’ class accesses the area. Well, let’s get to the problem:
(degirum_env) rasp5@raspberrypi:~/Desktop/degirum_test/yolov8n $ python3 /home/rasp5/hailo_examples/counting_test1.py
Traceback (most recent call last):
File "/home/rasp5/hailo_examples/counting_test1.py", line 42, in <module>
model = dg.load_model(
^^^^^^^^^^^^^^
File "/home/rasp5/hailo_examples/degirum_env/lib/python3.11/site-packages/degirum/__init__.py", line 220, in load_model
return zoo.load_model(model_name, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/rasp5/hailo_examples/degirum_env/lib/python3.11/site-packages/degirum/log.py", line 59, in wrap
return f(*args, **kwargs)
^^^^^^^^^^^^^^^^^^
File "/home/rasp5/hailo_examples/degirum_env/lib/python3.11/site-packages/degirum/zoo_manager.py", line 270, in load_model
model = self._zoo.load_model(model_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/rasp5/hailo_examples/degirum_env/lib/python3.11/site-packages/degirum/log.py", line 59, in wrap
return f(*args, **kwargs)
^^^^^^^^^^^^^^^^^^
File "/home/rasp5/hailo_examples/degirum_env/lib/python3.11/site-packages/degirum/_zoo_accessor.py", line 313, in load_model
model_params = self.model_info(model)
^^^^^^^^^^^^^^^^^^^^^^
File "/home/rasp5/hailo_examples/degirum_env/lib/python3.11/site-packages/degirum/log.py", line 59, in wrap
return f(*args, **kwargs)
^^^^^^^^^^^^^^^^^^
File "/home/rasp5/hailo_examples/degirum_env/lib/python3.11/site-packages/degirum/_zoo_accessor.py", line 131, in model_info
raise DegirumException(
degirum.exceptions.DegirumException: Model 'yolov8n' is not found in model zoo '/home/rasp5/Desktop/degirum_test'
(degirum_env) rasp5@raspberrypi:~/Desktop/degirum_test/yolov8n $
Using default settings such as:
zoo_url = “degirum/hailo”
model_name = ‘yolov8n_relu6_coco–640x640_quant_hailort_hailo8_1’
and any “video_source”, my script runs without any problems. When targeting my ‘zoo_url’ and my ‘model_name’, I get an error. In this case, I’m going to talk about yolov8n.
My script /home/rasp5/hailo_examples/counting_test1.py:
import degirum as dg, degirum_tools
import cv2
import time
inference_host_address = "@local"
#URLS----------------------------------------------------
zoo_url = "/home/rasp5/Desktop/degirum_test" #my models samples
#zoo_url = "degirum/hailo"
token = ''
device_type = "HAILORT/HAILO8"
#MODELS--------------------------------------------------
model_name = 'yolov8n'
#model_name = 'yolov5s_600'
#model_name = 'yolov8n_relu6_coco--640x640_quant_hailort_hailo8_1'
#VIDEO SOURCE--------------------------------------------
video_source = 0 # Para usar a câmera USB
#video_source = '/home/rasp5/Desktop/video_test2.mp4'
#video_source = "/home/rasp5/DeGirum_hailo_examples/assets/Traffic.mp4"
# ZONES--------------------------------------------------
polygon_zones = [
[[90, 200], [540, 200], [540, 400], [90, 400]],
#[[90, 200], [540, 200], [540, 400], [90, 400]], #if wish more zones
]
# class config
class_list = ["minerio"]
#class_list = ["car"]
per_class_display = True
window_name = "AI Camera"
# FPS control
desired_fps = 60 # <---
frame_delay = 1 / desired_fps
# load model
model = dg.load_model(
model_name=model_name,
inference_host_address=inference_host_address,
zoo_url=zoo_url,
token=token,
overlay_color=[(0, 255, 255)],
output_class_set=set(class_list)
)
# zone counter
zone_counter = degirum_tools.ZoneCounter(
polygon_zones,
class_list=class_list,
per_class_display=per_class_display,
triggering_position=degirum_tools.AnchorPoint.CENTER,
window_name=window_name,
)
degirum_tools.attach_analyzers(model, [zone_counter])
cap = cv2.VideoCapture(video_source)
if not cap.isOpened():
raise RuntimeError(f"Erro ao abrir fonte de vídeo: {video_source}")
# show results
with degirum_tools.Display(window_name) as display:
while True:
ret, frame = cap.read()
if not ret:
break
start_time = time.time()
inference_result = model.predict(frame)
display.show(inference_result)
elapsed_time = time.time() - start_time
sleep_time = frame_delay - elapsed_time
if sleep_time > 0:
time.sleep(sleep_time)
cap.release()
cv2.destroyAllWindows()
At /home/rasp5/Desktop/degirum_test/yolov8n i have it:
yolov8n.hef;
yolov8n.json:
{
"ConfigVersion": 10,
"DEVICE": [
{
"DeviceType": "HAILO8",
"RuntimeAgent": "HAILORT",
"SupportedDeviceTypes": "HAILORT/HAILO8",
"ThreadPackSize": 6
}
],
"PRE_PROCESS": [
{
"InputN": 1,
"InputH": 640,
"InputW": 640,
"InputC": 3,
"InputQuantEn": true
}
],
"MODEL_PARAMETERS": [
{
"ModelPath": "yolov8n.hef"
}
],
"POST_PROCESS": [
{
"LabelsPath": "yolov8n_minerio.json",
"OutputNumClasses": 2,
"OutputPostprocessType": "DetectionYoloV8"
}
]
}
yolov8n_minerio.json:
{
"detection_threshold": 0.5,
"max_boxes": 200,
"labels": [
"unlabeled",
"minerio"
]
}
Any idea why I’m getting the error? As far as I can tell, the directories and file names are correct. I enforced myself, but I couldn’t proceed from here