@kim_jiseob
Glad to hear that you were able to use our AI hub inference. If possible, we would still like to help you solve the issue with running locally.
Thx @shashi Isnât it possible to calculate the mAP of a custom model only locally? The fact that the value came out of the cloud meant that I just randomly entered the value and checked that it worked.
@kim_jiseob
It is possible to evaluate locally as well. There is definitely some setup issue on your side that we need to debug.
Yes @shashi The problem of not recognizing the model path is the same as commented in Guide 2. Here is my log:
[âyolov8nâ]
dict_keys([âDUMMY/DUMMYâ, âHAILORT/HAILO8Lâ, âN2X/CPUâ, âTFLITE/CPUâ])
There are hef and json files in the directory.
@kim_jiseob
In your case, the model list is not empty as it looks like yolov8n is actually listed as an available model.
When I set the versions of hailort, hailofw, and hailo-dkms to 4.19.0, inference was successful with my custom model. thank you so much @shashi
Hi @kim_jiseob
Amazing. Thanks for letting me know. Please feel free to reach out if you need any further help.
Good afternoon, I encountered the following issues.
All my files are located in the following directory:
HailoDetectionYolo.py
labels_coco.json
yolov11n.hef
yolov11n.json
in this directory:
yolo_check_5/zoo_url/yolov11n
However, when I use the following script:
import degirum as dg
from pprint import pprint
Load the model from the model zoo.
Replace â<path_to_model_zoo>â with the directory containing your model assets.
model = dg.load_model(
model_name=âyolov11nâ,
inference_host_address=â@localâ,
zoo_url=âyolo_check_5/zoo_url/yolov11nâ
)
I get the following error and canât figure out what the problem is:
Traceback (most recent call last):
File âer.pyâ, line 6, in
model = dg.load_model(
^^^^^^^^^^^^^^
File âdegirum_env/lib/python3.11/site-packages/degirum/init.pyâ, line 220, in load_model
return zoo.load_model(model_name, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File âdegirum_env/lib/python3.11/site-packages/degirum/log.pyâ, line 59, in wrap
return f(*args, **kwargs)
^^^^^^^^^^^^^^^^^^
File âdegirum_env/lib/python3.11/site-packages/degirum/zoo_manager.pyâ, line 266, in load_model
model = self._zoo.load_model(model_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File âdegirum_env/lib/python3.11/site-packages/degirum/log.pyâ, line 59, in wrap
return f(*args, **kwargs)
^^^^^^^^^^^^^^^^^^
File âdegirum_env/lib/python3.11/site-packages/degirum/_zoo_accessor.pyâ, line 309, in load_model
model_params = self.model_info(model)
^^^^^^^^^^^^^^^^^^^^^^
File âdegirum_env/lib/python3.11/site-packages/degirum/log.pyâ, line 59, in wrap
return f(*args, **kwargs)
^^^^^^^^^^^^^^^^^^
File âdegirum_env/lib/python3.11/site-packages/degirum/_zoo_accessor.pyâ, line 127, in model_info
raise DegirumException(
degirum.exceptions.DegirumException: Model âyolov11nâ is not found in model zoo âyolo_check_5/zoo_url/yolov11nâ
I have tried many solutions, but I havenât been able to resolve this issue.
Hi @An_ti11
Can you please check the supported devices in model json match the device you have?
i have hailo8l â{
âConfigVersionâ: 10,
â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â: âyolov11n.hefâ
}
],
âPOST_PROCESSâ: [
{
âOutputPostprocessTypeâ: âDetectionâ,
âPythonFileâ: âHailoDetectionYolo.pyâ,
âOutputNumClassesâ: 1,
âLabelsPathâ: âlabels_coco.jsonâ,
âOutputConfThresholdâ: 0.2
}
]
}â it is yolov11n.json
@An_ti11
Please add the below line to your json below the ConfigVersion line:
"Checksum": "d6c4d0b9620dc2e5e215dfab366510a740fe86bf2c5d9bd2059a6ba3fe62ee63",
thanks a lot for help, but now i have such error, i donât undrestand why "import degirum as dg
from pprint import pprint
import cv2
import numpy as np
Initialize the model from the model zoo
model = dg.load_model(
model_name=âyolov11nâ,
inference_host_address=â@localâ,
zoo_url=â/home/anton/yolo_check_5/zoo_url/yolov11nâ
)
def resize_with_letterbox_image(image, target_height, target_width, padding_value=(0, 0, 0)):
image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
h, w, c = image_rgb.shape
scale = min(target_width / w, target_height / h)
new_w = int(w * scale)
new_h = int(h * scale)
resized_image = cv2.resize(image_rgb, (new_w, new_h), interpolation=cv2.INTER_LINEAR)
letterboxed_image = np.full((target_height, target_width, c), padding_value, dtype=np.uint8)
pad_top = (target_height - new_h) // 2
pad_left = (target_width - new_w) // 2
letterboxed_image[pad_top:pad_top+new_h, pad_left:pad_left+new_w] = resized_image
return letterboxed_image, scale, pad_top, pad_left
video_path = âpath/to/your/video.mp4â
cap = cv2.VideoCapture(video_path)
if not cap.isOpened():
print(âError: Could not open video.â)
exit()
target_height, target_width = 640, 640 # Remove batch dimension
while True:
ret, frame = cap.read()
if not ret:
break
processed_frame, scale, pad_top, pad_left = resize_with_letterbox_image(frame, target_height, target_width)
# Perform inference with correctly shaped image (H, W, 3)
inference_result = model(processed_frame)
# Debug output
print(type(inference_result), inference_result)
# If the result is a list, extract the first element
if isinstance(inference_result, list):
inference_result = inference_result[0]
pprint(inference_result.results)
display_frame = cv2.cvtColor(processed_frame, cv2.COLOR_RGB2BGR)
print(f"Scale: {scale:.3f}, Pad top: {pad_top}, Pad left: {pad_left}")
cv2.imshow("Letterboxed Frame", display_frame)
if cv2.waitKey(30) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
"
degirum.exceptions.DegirumException: [ERROR]Operation failed
Python postprocessor: forward: âlistâ object has no attribute âgetâ [AttributeError] in file âHailoDetectionYolo_0335a2b4eba1d2604f54de0e5f844f64.pyâ, function âforwardâ, line 88
dg_postprocess_client.cpp: 1009 [DG::PostprocessClient::forward]
When running model âyolov11nâ
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File â/home/anton/er.pyâ, line 42, in
inference_result = model(processed_frame)
^^^^^^^^^^^^^^^^^^^^^^
File â/home/anton/degirum_env/lib/python3.11/site-packages/degirum/log.pyâ, line 59, in wrap
return f(*args, **kwargs)
^^^^^^^^^^^^^^^^^^
File â/home/anton/degirum_env/lib/python3.11/site-packages/degirum/model.pyâ, line 233, in call
return self.predict(data)
^^^^^^^^^^^^^^^^^^
File â/home/anton/degirum_env/lib/python3.11/site-packages/degirum/log.pyâ, line 59, in wrap
return f(*args, **kwargs)
^^^^^^^^^^^^^^^^^^
File â/home/anton/degirum_env/lib/python3.11/site-packages/degirum/model.pyâ, line 224, in predict
res = list(self._predict_impl(source))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File â/home/anton/degirum_env/lib/python3.11/site-packages/degirum/model.pyâ, line 1206, in _predict_impl
raise DegirumException(
degirum.exceptions.DegirumException: Failed to perform model âyolov11nâ inference: [ERROR]Operation failed
Python postprocessor: forward: âlistâ object has no attribute âgetâ [AttributeError] in file âHailoDetectionYolo_0335a2b4eba1d2604f54de0e5f844f64.pyâ, function âforwardâ, line 88
dg_postprocess_client.cpp: 1009 [DG::PostprocessClient::forward]
When running model âyolov11nâ
sorry maybe i wrote it badly, here the code , and such error "processed_frame, scale, pad_top, pad_left = resize_with_letterbox_image(frame, target_shape)
inference_result = model(processed_frame)
"
"degirum.exceptions.DegirumException: Image array shape â(1, 640, 640, 3)â is not supported for âopencvâ image backend
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File â/home/anton/er.pyâ, line 55, in
inference_result = model(processed_frame)
^^^^^^^^^^^^^^^^^^^^^^
File â/home/anton/degirum_env/lib/python3.11/site-packages/degirum/log.pyâ, line 59, in wrap
return f(*args, **kwargs)
^^^^^^^^^^^^^^^^^^
File â/home/anton/degirum_env/lib/python3.11/site-packages/degirum/model.pyâ, line 233, in call
return self.predict(data)
^^^^^^^^^^^^^^^^^^
File â/home/anton/degirum_env/lib/python3.11/site-packages/degirum/log.pyâ, line 59, in wrap
return f(*args, **kwargs)
^^^^^^^^^^^^^^^^^^
File â/home/anton/degirum_env/lib/python3.11/site-packages/degirum/model.pyâ, line 224, in predict
res = list(self._predict_impl(source))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File â/home/anton/degirum_env/lib/python3.11/site-packages/degirum/model.pyâ, line 1206, in _predict_impl
raise DegirumException(
degirum.exceptions.DegirumException: Failed to perform model âyolov11nâ inference: Image array shape â(1, 640, 640, 3)â is not supported for âopencvâ image backend
"
Hi @An_ti11
If you are following this guide, you do not have to send the processed_frame. You can directly send the image path to inference.
Hello,
Thanks for your work on this guide !
Iâm trying to use DeGirum with a basic yolov8 detection model, however, I have this error when trying to run my python script :
(.venv_hailo) p20c02@p20c02:~/rendu/degirum_tests$ python run_degirum.py
Running inference using 'yolov8m' on image source '/home/p20c02/rendu/COCO/small/000000000139.jpg'
degirum.exceptions.DegirumException: [ERROR]Operation failed
HailoRT Runtime Agent: Failed to create VDevice, status = HAILO_INVALID_OPERATION.
hailo_runtime_agent.cpp: 608 [DG::HailoRuntimeAgentImpl::Configure]
When running model 'yolov8m'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/p20c02/rendu/degirum_tests/run_degirum.py", line 25, in <module>
inference_result = model(image_source)
File "/home/p20c02/.venv_hailo/lib/python3.10/site-packages/degirum/log.py", line 59, in wrap
return f(*args, **kwargs)
File "/home/p20c02/.venv_hailo/lib/python3.10/site-packages/degirum/model.py", line 233, in __call__
return self.predict(data)
File "/home/p20c02/.venv_hailo/lib/python3.10/site-packages/degirum/log.py", line 59, in wrap
return f(*args, **kwargs)
File "/home/p20c02/.venv_hailo/lib/python3.10/site-packages/degirum/model.py", line 224, in predict
res = list(self._predict_impl(source))
File "/home/p20c02/.venv_hailo/lib/python3.10/site-packages/degirum/model.py", line 1206, in _predict_impl
raise DegirumException(
degirum.exceptions.DegirumException: Failed to perform model 'yolov8m' inference: [ERROR]Operation failed
HailoRT Runtime Agent: Failed to create VDevice, status = HAILO_INVALID_OPERATION.
hailo_runtime_agent.cpp: 608 [DG::HailoRuntimeAgentImpl::Configure]
When running model 'yolov8m'
Here is the script :
import degirum as dg
import cv2
from pprint import pprint
inference_host_address = "@local"
zoo_url = 'assets'
token=''
device_type='HAILORT/HAILO8'
# set model name, and image source
model_name = "yolov8m"
image_source='/home/p20c02/rendu/COCO/small/000000000139.jpg'
# load AI model
model = dg.load_model(
model_name=model_name,
inference_host_address=inference_host_address,
zoo_url=zoo_url,
token=token,
device_type=device_type,
)
# perform AI model inference on given image source
print(f" Running inference using '{model_name}' on image source '{image_source}'")
inference_result = model(image_source)
# Pretty print the detection results.
pprint(inference_result.results)
# Display the image with overlayed detection results.
cv2.imshow("AI Inference", inference_result.image_overlay)
cv2.waitKey(0)
cv2.destroyAllWindows() # Close all OpenCV windows.
The json file yolov8m.json (stored in my assets/yolov8m folder with the PostProcessor class, labels_coco.json and yolov8m.hef) :
{
"ConfigVersion": 10,
"Checksum": "d6c4d0b9620dc2e5e215dfab366510a740fe86bf2c5d9bd2059a6ba3fe62ee63",
"DEVICE": [
{
"DeviceType": "HAILO8",
"RuntimeAgent": "HAILORT",
"SupportedDeviceTypes": "HAILORT/HAILO8"
}
],
"PRE_PROCESS": [
{
"InputType": "Image",
"InputN": 1,
"InputH": 640,
"InputW": 640,
"InputC": 3,
"InputPadMethod": "letterbox",
"InputResizeMethod": "bilinear",
"InputQuantEn": true
}
],
"MODEL_PARAMETERS": [
{
"ModelPath": "yolov8m.hef"
}
],
"POST_PROCESS": [
{
"OutputPostprocessType": "Detection",
"PythonFile": "HailoDetectionYolo.py",
"OutputNumClasses": 80,
"LabelsPath": "labels_coco.json",
"OutputConfThreshold": 0.001
}
]
}
Degirum sys info :
(.venv_hailo) p20c02@p20c02:~/rendu/Hailo-Application-Code-Examples-main/runtime/python/object_detection/hef_yolo$ degirum sys-info
Devices:
HAILORT/HAILO8:
- '@Index': 0
Board Name: Hailo-8
Device Architecture: HAILO8
Firmware Version: 4.20.0
ID: '0000:52:00.0'
Part Number: HM218B1C2FAE
Product Name: HAILO-8 AI ACC M.2 M KEY MODULE EXT TEMP
Serial Number: "HLLWM2B223200047\x10HM218B1C2FAE"
N2X/CPU:
- '@Index': 0
- '@Index': 1
- '@Index': 2
- '@Index': 3
- '@Index': 4
- '@Index': 5
- '@Index': 6
- '@Index': 7
TFLITE/CPU:
- '@Index': 0
- '@Index': 1
- '@Index': 2
- '@Index': 3
- '@Index': 4
- '@Index': 5
- '@Index': 6
- '@Index': 7
Software Version: 0.15.3
Have a great day !
Cordially,
@shashi
Hi,
I successfully ran yolov11 and yolov8 pretrained models with the help of above solution. When I am trying to run yolov8 custom model, the inference result is an empty list.
My custom model was prepared from pytorch to onnx to hef.
Please let me know if there is any process or steps to prepare a custom model that works with PySdk for inference.
Hi @manasa
Can you share the model json and the code snippet?
Json file is:
{
âConfigVersionâ: 10,
âChecksumâ: â80752ca746bba42db3056d4b53f6c401bfcf930cf3bd5f82ae66a07a68dfa5ecâ,
â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â: âyolov8m.hefâ
}
],
âPOST_PROCESSâ: [
{
âOutputPostprocessTypeâ: âDetectionâ,
âPythonFileâ: âHailoDetectionYolo.pyâ,
âOutputNumClassesâ: 7,
âLabelsPathâ: âpopcorn.jsonâ,
âOutputConfThresholdâ: 0.3
}
]
}
Inference code is:
import degirum as dg
from pprint import pprint
model = dg.load_model(
model_name=âyolov8mâ,
inference_host_address=â@localâ,
zoo_url=â/home/jk/manasaâ
)
print(âModel Info:â, dir(model))
print(âModel Labels:â, model.output_class_set)
print(âInput Shape:â, model.input_shape)
inference_result = model(â/home/jk/frame_8250.jpgâ)
pprint(inference_result.results)
I followed the above steps whatever you shared. I got for pre-trained model but for custom trained model I got empty set. Can you please help me out for custom trained model?
Hi
Help me!
My error:
(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 5, 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 code:
import degirum as dg
from pprint import pprint
model_zoo = '/home/RPiAI/workspace/hailo_examples/pySDK/my_models'
model = dg.load_model(
model_name='yolov11m',
inference_host_address='@local',
zoo_url=model_zoo
)
inference_result = model('/home/RPiAI/Downloads/Cat.jpg')
pprint(inference_result.results)
my yolov11m.json
:
{
"ConfigVersion": 10,
"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
}
]
}
I use Hailo 8L
I not good English. Plss help me! thanks!
Hi @Loi_Tran
Please add one more line to the JSON below the ConfigVersion line:
"Checksum": "",