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

Is there any way to download the FAN and FAN-D before using them in a script? #92

Closed IAmSuyogJadhav closed 6 years ago

IAmSuyogJadhav commented 6 years ago

When I run

fa = face_alignment.FaceAlignment(face_alignment.LandmarksType._3D, enable_cuda=False, flip_input=False)

, it downloads the models for the first time and takes quite a while. Is there any way I can skip this? Like manually downloading the required files and putting them in a specified folder?

1adrianb commented 6 years ago

Hi @IAmSuyogJadhav,

Yes, you can. Download links: https://www.adrianbulat.com/downloads/python-fan/2DFAN-4.pth.tar https://www.adrianbulat.com/downloads/python-fan/3DFAN-4.pth.tar https://www.adrianbulat.com/downloads/python-fan/depth.pth.tar

You can copy them in your home folder in .face_alignment folder (You can also check your existing installation just to be sure, its hidden by default).

IAmSuyogJadhav commented 6 years ago

Thanks! Got it✌️

Edwardmark commented 6 years ago

@1adrianb sorry, I cannot open the download links you provided, can you upload the models to onedrive or google cloud or something like that?

visonpon commented 5 years ago

it loos like the compressed model has damaged , hope anyone can help, thanks~

ashafaei commented 5 years ago

@visonpon The files are not tar archives. You should open them directly inside PyTorch

import torch
data = torch.load('2DFAN-4.pth.tar')

I don't know why .pth.tar is chosen. It should be .pth.

visonpon commented 5 years ago

thanks~ @ashafaei i haved solved this error as you adviced.

enerai commented 5 years ago

Let me make a conclusion that how we can download the model files in advance and load them. After you use pip install face-alignment install the face-alignment package 1.0.0, the default face-alignment data directory is /root/.face_alignment/data if you are using the root in a docker. In general, you can use cd ~ && pwd to check the detailed user data directory, and the directory where you should put per-trained model files will be [user_data_dir]/.face_alignment/data, i.e., using

cd $(cd ~ && pwd)/.face_alignment/data

to directly access the directory. If the directory does not exist, you can make it by yourself.

The necessary model files are as follows:

https://www.adrianbulat.com/downloads/python-fan/2DFAN-4.pth.tar
https://www.adrianbulat.com/downloads/python-fan/3DFAN-4.pth.tar
https://www.adrianbulat.com/downloads/python-fan/depth.pth.tar
https://www.adrianbulat.com/downloads/python-fan/s3fd_convert.pth
lucasjinreal commented 4 years ago

Sounds good。