1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-21 19:33:03 +04:00
Scott d1264cc6ec Merge pull request #29457 from Scott-Nx:fix/objdetect-new-dnn-target
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.
2026-07-07 11:32:25 +03:00
2026-05-25 17:49:25 +03:00
2026-06-22 20:38:16 -04:00
2026-06-22 20:38:16 -04:00
2026-06-22 20:38:16 -04:00
2018-10-11 17:57:51 +00:00
2025-08-07 10:35:20 +03:00
2024-04-02 16:39:54 +03:00

OpenCV: Open Source Computer Vision Library

Resources

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

S
Description
No description provided
Readme Apache-2.0 3.3 GiB
Languages
C++ 87.6%
C 3.2%
Python 2.9%
CMake 2%
Java 1.5%
Other 2.6%