1adrianb / face-alignment

:fire: 2D and 3D Face alignment library build using pytorch
https://www.adrianbulat.com
BSD 3-Clause "New" or "Revised" License
7.05k stars 1.34k forks source link

Cannot pass tensor to get_landmarks_from_image #137

Closed ierezell closed 5 years ago

ierezell commented 5 years ago

In the doc, it's written that we can pass a tensor to the function get_landmarks_from_image.

It's working perfectly fine with numpy.arrays but when trying to pass a tensor (or even a tensor.data) it fails because Tensor has no attribute 'ndim' (l.165) which is uniquely an attribute of numpy.arrays.

It can be fixed with :

if isinstance(img, torch.Tensor) : img = img.detach().cpu().numpy()

which convert back the tensor to a numpy array

1adrianb commented 5 years ago

Thanks for report this!