diStyApps / Safe-and-Stable-Ckpt2Safetensors-Conversion-Tool-GUI

Convert your Stable Diffusion checkpoints quickly and easily.
MIT License
438 stars 40 forks source link

Error: No module named 'pytorch_lightning' #2

Closed Oricul closed 1 year ago

Oricul commented 2 years ago

Current Behavior:

Converting Anything-V3.0-pruned.ckpt, or CandyMissionBerryF222-hassan.ckpt, to safetensors fails with the below error:

Converting H:/ai/models/Stable-diffusion\Anything-V3.0-pruned.ckpt to safetensors. Saving H:/ai/models/Stable-diffusion\Anything-V3.0-pruned.safetensors. FILE NOT SUPPORTED Error: No module named 'pytorch_lightning'

Converting H:/ai/models/Stable-diffusion\CandyMissionBerryF222-hassan.ckpt to safetensors. Saving H:/ai/models/Stable-diffusion\CandyMissionBerryF222-hassan.safetensors. FILE NOT SUPPORTED Error: No module named 'pytorch_lightning'

Expected Behavior:

Ckpt should be converted to safetensors.

Steps To Reproduce:

  1. Open run_app_gui.exe.
  2. Point file dialog at either of the ckpts.
  3. Click Convert.
  4. Error upon conversion start.

Environment:

Anything else:

https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/4930#issue-1457942551

Use torch.load(..., weight_only=True) (torch 1.13.0 only). But this will fail on the original checkpoint since it uses some real pickled class (pytorch_lightning). There is no way to load those file securely with PyTorch in that format afaik.

67372a commented 2 years ago

Same issue, I attempted adding the missing modules to the app folder, which I kept doing step by step as new missing module errors appeared, until I hit the following:

Error: No module named '_overlapped'

It seems like there are missing dependencies that need to be bundled with the release for Windows.

Windows 10 Pro 22H2, Build 19045.2251 Python 3.10.6 (64-bit)

67372a commented 2 years ago

Ah, looks like this targets python 3.7, as per the conda.yaml.

67372a commented 2 years ago

The following works for me:

  1. Install Anaconda
  2. Clone repo locally
  3. Import env using conda.yaml in repo
  4. Using Anaconda prompt, activate the env (note, all of the following is assuming the env is activate and commands are run in its active prompt)
  5. cd to the repo directory
  6. Run pip -r requirements.txt in the repo directory
  7. pytorch_lightning is still not included, as such run pip install pytorch_lightning
  8. Finally, python ./run_app_gui.py to start the GUI

After this, I was able to successfully convert a ckpt to st, still need to test the result.

67372a commented 2 years ago

Results seem fine testing with Anything v3 pruned fp16.

diStyApps commented 1 year ago

Thank you, Yes i was aware of that. i just had some issues compiling pytorch_lightning with pyinstaller on other project. But its working fine now. i will requirements file.