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.11k stars 1.35k forks source link

AttributeError: 's3fd' object has no attribute 'to' #108

Closed CarinaFo closed 5 years ago

CarinaFo commented 6 years ago

Hello,

great work. I want to use the face-alignment for a study on facial expressions and metacognition at the BCCN Berlin. Unfortunately I encounter the following error AttributeError: 's3fd' object has no attribute 'to' , runing the sfd_detector script (line 45) I have a neuroscience/psychology background, so any help appreciated. Thanks a lot. Carina

1adrianb commented 6 years ago

Hi @Carinao6, please update your pytorch pacakge to the latest version.

CarinaFo commented 6 years ago

Thanks. Unfortunately now I encounter the following error:

untimeError: Cannot initialize CUDA without ATen_cuda library. PyTorch splits its backend into two shared libraries: a CPU library and a CUDA library; this error has occurred because you are trying to use some CUDA functionality, but the CUDA library has not been loaded by the dynamic linker for some reason. The CUDA library MUST be loaded, EVEN IF you don't directly use any symbols from the CUDA library! One common culprit is a lack of -Wl,--no-as-needed in your link arguments; many dynamic linkers will delete dynamic library dependencies if you don't depend on any of their symbols. You can check if this has occurred by using ldd on your binary to see if there is a dependency on *_cuda.so library.

I installed Cuda package and driver(10.0) for Windows 10 (64).

1adrianb commented 6 years ago

@Carinao6 There seams to be an error with your pytorch package. I remember I had some similar issue a while ago and I had to revert to cuda 9.2.

If this still doesn't fix for now you can try runnign the models on cpu, however this will be slow.

CarinaFo commented 6 years ago

It works using CPU, working on the Cuda issue. Is there a code to show me the placed landmarks on the image (not only the coordinates) and a possibility to manually change the landmarks? I know this is against the idea of machine learning, but might be interesting for our experiment as we want to compare images(facial expressions) and want to calculate the distance between landmarks. Thank you again.

1adrianb commented 6 years ago

Hi @Carinao6,

You can see an example about how to plot them here: https://github.com/1adrianb/face-alignment/blob/master/examples/detect_landmarks_in_image.py

Regarding modifying their position, sure, you can do this. The shape of the returned points is either 68x2 or 68x3, depending on if they are 2D or 3D. You can find a map with the corresponding location of each point here: https://ibug.doc.ic.ac.uk/media/uploads/images/annotpics/figure_68_markup.jpg

CarinaFo commented 6 years ago

Thanks a lot, it all worked. One last thing. Do you have any suggestions regarding images, like what format. I encounter problems using black and white images: ValueError: operands could not be broadcast together with shapes (810,576,4) (3). They are also pretty bad quality and have shadows, guess this is very bad for the detection. Any ideas?

1adrianb commented 6 years ago

I am glad that it worked. It seems that the images also contain an alpha channel which I forgot to handle. I will fix it this week, however in the meantime you can convert the images to jpeg (which will remove the alpha channel).

CarinaFo commented 6 years ago

thanks. It works. One last thing. We would like to adjust certain landmarks manually by clicking on them and replacing them, if we don't like the fit. Any ideas how to implement that?

1adrianb commented 6 years ago

Hi @Carinao6, I am afraid I don't know an easy tool that may achieve this easily. You can maybe however have a look at this: https://matplotlib.org/users/event_handling.html since you could probably achieve this by attaching some event handlers to the points.

CarinaFo commented 6 years ago

Thanks, great idea. I will try if that works.