User Guide 3: Simplifying Object Detection on a Hailo Device Using DeGirum PySDK

i added "Checksum": "", and my errror:

(degirum_env) RPiAI@Loitran:~/workspace/hailo_examples/py_hailo8l $ python test_detection.py 
Traceback (most recent call last):
  File "/home/RPiAI/workspace/hailo_examples/py_hailo8l/test_detection.py", line 4, in <module>
    model = dg.load_model(
            ^^^^^^^^^^^^^^
  File "/home/RPiAI/workspace/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/RPiAI/workspace/hailo_examples/degirum_env/lib/python3.11/site-packages/degirum/log.py", line 59, in wrap
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "/home/RPiAI/workspace/hailo_examples/degirum_env/lib/python3.11/site-packages/degirum/zoo_manager.py", line 266, in load_model
    model = self._zoo.load_model(model_name)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/RPiAI/workspace/hailo_examples/degirum_env/lib/python3.11/site-packages/degirum/log.py", line 59, in wrap
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "/home/RPiAI/workspace/hailo_examples/degirum_env/lib/python3.11/site-packages/degirum/_zoo_accessor.py", line 623, in load_model
    assets = self._get_model_assets(model, True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/RPiAI/workspace/hailo_examples/degirum_env/lib/python3.11/site-packages/degirum/_zoo_accessor.py", line 576, in _get_model_assets
    model_info = self._cloud_server_request(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/RPiAI/workspace/hailo_examples/degirum_env/lib/python3.11/site-packages/degirum/log.py", line 59, in wrap
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "/home/RPiAI/workspace/hailo_examples/degirum_env/lib/python3.11/site-packages/degirum/_zoo_accessor.py", line 494, in _cloud_server_request
    raise DegirumException(details) from None
degirum.exceptions.DegirumException: 404 Client Error: Not Found for url: https://hub.degirum.com/zoo/v1/public/models/home/RPiAI/workspace/hailo_examples/pySDK/my_models/yolov11m/info
(degirum_env) RPiAI@Loitran:~/workspace/hailo_examples/py_hailo8l $ 

my JSON file:

{
    "ConfigVersion": 10,
    "Checksum": "",
    "DEVICE": [
        {
            "DeviceType": "HAILO8L",
            "RuntimeAgent": "HAILORT",
            "SupportedDeviceTypes": "HAILORT/HAILO8L"
        }
    ],
    "PRE_PROCESS": [
        {
            "InputType": "Image",
            "InputN": 1,
            "InputH": 640,
            "InputW": 640,
            "InputC": 3,
            "InputPadMethod": "letterbox",
            "InputResizeMethod": "bilinear",                
            "InputQuantEn": true
        }
    ],
    "MODEL_PARAMETERS": [
        {
            "ModelPath": "yolov11m.hef"
        }
    ],
    "POST_PROCESS": [
        {
            "OutputPostprocessType": "Detection",
            "PythonFile": "HailoDetectionYolo.py",
            "OutputNumClasses": 80,
            "LabelsPath": "labels_coco.json",
            "OutputConfThreshold": 0.3           
        }
    ]
}

Pls help me! i don’t know is "Checksum": "" or "Checksum": "SOMETHING"

Hi @Loi_Tran
Can you please confirm the contents of this folder? /home/RPiAI/workspace/hailo_examples/pySDK/my_models

Hi @Loi_Tran
Please enter any dummy value for checksum. The actual value does not matter as long as it is not left empty.


Here. Thanks very much!

Thanks @Loi_Tran for sharing this. Please add some dummy value to checksum and try again (do not leave the string empty).

Thanks @shashi for reply!

i was added dummy value to checksum but i get the same error:

(degirum_env) RPiAI@Loitran:~/workspace/hailo_examples/py_hailo8l/my_models $ ls
HailoDetectionYolo.py  labels_coco.json  yolov11m.hef  yolov11m.json
(degirum_env) RPiAI@Loitran:~/workspace/hailo_examples/py_hailo8l/my_models $ cd ..
(degirum_env) RPiAI@Loitran:~/workspace/hailo_examples/py_hailo8l $ python test_detection.py 
Traceback (most recent call last):
  File "/home/RPiAI/workspace/hailo_examples/py_hailo8l/test_detection.py", line 4, in <module>
    model = dg.load_model(
            ^^^^^^^^^^^^^^
  File "/home/RPiAI/workspace/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/RPiAI/workspace/hailo_examples/degirum_env/lib/python3.11/site-packages/degirum/log.py", line 59, in wrap
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "/home/RPiAI/workspace/hailo_examples/degirum_env/lib/python3.11/site-packages/degirum/zoo_manager.py", line 266, in load_model
    model = self._zoo.load_model(model_name)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/RPiAI/workspace/hailo_examples/degirum_env/lib/python3.11/site-packages/degirum/log.py", line 59, in wrap
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "/home/RPiAI/workspace/hailo_examples/degirum_env/lib/python3.11/site-packages/degirum/_zoo_accessor.py", line 623, in load_model
    assets = self._get_model_assets(model, True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/RPiAI/workspace/hailo_examples/degirum_env/lib/python3.11/site-packages/degirum/_zoo_accessor.py", line 576, in _get_model_assets
    model_info = self._cloud_server_request(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/RPiAI/workspace/hailo_examples/degirum_env/lib/python3.11/site-packages/degirum/log.py", line 59, in wrap
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "/home/RPiAI/workspace/hailo_examples/degirum_env/lib/python3.11/site-packages/degirum/_zoo_accessor.py", line 494, in _cloud_server_request
    raise DegirumException(details) from None
degirum.exceptions.DegirumException: 404 Client Error: Not Found for url: https://hub.degirum.com/zoo/v1/public/models/home/RPiAI/workspace/hailo_examples/pySDK/my_models/yolov11m/info
(degirum_env) RPiAI@Loitran:~/workspace/hailo_examples/py_hailo8l $ 

I realy bad english! Thank for your help!

Hi @Loi_Tran
In your code you have model_zoo = '/home/RPiAI/workspace/hailo_examples/pySDK/my_models' but the model files seem to be located at '/home/RPiAI/workspace/hailo_examples/py_hailo8l/my_models'. Hope you can see the difference: pysdk instead of py_hailo8l.

1 Like

Hi @shashi
I just wanted to say a big thank you for taking the time to help me fix that code bug. I was really stuck, and your support made a huge difference. I truly appreciate your patience and your willingness to jump in and assist.

1 Like

By the way, I was thinking of trying this code using a camera instead of an image. Since I’m still new to Python, is there anything I should keep in mind or be careful about? I’d really appreciate any tips!

Hi @Loi_Tran
See our quick start guide on how to use it on video sources (video files, web cameras, rtsp stream): hailo_examples/examples/001_quick_start.ipynb at main · DeGirum/hailo_examples

1 Like

Hi, I have a finetuned Yolov8m model that I compiled to a hef file and i tried running it with Degirum SDK but got an error:

degirum.exceptions.DegirumException: [ERROR]Loading model failed
HailoRT Runtime Agent: Failed to create infer model, status = HAILO_FILE_OPERATION_FAILURE.
hailo_model_context_manager.cpp: 248 [DG::HailoModelContextManager::acquireModel]
When running model 'yolov8m'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/raspberry/Documents/hailo-rpi5-examples/basic_pipelines/detect.py", line 1270, in <module>
    main(args)
  File "/home/raspberry/Documents/hailo-rpi5-examples/basic_pipelines/detect.py", line 876, in main
    det_inf = detection_model(np.expand_dims(frame, 0))
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/raspberry/Documents/hailo-rpi5-examples/venv_hailo_rpi5_examples/lib/python3.11/site-packages/degirum/log.py", line 59, in wrap
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "/home/raspberry/Documents/hailo-rpi5-examples/venv_hailo_rpi5_examples/lib/python3.11/site-packages/degirum/model.py", line 233, in call
    return self.predict(data)
           ^^^^^^^^^^^^^^^^^^
  File "/home/raspberry/Documents/hailo-rpi5-examples/venv_hailo_rpi5_examples/lib/python3.11/site-packages/degirum/log.py", line 59, in wrap
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "/home/raspberry/Documents/hailo-rpi5-examples/venv_hailo_rpi5_examples/lib/python3.11/site-packages/degirum/model.py", line 224, in predict
    res = list(self._predict_impl(source))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/raspberry/Documents/hailo-rpi5-examples/venv_hailo_rpi5_examples/lib/python3.11/site-packages/degirum/model.py", line 1206, in _predict_impl
    raise DegirumException(
degirum.exceptions.DegirumException: Failed to perform model 'yolov8m' inference: [ERROR]Loading model failed
HailoRT Runtime Agent: Failed to create infer model, status = HAILO_FILE_OPERATION_FAILURE.
hailo_model_context_manager.cpp: 248 [DG::HailoModelContextManager::acquireModel]
When running model 'yolov8m'

shortened verion of the code:

detection_model = dg.load_model(
		model_name=args.degirum_model,
		zoo_url='models',
		inference_host_address='@local',
	)

cap = cv2.VideoCapture(0)
ret, frame = cap.read()
det_inf = detection_model(np.expand_dims(frame, 0))

Any ideas of what could the issue be?

HI @JanDev
Is this happening for only this model?

Hi, I’m sorry for the message, I transferred the model using the local network and it got corrupted. Now it’s ok!

1 Like

Hi, sorry to interrupt again.
I was easily able to get the yolo model working, but Im having problems with an implementation of a zero_dce model. I want to enhance the captured image using this model and then feed the enhanced image to the yolo network.

I downloaded the enhanced model from this link (the compiled hef version; Btw I tested out the onnx version without degirum and it works) and wrote a script to test it out:

import degirum as dg
import cv2
import numpy as np

enhancement_model = dg.load_model(
    model_name='zero_dce',
    inference_host_address='@local',
    zoo_url='models',
)
cap = cv2.VideoCapture(0)
if not cap.isOpened():
    print("Error: Unable to open camera")
    exit(1)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 600)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 400)

ret, frame = cap.read()
if not ret or frame is None:
    print("Error: Failed to capture frame")
    cap.release()
    exit(1)

cv2.imwrite("captured_image.jpg", frame)
print("Image saved as 'captured_image.jpg'")

frame_resized = cv2.resize(frame, (600, 400), cv2.INTER_LINEAR)
model_input = frame.astype(np.uint8)
enh_inf = enhancement_model(model_input)
enhanced_frame = enh_inf.image_overlay if hasattr(enh_inf, "image_overlay") else enh_inf.image
cv2.imwrite("enhanced_image.jpg", enhanced_frame)
print("Enhanced image saved as 'enhanced_image.jpg'")
cap.release()

But the saved enhanced image is exactly the same one that was captured before the enhancement (no change). What could be the problem?

Hi @JanDev
This is because the image_overlaymethod for these type of models is not supported. We are preparing an example on how to visualize the output image which we will share shortly.

Thank you very much for your reply. How can I set the batch size to 2? For example, I would like to just add two identical images. I would be very grateful for your answer.“inference_result = model(frame)
results = inference_result.results
box1 = np.array([det[‘bbox’] for det in results], dtype=np.float32)
score1 = np.array([det[‘score’] for det in results], dtype=np.float32)” “model = dg.load_model(
model_name=‘yolov11n_5’,
inference_host_address=‘@local’,
zoo_url=‘/home/zoo_url/yolov11n_5’
)”

Hi @An_ti11
Can you please explain what you mean by batch size of 2 and what adding two identical images means?

Hi, @An_ti11 ,
See my response here: