diff --git a/python/pokedex_rpi.py b/python/pokedex_rpi.py index 7454e9a44026b2d6c5cd12d4ac7ec55a256b6f62..cc31896de81e93a901c343828590d2961d3e4ebe 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)