From b34ee7a69c26d11bcf7ec3a10f69ed627aefd772 Mon Sep 17 00:00:00 2001 From: "michael.divia" <michael.divia@etu.hesge.ch> Date: Wed, 9 Apr 2025 21:36:04 +0200 Subject: [PATCH] ? --- python/pokedex_rpi.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/python/pokedex_rpi.py b/python/pokedex_rpi.py index 7454e9a..cc31896 100644 --- a/python/pokedex_rpi.py +++ b/python/pokedex_rpi.py @@ -55,12 +55,12 @@ with Hailo(hef_path) as hailo: output_path = "/tmp/captured.png" cv2.imwrite(output_path, frame) os.system(f"feh --fullscreen {output_path}") + + # --- Preprocess image --- + image = frame.astype(np.float32) / 255.0 # Normalize to [0, 1] + image = np.expand_dims(image, axis=0) # Add batch dimension + image = np.transpose(image, (0, 3, 1, 2)) # NHWC ? NCHW if required (check your model) - # --- Preprocess (normalize + layout + batch) --- - image = frame.astype(np.float32) # Convert to float32 - image -= [123.68, 116.779, 103.939] # Subtract ImageNet mean - image = np.transpose(image, (2, 0, 1)) # HWC → CHW - image = np.expand_dims(image, axis=0) # Add batch dimension print("-- Running inference...") inference_results = hailo.run(image) -- GitLab