Skip to content

Fix NumPy casting error in blur_blending_cv2 function#305

Open
sayedgamal99 wants to merge 2 commits intomicrosoft:masterfrom
sayedgamal99:fix-blur-blending-cv2
Open

Fix NumPy casting error in blur_blending_cv2 function#305
sayedgamal99 wants to merge 2 commits intomicrosoft:masterfrom
sayedgamal99:fix-blur-blending-cv2

Conversation

@sayedgamal99
Copy link

Description

This PR fixes a NumPy casting error in the blur_blending_cv2 function in the Face_Detection module. The error occurs when multiplying a mask (likely of type uint8) by 255.0, resulting in a casting error:

numpy.core._exceptions._UFuncOutputCastingError: Cannot cast ufunc 'multiply' output from dtype('float64') to dtype('uint8') with casting rule 'same_kind'

Changes

  • Modified the blur_blending_cv2 function to convert the mask to float64 before multiplication
  • This allows the multiplication to happen without overflow issues
  • The result is then properly scaled back for further processing

Testing

The fix has been tested on various images and resolves the casting error that was occurring

Follow Up

Also Fixed the same function in the HR file simply.

@sayedgamal99
Copy link
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant