Skip to content

face_detector: detect NCHW layout after model compilation#4041

Open
InfoSage05 wants to merge 1 commit into
openvinotoolkit:masterfrom
InfoSage05:fix/nchw-layout-detection
Open

face_detector: detect NCHW layout after model compilation#4041
InfoSage05 wants to merge 1 commit into
openvinotoolkit:masterfrom
InfoSage05:fix/nchw-layout-detection

Conversation

@InfoSage05
Copy link
Copy Markdown

Summary

I have moved NCHW layout detection from model construction to after compilation, ensuring the layout matches the actual compiled model selected by AUTO plugin.

Root Cause

The nchw_layout flag was detected in __init__ using the uncompiled model's input shape. When AUTO plugin is used, the device is not yet known at that point. Different devices (CPU vs GPU) may have different input layout requirements. After deploy() compiles with the chosen device, the actual layout might differ, which is causing incorrect preprocessing.

Solution

Overriding the deploy() function in the FaceDetector file to detect nchw_layout from the compiled_model.inputs[0].shape AFTER compile_model() completes. This ensures the layout detection uses the device-specific shape and not the defined one.

How to Test

# Should work correctly with AUTO on systems with mixed CPU/GPU
python face_recognition_demo.py -d_fd AUTO ...

Move nchw_layout detection from __init__ to deploy() method. This ensures
the layout is determined from the compiled model after the AUTO plugin has
selected the target device, rather than using the uncompiled model's shape
which may differ depending on device selection.

Add necessary imports (logging, AsyncInferQueue) and override deploy() to
access the compiled model for accurate shape introspection.
@workflow-lab
Copy link
Copy Markdown

Can one of the admins verify this patch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants