Open ivan-uskov opened 4 years ago
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)
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.
This issue stems from the call to the locater here: https://github.com/alyssaq/face_morpher/blob/7a30611cd9d33469e843cec9cfa23ccf819386a8/facemorpher/averager.py#L103
The locator.average_points returns an int32 type as defined here: https://github.com/alyssaq/face_morpher/blob/7a30611cd9d33469e843cec9cfa23ccf819386a8/facemorpher/locator.py#L91-L97
The version of matplotlib uses requires it to be a uint8 when attempting to save the plot - hence the raised exception.
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