mirror of
https://github.com/opencv/opencv.git
synced 2026-07-21 19:33:03 +04:00
d1264cc6ecd6ea2cf63831e2c6864cffe8ee7790
dnn: silence false-positive CPU target warning for New graph engine #29457 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request * [x] I agree to contribute to the project under Apache 2 License. * [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV * [x] The PR is proposed to the proper branch (`5.x`) * [ ] There is a reference to the original bug report and related work No existing OpenCV issue or pull request directly covers this warning. This PR is the original report and fix. * [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Not applicable. This patch changes only diagnostic behavior for an existing CPU no-op path. * [ ] The feature is well documented and sample code can be built with the project CMake Not applicable. This patch adds no feature or public API. ## Summary Suppress a misleading warning emitted when OpenCV 5 New DNN graph engine receives its default CPU target request. `FaceDetectorYN` and `FaceRecognizerSF` call: ```cpp net.setPreferableTarget(DNN_TARGET_CPU); ``` after loading their networks. When New graph engine is active, target switching is not supported. OpenCV therefore currently prints: ```text Targets are not supported by the new graph engine for now ``` However, New graph engine already executes on CPU. The CPU request does not require a target change, is ignored, and inference continues through New graph engine. The warning therefore suggests a failed configuration or fallback to Classic DNN even though neither occurs. ## Change Treat `DNN_TARGET_CPU` as a silent no-op when generic New graph engine is active. ```text New graph engine + CPU target → no target change needed → return unchanged → no warning New graph engine + non-CPU target → target remains unsupported → preserve existing warning → return unchanged ``` ## Behavior before ```text New graph engine active → caller requests CPU → request is ignored → warning emitted → inference continues on New graph engine ``` ## Behavior after ```text New graph engine active → caller requests CPU → request is ignored → no warning → inference continues on New graph engine ``` ## Unchanged behavior * New graph engine selection is unchanged. * Inference execution is unchanged. * CPU remains the effective target for generic New graph engine. * Classic DNN behavior is unchanged. * ONNX Runtime handling is unchanged. * Non-CPU targets continue to emit the existing warning. ## Motivation The current diagnostic is a false positive for the default CPU request. It reports unsupported target selection even though CPU is already the active execution target and inference succeeds through New graph engine. ## Testing * Built OpenCV locally. * Ran relevant DNN tests. * Verified New graph engine still loads and executes affected models. * Verified CPU target requests no longer emit the misleading warning. * Verified non-CPU target requests retain the existing unsupported-target warning.
OpenCV: Open Source Computer Vision Library
Resources
- Homepage: https://opencv.org
- Courses: https://opencv.org/courses
- Docs: https://docs.opencv.org/5.x/
- Q&A forum: https://forum.opencv.org
- previous forum (read only): http://answers.opencv.org
- Issue tracking: https://github.com/opencv/opencv/issues
- Additional OpenCV functionality: https://github.com/opencv/opencv_contrib
- Donate to OpenCV: https://opencv.org/support/
Contributing
Please read the contribution guidelines before starting work on a pull request.
Summary of the guidelines:
- One pull request per issue;
- Choose the right base branch;
- Include tests and documentation;
- Clean up "oops" commits before submitting;
- Follow the coding style guide.
Additional Resources
- Submit your OpenCV-based project for inclusion in Community Friday on opencv.org
- Subscribe to the OpenCV YouTube Channel featuring OpenCV Live, an hour-long streaming show
- Follow OpenCV on LinkedIn for daily posts showing the state-of-the-art in computer vision & AI
- Apply to be an OpenCV Volunteer to help organize events and online campaigns as well as amplify them
- Follow OpenCV on Mastodon in the Fediverse
- Follow OpenCV on Twitter
- OpenCV.ai: Computer Vision and AI development services from the OpenCV team.
Description
Languages
C++
87.6%
C
3.2%
Python
2.9%
CMake
2%
Java
1.5%
Other
2.6%