Skip to content
Snippets Groups Projects
Commit 8472b806 authored by michael.divia's avatar michael.divia
Browse files

1 to rule them all

parent 962ffb8f
No related branches found
No related tags found
No related merge requests found
...@@ -15,9 +15,11 @@ args = parser.parse_args() ...@@ -15,9 +15,11 @@ args = parser.parse_args()
if args.model == "1": if args.model == "1":
hef_path = "../models/ResNet50/pokedex_ResNet50.hef" hef_path = "../models/ResNet50/pokedex_ResNet50.hef"
json_path = "../models/ResNet50/class_names.json" json_path = "../models/ResNet50/class_names.json"
size=(224, 224)
elif args.model == "2": elif args.model == "2":
hef_path = "../models/Xception/pokedex_Xception.hef" hef_path = "../models/Xception/pokedex_Xception.hef"
json_path = "../models/Xception/class_names.json" json_path = "../models/Xception/class_names.json"
size = (256, 256)
else: else:
raise ValueError("Invalid model selection") raise ValueError("Invalid model selection")
...@@ -27,14 +29,13 @@ with open(json_path, "r") as f: ...@@ -27,14 +29,13 @@ with open(json_path, "r") as f:
# --- Inference --- # --- Inference ---
with Hailo(hef_path) as hailo: with Hailo(hef_path) as hailo:
model_h, model_w, _ = hailo.get_input_shape() print(f"-- Hailo model input size: {size}")
print(f"-- Hailo model input size: {model_w}x{model_h}")
picam2 = Picamera2() picam2 = Picamera2()
# Use *raw* capture configuration with correct size # Use *raw* capture configuration with correct size
config = picam2.create_still_configuration( config = picam2.create_still_configuration(
main={"size": (model_w, model_h), "format": "RGB888"}, main={"size": size, "format": "RGB888"},
lores=None, lores=None,
display=None display=None
) )
...@@ -45,10 +46,6 @@ with Hailo(hef_path) as hailo: ...@@ -45,10 +46,6 @@ with Hailo(hef_path) as hailo:
frame = picam2.capture_array() frame = picam2.capture_array()
print(f"-- Captured frame shape: {frame.shape}") print(f"-- Captured frame shape: {frame.shape}")
if frame.shape[0] != model_h or frame.shape[1] != model_w:
print("-- Frame shape doesn't match model input size. Aborting.")
exit(1)
# Optional: display image # Optional: display image
try: try:
cv2.imshow("Captured Image", frame) cv2.imshow("Captured Image", frame)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment