Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image RGB array must be uint8 or floating point; found int32 #61

Open
ivan-uskov opened this issue Mar 27, 2020 · 3 comments
Open

Image RGB array must be uint8 or floating point; found int32 #61

ivan-uskov opened this issue Mar 27, 2020 · 3 comments

Comments

@ivan-uskov
Copy link

When using background=average, got this:

root@bfa4a21e5b8e:/app# python face_morpher/facemorpher/averager.py --work=/app/work/tmp/avg --out=work/result/1.png --background=average
<class 'numpy.ndarray'>
Averaged 3 work
Image RGB array must be uint8 or floating point; found int32

@Guml
Copy link

Guml commented Apr 16, 2020

change

plt = plotter.Plotter(plot, num_images=1, out_filename=out_filename)
plt.save(dest_img)

to:
plt = plotter.Plotter(plot, num_images=1, out_filename=out_filename)
dest_img = dest_img.astype(np.uint8)
plt.save(dest_img)

from:
https://stackoverflow.com/questions/42044259/getting-black-plots-with-plt-imshow-after-multiplying-image-array-by-a-scalar

@nchlis
Copy link

nchlis commented Jul 27, 2020

Guml's answer above works.
Just don't forget to add "import numpy as np" in averager.py since it is not included by default.

@JonBoyleCoding
Copy link

JonBoyleCoding commented Jun 25, 2021

This issue stems from the call to the locater here:

average_background = locator.average_points(images)

The locator.average_points returns an int32 type as defined here:

def average_points(point_set):
""" Averages a set of face points from images
:param point_set: *n* x *m* x 2 array of face points. \\
*n* = number of images. *m* = number of face points per image
"""
return np.mean(point_set, 0).astype(np.int32)

The version of matplotlib uses requires it to be a uint8 when attempting to save the plot - hence the raised exception.

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

No branches or pull requests

4 participants