1adrianb / face-alignment

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

Error: can't convert cuda:0 device type tensor to numpy. #292

Open GaryGky opened 2 years ago

GaryGky commented 2 years ago

image

When I try to predict landmarks with method: get_landmarks(), in line 126, we have a numpy array, but in line 138, we have a tensor default to locate in cuda:0 if GPU is available. But in line 142, we try to calculate a tensor on cuda and numpy array. So I got the problem: "can't convert cuda:0 device type tensor to numpy."

I wonder if this is a bug or I use the api in a wrong way.

MZHI commented 2 years ago

Hi! I think it is not a bug, because the description for method 'crop' from https://github.com/1adrianb/face-alignment/blob/master/face_alignment/utils.py says that image and center must be of type np.array. So, just create center of type np.array instead of torch.tensor