opencv/modules/dnn
alexlyulkov 9238eb2ab2
Merge pull request #25555 from alexlyulkov:al/int8-uint8-dnn-input
Disabled conversion to float of model's input #25555

In dnn 4.x usually any model's input is converted to float32 or float16 (except quantized models). Also mean and scale can be applied. In current dnn 5.x there is the same conversion except int32 and int64 types. I removed this conversion.

Here is how the pipeline works now:
- if input Mat type is float32, the pipeline applies mean and scale and may convert it to float16.
- if input Mat type is not float32, the pipeline preserves the input type and doesn't apply mean and scale

There was a conflict in protobuf parser between ONNX importer and tests. In ONNX importer any uint8 weight was handled as quantized weight and x = int8(x_uint8 - 128) conversion was used inside the protobuf parser. ONNX conformance tests used the same protobuf reader, so tests with uint8 inputs couldn't read the input values properly. I've made this conversion optional.

These ONNX conformance tests are enabled:
- test_add_uint8
- test_div_uint8
- test_mul_uint8
- test_sub_uint8
- test_max_int8
- test_max_uint8
- test_min_int8
- test_min_uint8
- test_mod_mixed_sign_int8
- test_mod_uint8

These tests were removed:
- Test_two_inputs.basic (when input is uint8)
- setInput.normalization (when input is uint8)

### 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
- [ ] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
2024-05-16 15:54:00 +03:00
..
cmake Add Definition "_USE_MATH_DEFINES" for dnn plugin on Win32 build 2024-04-07 21:08:09 +09:00
include/opencv2 Allowed int64 constants in ONNX parser (#25148) 2024-03-13 11:48:23 +03:00
misc Merge pull request #25463 from WanliZhong:ocvface2YuNet 2024-05-08 15:49:10 +03:00
perf Merge pull request #25463 from WanliZhong:ocvface2YuNet 2024-05-08 15:49:10 +03:00
src Merge pull request #25555 from alexlyulkov:al/int8-uint8-dnn-input 2024-05-16 15:54:00 +03:00
test Merge pull request #25555 from alexlyulkov:al/int8-uint8-dnn-input 2024-05-16 15:54:00 +03:00
CMakeLists.txt Merge branch 4.x 2024-04-02 16:39:54 +03:00