From 537e723c302a6ef65b4fb20fde2a8546b8bb732a Mon Sep 17 00:00:00 2001 From: Roki Date: Sun, 8 Mar 2026 14:00:06 +0100 Subject: [PATCH] Fix/rknn arcface input format master (#22319) * "fix: correct ArcFace input format for RKNN runner" * ruff format --- frigate/detectors/detection_runners.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/frigate/detectors/detection_runners.py b/frigate/detectors/detection_runners.py index fcbb41e66..36bf24ce1 100644 --- a/frigate/detectors/detection_runners.py +++ b/frigate/detectors/detection_runners.py @@ -529,6 +529,17 @@ class RKNNModelRunner(BaseModelRunner): # Transpose from NCHW to NHWC pixel_data = np.transpose(pixel_data, (0, 2, 3, 1)) rknn_inputs.append(pixel_data) + elif name == "data": + # ArcFace: undo Python normalisation to uint8 [0,255] + # RKNN runtime applies mean=127.5/std=127.5 internally before first layer + face_data = inputs[name] + if len(face_data.shape) == 4 and face_data.shape[1] == 3: + # Transpose from NCHW to NHWC + face_data = np.transpose(face_data, (0, 2, 3, 1)) + face_data = ( + ((face_data + 1.0) * 127.5).clip(0, 255).astype(np.uint8) + ) + rknn_inputs.append(face_data) else: rknn_inputs.append(inputs[name])