instruct-pix2pix icon indicating copy to clipboard operation
instruct-pix2pix copied to clipboard

Loading the model consistently fails

Open rwkeane opened this issue 2 years ago • 4 comments

Platform: Windows 10 x64 v22H2 Software: Python 3.8.5 Terminal: Anaconda Powershell Prompt v22.9.0 The system just had windows installed yesterday, so it should be in a very vanilla state

When running command:

(ip2p) PS C:\Users\me\src\instruct-pix2pix> python edit_cli.py --input ..\..\Pictures\input.jpg --output ..\..\Pictures\modded.jpg --edit "turn him into a cyborg"

It receives the following error

Loading model from checkpoints/instruct-pix2pix-00-22000.ckpt
Traceback (most recent call last):
  File "edit_cli.py", line 128, in <module>
    main()
  File "edit_cli.py", line 79, in main
    model = load_model_from_config(config, args.ckpt, args.vae_ckpt)
  File "edit_cli.py", line 41, in load_model_from_config
    pl_sd = torch.load(ckpt, map_location="cpu")
  File "C:\Users\Me\anaconda3\envs\ip2p\lib\site-packages\torch\serialization.py", line 705, in load
    with _open_zipfile_reader(opened_file) as opened_zipfile:
  File "C:\Users\Me\anaconda3\envs\ip2p\lib\site-packages\torch\serialization.py", line 243, in __init__
    super(_open_zipfile_reader, self).__init__(torch._C.PyTorchFileReader(name_or_buffer))
RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory

Similarly, when running the following command: When running command:

(ip2p) PS C:\Users\me\src\instruct-pix2pix> python edit_app.py

It receives the following error

Loading model from checkpoints/instruct-pix2pix-00-22000.ckpt
Traceback (most recent call last):
  File "edit_app.py", line 268, in <module>
    main()
  File "edit_app.py", line 109, in main
    model = load_model_from_config(config, args.ckpt, args.vae_ckpt)
  File "edit_app.py", line 78, in load_model_from_config
    pl_sd = torch.load(ckpt, map_location="cpu")
  File "C:\Users\me\anaconda3\envs\ip2p\lib\site-packages\torch\serialization.py", line 705, in load
    with _open_zipfile_reader(opened_file) as opened_zipfile:
  File "C:\Users\me\anaconda3\envs\ip2p\lib\site-packages\torch\serialization.py", line 243, in __init__
    super(_open_zipfile_reader, self).__init__(torch._C.PyTorchFileReader(name_or_buffer))
RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory

rwkeane avatar Jan 22 '23 09:01 rwkeane

ckpt files are zip files. a partial or corrupted download is a good guess though

brycedrennan avatar Jan 22 '23 09:01 brycedrennan

Corrupted download was my guess so I tried downloading the model via curl twice and had the same result I'm wondering if there is something off in the Windows implementation of curl

Would anyone be willing to create a .torrent of the model?

rwkeane avatar Jan 22 '23 09:01 rwkeane

My guess is also corrupted download.

Where are you download from? Maybe try download via a browser instead of curl? You can access the file here:

https://huggingface.co/timbrooks/instruct-pix2pix/blob/main/instruct-pix2pix-00-22000.ckpt

holynski avatar Jan 22 '23 18:01 holynski

I have been getting errors of all kinds for training the model but when it comes to using the pre-trained model to generate images just make sure all the packages are installed and all the files downloaded by download_checkpoints.sh and download_pretrained_sd.sh are in the right place(alternatively you can download them by yourself by opening them as a text file and following the commands). Also make sure that your version of Conda and torch are compatible

redcartel243 avatar Jan 23 '23 09:01 redcartel243