face_detector: detect NCHW layout after model compilation#4041
Open
InfoSage05 wants to merge 1 commit into
Open
face_detector: detect NCHW layout after model compilation#4041InfoSage05 wants to merge 1 commit into
InfoSage05 wants to merge 1 commit into
Conversation
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.
|
Can one of the admins verify this patch? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_layoutflag 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. Afterdeploy()compiles with the chosen device, the actual layout might differ, which is causing incorrect preprocessing.Solution
Overriding the
deploy()function in theFaceDetectorfile to detectnchw_layoutfrom thecompiled_model.inputs[0].shapeAFTERcompile_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 ...