Search code examples
pythonpytorch

Download location of Pytorch


Download fail

I'm running this Python code:

https://github.com/SimonGiebenhain/MonoNPHM/blob/05aafd8e7dbe3168bee7d5f93f47537acb877df3/scripts/preprocessing/run_facer.py#L153

It fails at downloading a file and then throws the following errors:

failed downloading from https://github.com/FacePerceiver/facer/releases/download/models-v1/face_parsing.farl.celebm.main_ema_181500_jit.pt
Traceback (most recent call last):
  File "/home/arisa/MonoNPHM/scripts/preprocessing/run_facer.py", line 212, in <module>
    tyro.cli(main)
  File "/home/arisa/.conda/envs/mononphm/lib/python3.9/site-packages/tyro/_cli.py", line 229, in cli
    return run_with_args_from_cli()
  File "/home/arisa/MonoNPHM/scripts/preprocessing/run_facer.py", line 153, in main
    face_parser = facer.face_parser('farl/celebm/448', device=device)  # optional "farl/lapa/448"
  File "/home/arisa/.conda/envs/mononphm/lib/python3.9/site-packages/facer/__init__.py", line 36, in face_parser
    return FaRLFaceParser(conf_name, device=device, **kwargs).to(device)
  File "/home/arisa/.conda/envs/mononphm/lib/python3.9/site-packages/facer/face_parsing/farl.py", line 69, in __init__
    self.net = download_jit(model_path, map_location=device)
  File "/home/arisa/.conda/envs/mononphm/lib/python3.9/site-packages/facer/util.py", line 162, in download_jit
    return torch.jit.load(cached_file, map_location=map_location, **kwargs)
  File "/home/arisa/.conda/envs/mononphm/lib/python3.9/site-packages/torch/jit/_serialization.py", line 162, in load
    cpp_module = torch._C.import_ir_module(cu, str(f), map_location, _extra_files, _restore_shapes)  # type: ignore[call-arg]
RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory

The corrupt download is the root cause of the last error:

PytorchStreamReader failed reading zip archive: failed finding central directory

RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory

Manual download

I have downloaded the following manually:

https://github.com/FacePerceiver/facer/releases/download/models-v1/face_parsing.farl.celebm.main_ema_181500_jit.pt

But I'm not sure where to place it on the server so that the Python/Pytorch code would use it. Can anyone tell me the download location?


Solution

  • Getting some hints from chat-bots and trying different locations, looks like ~/.cache/torch/hub/checkpoints/ is the location at which the downloads are stored by the code:

    ls ~/.cache/torch/hub/checkpoints/ -1
    
    face_parsing.farl.celebm.main_ema_181500_jit.pt
    mobilenet0.25_Final.pth
    resnet18-f37072fd.pth
    

    The manually downloaded file can be sent to that location on server by:

    scp ~/Downloads/face_parsing.farl.celebm.main_ema_181500_jit.pt arisa@IP.IP.IP.IP:/home/arisa/.cache/torch/hub/checkpoints/