YingqingHe / Shadow-Removal-via-Generative-Priors

[ACM MM 2021 Oral] Unsupervised Portrait Shadow Removal via Generative Priors
Other
70 stars 11 forks source link

No such file or directory: lpips/weights/v0.1/vgg.pth #4

Open rshiv2 opened 2 years ago

rshiv2 commented 2 years ago

Hi there, ML noob here.

I am trying to run the code in this repository on Google Colab. I have downloaded the two checkpoints provided in your drive and installed all necessary libraries.

Unfortunately, when I run bash run.sh I receive the following error message:

target img path: imgs/9165-006-input.png
Downloading: "https://download.pytorch.org/models/resnet18-5c106cde.pth" to /root/.cache/torch/hub/checkpoints/resnet18-5c106cde.pth
100% 44.7M/44.7M [00:00<00:00, 99.4MB/s]
Setting up Perceptual loss...
Downloading: "https://download.pytorch.org/models/vgg16-397923af.pth" to /root/.cache/torch/hub/checkpoints/vgg16-397923af.pth
100% 528M/528M [00:04<00:00, 132MB/s] 
Loading model from: /content/drive/MyDrive/Shadow-Removal-via-Generative-Priors/lpips/weights/v0.1/vgg.pth
Traceback (most recent call last):
  File "remove_shadow.py", line 379, in <module>
    main(img_path, res_dir, args.device, args)
  File "remove_shadow.py", line 166, in main
    model="net-lin", net="vgg", use_gpu=device.startswith("cuda")
  File "/content/drive/MyDrive/Shadow-Removal-via-Generative-Priors/lpips/__init__.py", line 22, in __init__
    self.model.initialize(model=model, net=net, use_gpu=use_gpu, colorspace=colorspace, spatial=self.spatial, gpu_ids=gpu_ids)
  File "/content/drive/MyDrive/Shadow-Removal-via-Generative-Priors/lpips/dist_model.py", line 73, in initialize
    self.net.load_state_dict(torch.load(model_path, **kw), strict=False)
  File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 699, in load
    with _open_file_like(f, 'rb') as opened_file:
  File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 231, in _open_file_like
    return _open_file(name_or_buffer, mode)
  File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 212, in __init__
    super(_open_file, self).__init__(open(name, mode))
FileNotFoundError: [Errno 2] No such file or directory: '/content/drive/MyDrive/Shadow-Removal-via-Generative-Priors/lpips/weights/v0.1/vgg.pth'

The error is thrown in line 73 of lpips/dist_model.py. The code I ran does download a vgg16 checkpoint file called vgg16-397923af.pth, so I tried hardcoding the path to this file into line 69 of lpips/dist_model.py. No error is thrown after hardcoding this path, but the output of the network after doing so is very strange:

Screen Shot 2022-06-23 at 4 30 29 PM

This presumably means that hardcoding vgg16-397923af.pth into line 73 was incorrect, especially since in your paper, you use a VGG-19 network.

Should I expect the path lpips/weights/v0.1/vgg.pth to exist after I've run bash run.sh? Was I supposed to include it before hand and if so, where do I download it from?

Thanks!

YingqingHe commented 2 years ago

Hi~ You can download the weights.tar.gz from this link and put it inside the project folder, and then run tar -zxvf weights.tar.gz to uncompress it. Then you will see the checkpoint in lpips/weights/v0.1/vgg.pth. This is the checkpoint we use for our experiments. Hope this will help.