matthewearl / faceswap

Python script to put facial features from one face onto another
MIT License
1.4k stars 496 forks source link

Cannot cast ufunc add output from dtype('int32') to dtype('uint8') with casting rule 'same_kind' #5

Closed svezina closed 8 years ago

svezina commented 8 years ago

Hi Matthew,

Great piece of code. Thanks for putting this together from the Switching Eds blog post.

On line 197 inside correct_colours(), the following error happens on a x64 Windows 10 machine with Python 2.7.11:

im2_blur += 128 * (im2_blur <= 1.0) TypeError: Cannot cast ufunc add output from dtype('int32') to dtype('uint8') with casting rule 'same_kind'

Cheers

matthewearl commented 8 years ago

Hi, I cannot reproduce the issue easily (my windows machine isn't set up for Python development). Can you check if changing the failing line to the following fixes the issue?

im2_blur += (128 * (im2_blur <= 1.0)).astype(im2_blur.dtype)
svezina commented 8 years ago

Yep, that did it. I just sent you a PR. Thanks a lot

matthewearl commented 8 years ago

Thanks for the PR, now merged.