harlanhong / CVPR2022-DaGAN

Official code for CVPR2022 paper: Depth-Aware Generative Adversarial Network for Talking Head Video Generation
https://harlanhong.github.io/publications/dagan.html
Other
957 stars 125 forks source link

Error No such file or directory: 'depth/models/weights_19/encoder.pth' #40

Closed tikitong closed 1 year ago

tikitong commented 1 year ago

I downloaded the pre-trained weights from the onedrive DaGAN_vox_adv_256.pth.tar and put it in a checkpoints directory. When I run the demo command with --cpu I get the following error:

(dagan) user@Users-MacBook-Air CVPR2022-DaGAN % python demo.py --config config/vox-adv-256.yaml --driving_video ./assets/driving.mp4 --source_image ./assets/leo.jpg --checkpoint ./checkpoints/DaGAN_vox_adv_256.pth.tar --relative --adapt_scale --kp_num 15 --generator DepthAwareGenerator --cpu                 
Traceback (most recent call last):
  File "demo.py", line 165, in <module>
    loaded_dict_enc = torch.load('depth/models/weights_19/encoder.pth')
  File "/Users/user/miniconda3/envs/dagan/lib/python3.7/site-packages/torch/serialization.py", line 594, in load
    with _open_file_like(f, 'rb') as opened_file:
  File "/Users/user/miniconda3/envs/dagan/lib/python3.7/site-packages/torch/serialization.py", line 230, in _open_file_like
    return _open_file(name_or_buffer, mode)
  File "/Users/user/miniconda3/envs/dagan/lib/python3.7/site-packages/torch/serialization.py", line 211, in __init__
    super(_open_file, self).__init__(open(name, mode))
FileNotFoundError: [Errno 2] No such file or directory: 'depth/models/weights_19/encoder.pth'

How can I solve it? Many thanks, great job and good luck for ICLR :) !

harlanhong commented 1 year ago

The path is wrong, you could figure it out by yourself. Just put the .pth file in the right path.

tikitong commented 1 year ago

Yes I have changed the path, thanks. Just to know, where does the base path depth/models/weights_19/encoder.pth come from? Did you use the same weight files as the ones provided in the one drive for the demo?

balumuriraj commented 1 year ago

I am also having the same error. How to fix this issue?

CUDA_VISIBLE_DEVICES=0 python demo.py --config config/vox-adv-256.yaml --driving_video driving.mp4 --source_image input.jpeg --checkpoint Checkpoint/DaGAN_vox_adv_256.pth.tar --relative --adapt_scale --kp_num 15 --generator DepthAwareGenerator --cpu

/Users/user/opt/anaconda3/lib/python3.9/site-packages/torchvision/models/_utils.py:135: UserWarning: Using 'weights' as positional parameter(s) is deprecated since 0.13 and may be removed in the future. Please use keyword parameter(s) instead. warnings.warn( /Users/user/opt/anaconda3/lib/python3.9/site-packages/torchvision/models/_utils.py:223: UserWarning: Arguments other than a weight enum or None for 'weights' are deprecated since 0.13 and may be removed in the future. The current behavior is equivalent to passing weights=None. warnings.warn(msg)

Traceback (most recent call last): File "/Users/user/Workspace/Code/Apps/CVPR2022-DaGAN/demo.py", line 165, in loaded_dict_enc = torch.load('depth/models/weights_19/encoder.pth') File "/Users/user/opt/anaconda3/lib/python3.9/site-packages/torch/serialization.py", line 771, in load with _open_file_like(f, 'rb') as opened_file: File "/Users/user/opt/anaconda3/lib/python3.9/site-packages/torch/serialization.py", line 270, in _open_file_like return _open_file(name_or_buffer, mode) File "/Users/user/opt/anaconda3/lib/python3.9/site-packages/torch/serialization.py", line 251, in init super(_open_file, self).init(open(name, mode)) FileNotFoundError: [Errno 2] No such file or directory: 'depth/models/weights_19/encoder.pth'

tikitong commented 1 year ago

@balumuriraj you need to download the pre-trained checkpoints from the readme. And in the demo.py file:

Replace loaded_dict_enc = torch.load('depth/models/weights_19/encoder.pth') by loaded_dict_enc = torch.load('checkpoints/depth_face_model/encoder.pth')

loaded_dict_dec = torch.load('depth/models/weights_19/depth.pth') with loaded_dict_enc = torch.load('checkpoints/depth_face_model/depth.pth')

balumuriraj commented 1 year ago

Thanks @tikitong . It is working now.