Skip to content

Commit 7c1995a

Browse files
committed
examples: hailo: Switch default models for detect and pose demos
Use the hailo_architecture() helper to see which device is attached, and select the appropriate HEF file for the architecture in use. Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
1 parent 19dc6c5 commit 7c1995a

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

examples/hailo/detect.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
import argparse
66

77
import cv2
8-
98
from picamera2 import MappedArray, Picamera2, Preview
10-
from picamera2.devices import Hailo
9+
from picamera2.devices import Hailo, hailo_architecture
1110

1211

1312
def extract_detections(hailo_output, w, h, class_names, threshold=0.5):
@@ -38,14 +37,22 @@ def draw_objects(request):
3837
if __name__ == "__main__":
3938
# Parse command-line arguments.
4039
parser = argparse.ArgumentParser(description="Detection Example")
41-
parser.add_argument("-m", "--model", help="Path for the HEF model.",
42-
default="/usr/share/hailo-models/yolov8s_h8l.hef")
40+
parser.add_argument("-m", "--model", help="Path for the HEF model. "
41+
"Defaults to /usr/share/hailo-models/yolov8s_h8l.hef for H8 devices, "
42+
"and /usr/share/hailo-models/yolov8m_h10.hef for H10 devices.",
43+
default=None)
4344
parser.add_argument("-l", "--labels", default="coco.txt",
4445
help="Path to a text file containing labels.")
4546
parser.add_argument("-s", "--score_thresh", type=float, default=0.5,
4647
help="Score threshold, must be a float between 0 and 1.")
4748
args = parser.parse_args()
4849

50+
if args.model is None:
51+
if hailo_architecture() == 'HAILO10H':
52+
args.model = '/usr/share/hailo-models/yolov8m_h10.hef'
53+
else:
54+
args.model = '/usr/share/hailo-models/yolov8s_h8l.hef'
55+
4956
# Get the Hailo model, the input size it wants, and the size of our preview stream.
5057
with Hailo(args.model) as hailo:
5158
model_h, model_w, _ = hailo.get_input_shape()

examples/hailo/pose.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,24 @@
33
import argparse
44

55
import cv2
6-
from pose_utils import postproc_yolov8_pose
7-
86
from picamera2 import MappedArray, Picamera2, Preview
9-
from picamera2.devices import Hailo
7+
from picamera2.devices import Hailo, hailo_architecture
8+
9+
from pose_utils import postproc_yolov8_pose
1010

1111
parser = argparse.ArgumentParser(description='Pose estimation using Hailo')
12-
parser.add_argument('-m', '--model', help="HEF file path", default="/usr/share/hailo-models/yolov8s_pose_h8l_pi.hef")
12+
parser.add_argument('-m', '--model', help="HEF file path"
13+
"Defaults to /usr/share/hailo-models/yolov8s_pose_h8l_pi.hef for H8 devices, "
14+
"and /usr/share/hailo-models/yolov8s_pose_h10.hef for H10 devices.",
15+
default=None)
1316
args = parser.parse_args()
1417

18+
if args.model is None:
19+
if hailo_architecture() == 'HAILO10H':
20+
args.model = '/usr/share/hailo-models/yolov8s_pose_h10.hef'
21+
else:
22+
args.model = '/usr/share/hailo-models/yolov8s_pose_h8l_pi.hef'
23+
1524
NOSE, L_EYE, R_EYE, L_EAR, R_EAR, L_SHOULDER, R_SHOULDER, L_ELBOW, R_ELBOW, \
1625
L_WRIST, R_WRIST, L_HIP, R_HIP, L_KNEE, R_KNEE, L_ANKLE, R_ANKLE = range(17)
1726

0 commit comments

Comments
 (0)