Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Error Loading LDSR after installation of model.ckpt #488

Closed
1 task done
darkstorm2150 opened this issue Sep 2, 2022 · 24 comments
Closed
1 task done

[Bug]: Error Loading LDSR after installation of model.ckpt #488

darkstorm2150 opened this issue Sep 2, 2022 · 24 comments
Labels
bug Something isn't working

Comments

@darkstorm2150
Copy link

What happened?

I followed the advice from the discussion, Im unsure if its missing more information for it to be activated.

Error loading LDSR:
Traceback (most recent call last):
File "scripts/webui.py", line 359, in try_loading_LDSR
LDSR = load_LDSR() # TODO: Should try to load both models before giving up
File "scripts/webui.py", line 286, in load_LDSR
from LDSR import LDSR
ModuleNotFoundError: No module named 'LDSR'

Version

0.0.1 (Default)

What browsers are you seeing the problem on?

Firefox

Where are you running the webui?

Windows

Custom settings

No response

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@darkstorm2150 darkstorm2150 added the bug Something isn't working label Sep 2, 2022
@devilismyfriend
Copy link
Contributor

Git clone https://github.com/devilismyfriend/latent-diffusion into your stable-diffusion-main/src/ folder
Rename latent-diffusion-main folder to latent-diffusion
If on windows: run download_models.bat to download the required model files
Otherwise to manually install the model download project.yaml and last.cpkt and rename last.ckpt to model.ckpt
Place both under stable-diffusion-main/src/latent-diffusion/experiments/pretrained_models/
Make sure you have both project.yaml and model.ckpt in that folder and path.
LDSR should be wokring now.

@darkstorm2150
Copy link
Author

Made the mistake of git cloning https://github.com/CompVis/latent-diffusion instead of yours, it seems to be working now, thx!

@AbdBarho
Copy link
Contributor

AbdBarho commented Sep 2, 2022

Outdated, see edit below

@devilismyfriend I am also facing a similar problem but while loading the config:

Loaded LDSR
Traceback (most recent call last):
  File "scripts/webui.py", line 1743, in imgproc
    image = processLDSR(image)
  File "scripts/webui.py", line 1679, in processLDSR
    result = LDSR.superResolution(image)
  File "/stable-diffusion/src/latent-diffusion/LDSR.py", line 315, in superResolution
    model = self.load_model_from_config()
  File "/stable-diffusion/src/latent-diffusion/LDSR.py", line 76, in load_model_from_config
    model = instantiate_from_config(config.model)
  File "/stable-diffusion/ldm/util.py", line 85, in instantiate_from_config
    return get_obj_from_str(config["target"])(**config.get("params", dict()), **kwargs)
TypeError: __init__() missing 1 required positional argument: 'personalization_config'

The files are at the correct place:

(base) root@6bf18db60a15:/# cd /stable-diffusion/src/latent-diffusion/experiments/pretrained_models/
model.ckpt    project.yaml

I think there are two possible explainations:

  1. the configuration file I have is the wrong one, because it does not have personalization_config
  2. the LDSR is wrongly trying to import /stable-diffusion/ldm/util.py instead of /stable-diffusion/src/latent-diffusion/ldm/util.py

Edit

It turns out, this was a conflict with the models of Textual Inversion, which caused import confusion.

@AdamNizol
Copy link

If you are using windows then the bat file that they say works may not. It didn't for me since the curl command requires some ssl certification or something so the bat was throwing errors but closed on its own afterwards so you couldnt tell it went wrong without checking the folder and seeing that no files were downloaded. I added a pause to the end of the bat file which let me see the error and fix it. It was an easy fix in the end by adding the --ssl-no-revoke flag to both curl commands in the bat file.

@Renaldas111
Copy link

Where is download_models.bat file? If it is download_models.sh, how to run it on Windows?

@hafiidz
Copy link
Contributor

hafiidz commented Sep 7, 2022

Maybe try the manual option? hopefully we didnt give it death hug, hahaha.

@devilismyfriend
Copy link
Contributor

devilismyfriend commented Sep 8, 2022 via email

@hafiidz
Copy link
Contributor

hafiidz commented Sep 9, 2022

Just in case others come to this issue page later, latest instruction for LDSR is here and more details here

@naavis
Copy link

naavis commented Sep 10, 2022

I'm having this same issue with the master version of sd-webui. I'm running on Windows, and running the web UI using Docker Compose. The relevant model.ckpt and project.yaml files are in the correct place, the model validation at the beginning of starting the container succeeds.

You can see the output here:

sd  | Validating model files...
sd  | checking model.ckpt...
sd  | model.ckpt is valid!
sd  |
sd  | checking GFPGANv1.3.pth...
sd  | GFPGANv1.3.pth is valid!
sd  |
sd  | checking RealESRGAN_x4plus.pth...
sd  | RealESRGAN_x4plus.pth is valid!
sd  |
sd  | checking RealESRGAN_x4plus_anime_6B.pth...
sd  | RealESRGAN_x4plus_anime_6B.pth is valid!
sd  |
sd  | entrypoint.sh: Launching...
sd  | Found GFPGAN
sd  | Found RealESRGAN
sd  | Found LDSR

Yet when I go to the web UI and try to upscale an image with LDSR in the Image Lab tab, it fails with the following error:

sd  | Processing images...
sd  | Unloaded Stable Diffusion
sd  | Unloaded GFPGAN
sd  | Traceback (most recent call last):
sd  |   File "/opt/conda/envs/ldm/lib/python3.8/site-packages/gradio/routes.py", line 247, in run_predict
sd  |     output = await app.blocks.process_api(
sd  |   File "/opt/conda/envs/ldm/lib/python3.8/site-packages/gradio/blocks.py", line 641, in process_api
sd  |     predictions, duration = await self.call_function(fn_index, processed_input)
sd  |   File "/opt/conda/envs/ldm/lib/python3.8/site-packages/gradio/blocks.py", line 556, in call_function
sd  |     prediction = await anyio.to_thread.run_sync(
sd  |   File "/opt/conda/envs/ldm/lib/python3.8/site-packages/anyio/to_thread.py", line 31, in run_sync
sd  |     return await get_asynclib().run_sync_in_worker_thread(
sd  |   File "/opt/conda/envs/ldm/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
sd  |     return await future
sd  |   File "/opt/conda/envs/ldm/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 867, in run
sd  |     result = context.run(func, *args)
sd  |   File "scripts/webui.py", line 1850, in imgproc
sd  |     ModelLoader(['LDSR'],True,False) # Load used models
sd  |   File "scripts/webui.py", line 1946, in ModelLoader
sd  |     global_vars[m] = load_LDSR()
sd  |   File "scripts/webui.py", line 306, in load_LDSR
sd  |     from LDSR import LDSR
sd  | ModuleNotFoundError: No module named 'LDSR'

Are only the project.yaml and model.ckpt files necessary, or do I need to clone the whole linked repo to the src folder like described here? https://github.com/sd-webui/stable-diffusion-webui/wiki/Installation#ldsr

@naavis
Copy link

naavis commented Sep 10, 2022

Nevermind, it was easier to test than I anticipated. It started working after cloning the whole repository into the folder as described!

@victorchall
Copy link

Git clone https://github.com/devilismyfriend/latent-diffusion into your stable-diffusion-main/src/ folder Rename latent-diffusion-main folder to latent-diffusion If on windows: run download_models.bat to download the required model files Otherwise to manually install the model download project.yaml and last.cpkt and rename last.ckpt to model.ckpt Place both under stable-diffusion-main/src/latent-diffusion/experiments/pretrained_models/ Make sure you have both project.yaml and model.ckpt in that folder and path. LDSR should be wokring now.

This fixed my issue, probably need to specify this repo in instructions as most are going to use the compvis/latent-diffusion

@hafiidz
Copy link
Contributor

hafiidz commented Sep 11, 2022

@victorchall & @naavis

Hi, I am curious on your flow of installation, since I am doing most of the updates recently for the installation guide in the wiki. We have included the latest steps here. If you don't mind me asking, was that link unclear or is there a guide somewhere else that wasn't updated or unclear or the wiki link itself not as easy to discover. Wanted to help others coming in later, so need to know where we need to improve. Appreciate the help to clarify.

@victorchall
Copy link

victorchall commented Sep 11, 2022

The readme.md only states
LDSR Download LDSR [project.yaml](https://heibox.uni-heidelberg.de/f/31a76b13ea27482981b4/?dl=1) and [model last.cpkt](https://heibox.uni-heidelberg.de/f/578df07c8fc04ffbadf3/?dl=1). Rename last.ckpt to model.ckpt and place both under stable-diffusion-webui/src/latent-diffusion/experiments/pretrained_models/

This should probably be changed to point to the wiki and not state anything at all rather than be incomplete.

Might also put a "hey go look at the wiki" at the top under "Have an issue?"

@hafiidz
Copy link
Contributor

hafiidz commented Sep 11, 2022

I see, I think I found the problem. The changes made to the readme was still in dev branch and not to the master yet.

image

Really appreciate your kind feedback. Will check with team if they can migrate this updated message to the master branch sooner.

p/s, just noticed instructios typo, LOL

@juliosmacedo
Copy link

webui.cmd is stuck in a relaunch loop, seems to be because the app can't find any NVIDIA drivers. I use AMD cards, so nvidia drivers wouldn't be found anyway. Does this only works on NVIDIA cards?

Pasting here the 9th relaunch log:

Found RealESRGAN
Found LDSR
Loading model from models/ldm/stable-diffusion-v1/model.ckpt
Global Step: 470000
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
making attention of type 'vanilla' with 512 in_channels
Working with z of shape (1, 4, 32, 32) = 4096 dimensions.
making attention of type 'vanilla' with 512 in_channels
Traceback (most recent call last):
File "scripts/webui.py", line 453, in
model, device,config = load_SD_model()
File "scripts/webui.py", line 444, in load_SD_model
model = load_model_from_config(config, opt.ckpt)
File "scripts/webui.py", line 159, in load_model_from_config
model.cuda()
File "C:\Users\Adm.conda\envs\ldm\lib\site-packages\pytorch_lightning\core\mixins\device_dtype_mixin.py", line 127, in cuda
return super().cuda(device=device)
File "C:\Users\Adm.conda\envs\ldm\lib\site-packages\torch\nn\modules\module.py", line 688, in cuda
return self._apply(lambda t: t.cuda(device))
File "C:\Users\Adm.conda\envs\ldm\lib\site-packages\torch\nn\modules\module.py", line 578, in _apply
module._apply(fn)
File "C:\Users\Adm.conda\envs\ldm\lib\site-packages\torch\nn\modules\module.py", line 578, in _apply
module._apply(fn)
File "C:\Users\Adm.conda\envs\ldm\lib\site-packages\torch\nn\modules\module.py", line 578, in _apply
module._apply(fn)
[Previous line repeated 1 more time]
File "C:\Users\Adm.conda\envs\ldm\lib\site-packages\torch\nn\modules\module.py", line 601, in _apply
param_applied = fn(param)
File "C:\Users\Adm.conda\envs\ldm\lib\site-packages\torch\nn\modules\module.py", line 688, in
return self.apply(lambda t: t.cuda(device))
File "C:\Users\Adm.conda\envs\ldm\lib\site-packages\torch\cuda_init
.py", line 216, in _lazy_init
torch._C._cuda_init()
RuntimeError: Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from http://www.nvidia.com/Download/index.aspx
Relauncher: Process is ending. Relaunching in 1s...
Relaunch count: 9
Relauncher: Launching...
Error loading GFPGAN:
Traceback (most recent call last):
File "scripts/webui.py", line 356, in
GFPGAN = load_GFPGAN(checking=True)
File "scripts/webui.py", line 313, in load_GFPGAN
raise Exception("GFPGAN model not found at path "+model_path)
Exception: GFPGAN model not found at path ./src/gfpgan\experiments/pretrained_models\GFPGANv1.3.pth

@satvikpendem
Copy link

My terminal says it found LDSR but the UI doesn't seem to detect it.

Relauncher: Launching...
Found GFPGAN
Found RealESRGAN
Found LDSR
Loading model from models/ldm/stable-diffusion-v1/model.ckpt
Global Step: 470000
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
making attention of type 'vanilla' with 512 in_channels
Working with z of shape (1, 4, 32, 32) = 4096 dimensions.
making attention of type 'vanilla' with 512 in_channels
C:\Users\Satvik\anaconda3\envs\ldm\lib\site-packages\gradio\deprecation.py:43: UserWarning: You have unused kwarg parameters in File, please remove them: {'source': 'upload'}
  warnings.warn(
Running on local URL:  http://localhost:7860/

To create a public link, set `share=True` in `launch()`.
Iteration: 1/10
[MemMon] Recording max memory usage...

image

@Rustmongrel
Copy link

Outdated, see edit below

@devilismyfriend I am also facing a similar problem but while loading the config:

Loaded LDSR
Traceback (most recent call last):
  File "scripts/webui.py", line 1743, in imgproc
    image = processLDSR(image)
  File "scripts/webui.py", line 1679, in processLDSR
    result = LDSR.superResolution(image)
  File "/stable-diffusion/src/latent-diffusion/LDSR.py", line 315, in superResolution
    model = self.load_model_from_config()
  File "/stable-diffusion/src/latent-diffusion/LDSR.py", line 76, in load_model_from_config
    model = instantiate_from_config(config.model)
  File "/stable-diffusion/ldm/util.py", line 85, in instantiate_from_config
    return get_obj_from_str(config["target"])(**config.get("params", dict()), **kwargs)
TypeError: __init__() missing 1 required positional argument: 'personalization_config'

The files are at the correct place:

(base) root@6bf18db60a15:/# cd /stable-diffusion/src/latent-diffusion/experiments/pretrained_models/
model.ckpt    project.yaml

I think there are two possible explainations:

1. the configuration file I have is the wrong one, because it does not have `personalization_config`

2. the LDSR is wrongly trying to import `/stable-diffusion/ldm/util.py` instead of `/stable-diffusion/src/latent-diffusion/ldm/util.py`

Edit

It turns out, this was a conflict with the models of Textual Inversion, which caused import confusion.

How did you fix this? I am having the same issue and have tried everything I can think of, which isn't much. Any help would be appreciated!

@hafiidz
Copy link
Contributor

hafiidz commented Sep 17, 2022

@Rustmongrel, could you please confirm are you in master or dev channel ya? If in master, follow the installation steps here as close as possible. Please ensure .src folder is not there before you first run webui.cmd

@Rustmongrel
Copy link

@Rustmongrel, could you please confirm are you in master or dev channel ya? If in master, follow the installation steps here as close as possible. Please ensure .src folder is not there before you first run webui.cmd

Sorry, I have no idea what master or dev channel is so any guidance would be appreciated. I followed that guide to a T and everything but LDSR runs perfectly. When I try to use it I get that exact same error and I am here asking for help as it is the only place it is mentioned on the entirety of the internet. I have verified that everything is exactly where it is supposed to be so I am lost as to what it could be. I would really appreciate any help.

@hafiidz
Copy link
Contributor

hafiidz commented Sep 18, 2022

@Rustmongrel, this is quite an edge cases then. Hard to troubleshoot here, I can suggest two things,

First, could you please try running webui_streamlit.cmd instead of webui.cmd, just in case.

Second, if the above doesn't help, I would suggest you to share this issue in our discord, somebody more knowledgeable might be able to help. You can see the link to discord on the github home/readme.

@hafiidz
Copy link
Contributor

hafiidz commented Sep 18, 2022

master and dev is branch of git, since you are not doing anything else, you're on the master branch.

@hlky hlky closed this as completed Oct 6, 2022
@devilismyfriend
Copy link
Contributor

devilismyfriend commented Oct 11, 2022 via email

@Nirvan93
Copy link

I had the same error "ModuleNotFoundError: No module named 'LDSR'" constantly no matter what.
What helped me was going back on master branch to "The Merge (#1444)" commint and it's fixed.

I am confused about right directory of the ldsr files.
In one part in the docs you say to put model.cpkt and project.yaml under
' stable-diffusion-main/src/latent-diffusion/experiments/pretrained_models/' and in other doc you say to put it under 'stable-diffusion-webui/models/ldsr/' so where should it be?

PS. I also needed to change webui.py line 389 for GFPGANv1.3 to v1.4 since now link is downloading v.1.4

@ovasdi
Copy link

ovasdi commented Oct 19, 2022

I had the same error "ModuleNotFoundError: No module named 'LDSR'" constantly no matter what. What helped me was going back on master branch to "The Merge (#1444)" commint and it's fixed.

I am confused about right directory of the ldsr files. In one part in the docs you say to put model.cpkt and project.yaml under ' stable-diffusion-main/src/latent-diffusion/experiments/pretrained_models/' and in other doc you say to put it under 'stable-diffusion-webui/models/ldsr/' so where should it be?

PS. I also needed to change webui.py line 389 for GFPGANv1.3 to v1.4 since now link is downloading v.1.4

@Nirvan93 thanks for the workaround. It works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests