Skip to content

Fix yoloPostProcessing to handle variable number of classes (nc)#26618

Merged
asmorkalov merged 1 commit intoopencv:4.xfrom
KangJialiang:fix/yoloPostProcessing-variable-nc
Dec 14, 2024
Merged

Fix yoloPostProcessing to handle variable number of classes (nc)#26618
asmorkalov merged 1 commit intoopencv:4.xfrom
KangJialiang:fix/yoloPostProcessing-variable-nc

Conversation

@KangJialiang
Copy link
Copy Markdown
Contributor

Previously, the yoloPostProcessing function assumed that the number of classes (nc) was fixed at 80. This caused incorrect behavior when a different number of classes was specified, leading to mismatched output shapes.

This update modifies the code to use the provided nc value dynamically, ensuring that the output shapes are correctly calculated based on the specified number of classes. This prevents issues when nc is not equal to 80 and allows for greater flexibility in model configurations.

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • 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
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

Previously, the yoloPostProcessing function assumed that the number of classes (nc) was fixed at 80. This caused incorrect behavior when a different number of classes was specified, leading to mismatched output shapes.

This update modifies the code to use the provided `nc` value dynamically, ensuring that the output shapes are correctly calculated based on the specified number of classes. This prevents issues when `nc` is not equal to 80 and allows for greater flexibility in model configurations.
@asmorkalov asmorkalov self-assigned this Dec 13, 2024
@asmorkalov asmorkalov merged commit 71581d9 into opencv:4.x Dec 14, 2024
@KangJialiang KangJialiang deleted the fix/yoloPostProcessing-variable-nc branch December 16, 2024 12:40
@asmorkalov asmorkalov mentioned this pull request Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants