lllyasviel / stable-diffusion-webui-forge

GNU Affero General Public License v3.0
7.72k stars 741 forks source link

[Bug]: No GFPGAN, and CodeFormer always corrupted and re-downloading #737

Closed mr-september closed 5 days ago

mr-september commented 4 months ago

Checklist

What happened?

If using GFPGan:

WARNING:modules.face_restoration_utils:Unable to load face-restoration model
Traceback (most recent call last):
  File "E:\stable-diffusion-webui-forge\modules\face_restoration_utils.py", line 151, in restore_with_helper
    self.net = self.load_net()
  File "E:\stable-diffusion-webui-forge\modules\gfpgan_model.py", line 46, in load_net
    raise ValueError("No GFPGAN model found")
ValueError: No GFPGAN model found

If using CodeFormers:

Downloading: "https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/codeformer.pth" to E:\stable-diffusion-webui-forge\models\Codeformer\codeformer-v0.1.0.pth

100%|███████████████████████████████████████████████████████████████████████████████████████| 359M/359M [01:01<00:00, 6.16MB/s]
WARNING:modules.face_restoration_utils:Unable to load face-restoration model

Also, checking the local Codeformer folder, it is permanently codeformer-v0.1.0.pth.corrupted, even if I am 100% sure it is not (it works fine if copied to A1111 install on the same machine.

Steps to reproduce the problem

  1. Extras
  2. GFPGAN and/or Codeformer

What should have happened?

  1. Find/download the model only if it doesn't exist.
  2. Use the model.
  3. Do not rename it as "corrupted".

What browsers do you use to access the UI ?

Google Chrome

Sysinfo

sysinfo-2024-05-14-04-22.json

Console logs

venv "E:\stable-diffusion-webui-forge\venv\Scripts\Python.exe"
Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]
Version: f0.0.17v1.8.0rc-latest-276-g29be1da7
Commit hash: 29be1da7cf2b5dccfc70fbdd33eb35c56a31ffb7
Launching Web UI with arguments: --directml --skip-torch-cuda-test --ckpt-dir E:stable-diffusion-webui-directml/models/Stable-diffusion --hypernetwork-dir E:stable-diffusion-webui-directml/models/hypernetworks --embeddings-dir E:stable-diffusion-webui-directml/embeddings --lora-dir E:stable-diffusion-webui-directml/models/Lora
Using directml with device:
Total VRAM 1024 MB, total RAM 32688 MB
Trying to enable lowvram mode because your GPU seems to have 4GB or less. If you don't want this use: --always-normal-vram
Set vram state to: LOW_VRAM
Device: privateuseone
VAE dtype: torch.float32
CUDA Stream Activated:  False
Warning: caught exception 'Torch not compiled with CUDA enabled', memory monitor disabled
Using sub quadratic optimization for cross attention, if you have memory or speed issues try using: --attention-split
==============================================================================
You are running torch 2.0.0+cpu.
The program is tested to work with torch 2.1.2.
To reinstall the desired version, run with commandline flag --reinstall-torch.
Beware that this will cause a lot of large files to be downloaded, as well as
there are reports of issues with training tab on the latest version.

Use --skip-version-check commandline argument to disable this check.
==============================================================================
ControlNet preprocessor location: E:\stable-diffusion-webui-forge\models\ControlNetPreprocessor
14:02:17 - ReActor - STATUS - Running v0.7.0-b7 on Device: CPU
Loading weights [859d329490] from E:\stable-diffusion-webui-forge\models\Stable-diffusion\picxReal_10Inpaint.safetensors
2024-05-14 14:02:18,310 - ControlNet - INFO - ControlNet UI callback registered.
model_type EPS
UNet ADM Dimension 0
Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
Startup time: 16.6s (prepare environment: 3.8s, import torch: 4.6s, import gradio: 1.1s, setup paths: 1.1s, initialize shared: 0.1s, other imports: 0.7s, load scripts: 3.9s, create ui: 0.8s, gradio launch: 0.4s).
Using split attention in VAE
Working with z of shape (1, 4, 32, 32) = 4096 dimensions.
Using split attention in VAE
extra {'cond_stage_model.clip_l.logit_scale', 'cond_stage_model.clip_l.text_projection'}
left over keys: dict_keys(['alphas_cumprod', 'alphas_cumprod_prev', 'betas', 'log_one_minus_alphas_cumprod', 'posterior_log_variance_clipped', 'posterior_mean_coef1', 'posterior_mean_coef2', 'posterior_variance', 'sqrt_alphas_cumprod', 'sqrt_one_minus_alphas_cumprod', 'sqrt_recip_alphas_cumprod', 'sqrt_recipm1_alphas_cumprod'])
To load target model SD1ClipModel
Begin to load 1 model
Moving model(s) has taken 0.00 seconds
Model loaded in 3.5s (load weights from disk: 0.4s, forge load real models: 1.7s, load VAE: 0.3s, calculate empty prompt: 1.2s).
WARNING:modules.face_restoration_utils:Unable to load face-restoration model
Traceback (most recent call last):
  File "E:\stable-diffusion-webui-forge\modules\face_restoration_utils.py", line 151, in restore_with_helper
    self.net = self.load_net()
  File "E:\stable-diffusion-webui-forge\modules\gfpgan_model.py", line 46, in load_net
    raise ValueError("No GFPGAN model found")
ValueError: No GFPGAN model found
Downloading: "https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/codeformer.pth" to E:\stable-diffusion-webui-forge\models\Codeformer\codeformer-v0.1.0.pth

100%|███████████████████████████████████████████████████████████████████████████████████████| 359M/359M [01:01<00:00, 6.16MB/s]
WARNING:modules.face_restoration_utils:Unable to load face-restoration model
Traceback (most recent call last):
  File "E:\stable-diffusion-webui-forge\modules_forge\patch_basic.py", line 17, in loader
    result = original_loader(*args, **kwargs)
  File "E:\stable-diffusion-webui-forge\venv\lib\site-packages\torch\serialization.py", line 809, in load
    return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
  File "E:\stable-diffusion-webui-forge\venv\lib\site-packages\torch\serialization.py", line 1172, in _load
    result = unpickler.load()
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\pickle.py", line 1213, in load
    dispatch[key[0]](self)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\pickle.py", line 1254, in load_binpersid
    self.append(self.persistent_load(pid))
  File "E:\stable-diffusion-webui-forge\venv\lib\site-packages\torch\serialization.py", line 1142, in persistent_load
    typed_storage = load_tensor(dtype, nbytes, key, _maybe_decode_ascii(location))
  File "E:\stable-diffusion-webui-forge\venv\lib\site-packages\torch\serialization.py", line 1116, in load_tensor
    wrap_storage=restore_location(storage, location),
  File "E:\stable-diffusion-webui-forge\venv\lib\site-packages\torch\serialization.py", line 1086, in restore_location
    return default_restore_location(storage, str(map_location))
  File "E:\stable-diffusion-webui-forge\venv\lib\site-packages\torch\serialization.py", line 220, in default_restore_location
    raise RuntimeError("don't know how to restore data location of "
RuntimeError: don't know how to restore data location of torch.storage.UntypedStorage (tagged with privateuseone:0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "E:\stable-diffusion-webui-forge\modules\face_restoration_utils.py", line 151, in restore_with_helper
    self.net = self.load_net()
  File "E:\stable-diffusion-webui-forge\modules\codeformer_model.py", line 37, in load_net
    return modelloader.load_spandrel_model(
  File "E:\stable-diffusion-webui-forge\modules\modelloader.py", line 150, in load_spandrel_model
    model_descriptor = spandrel.ModelLoader(device=device).load_from_file(str(path))
  File "E:\stable-diffusion-webui-forge\venv\lib\site-packages\spandrel\__helpers\loader.py", line 41, in load_from_file
    state_dict = self.load_state_dict_from_file(path)
  File "E:\stable-diffusion-webui-forge\venv\lib\site-packages\spandrel\__helpers\loader.py", line 60, in load_state_dict_from_file
    state_dict = self._load_pth(path)
  File "E:\stable-diffusion-webui-forge\venv\lib\site-packages\spandrel\__helpers\loader.py", line 82, in _load_pth
    return torch.load(
  File "E:\stable-diffusion-webui-forge\modules_forge\patch_basic.py", line 33, in loader
    raise ValueError(exp)
ValueError: don't know how to restore data location of torch.storage.UntypedStorage (tagged with privateuseone:0)
File corrupted: E:\stable-diffusion-webui-forge\models\Codeformer\codeformer-v0.1.0.pth
Forge has tried to move the corrupted file to E:\stable-diffusion-webui-forge\models\Codeformer\codeformer-v0.1.0.pth.corrupted
You may try again now and Forge will download models again.


### Additional information

This might be related to the recent AMD/intel GPU incompatibility with Codeformer and GFPGAN.
https://github.com/lshqqytiger/stable-diffusion-webui-amdgpu/issues/423

Adding CPU may argument may help.
https://github.com/lllyasviel/stable-diffusion-webui-forge/issues/565