opencv / opencv

Open Source Computer Vision Library
https://opencv.org
Apache License 2.0
76.54k stars 55.64k forks source link

Support Global_Pool_2D ops in .tflite model #25613

Closed CNOCycle closed 2 weeks ago

CNOCycle commented 4 weeks ago

Pull Request Readiness Checklist

Merge with extra: https://github.com/opencv/opencv_extra/pull/1180

This PR adds support for GlobalAveragePooling2D and GlobalMaxPool2D on the TFlite backend. When the keep_dims option is enabled, the output is a 2D tensor, necessitating the inclusion of an additional flatten layer. Additionally, the names of these layers have been updated to match the output tensor names generated by generate.py from the opencv_extra repository.

CNOCycle commented 3 weeks ago

@dkurt

Thank you for your comment. However, I'm not sure which case you're concerned about. Could you please provide your expected model architecture for me to verify the correctness.

dkurt commented 2 weeks ago

@CNOCycle, never mind. I misunderstood the fact that Flatten goes after Pooling, not before.

I added minor changes to the code to make it look more unified with other layers. LGTM after tests pass.