AttributeError: module 'ldm.modules.encoders.modules' has no attribute 'FrozenCLIPEmbedder'
Apologize if this is a noob question. When I run
python scripts/img2img.py --prompt "A fantasy landscape, trending on artstation" --init-img d:\code\Painter\astronaut_rides_horse.png --strength 0.8
I got output:
Global seed set to 42
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 "d:\code\stable-diffusion\scripts\img2img.py", line 293, in <module>
main()
File "d:\code\stable-diffusion\scripts\img2img.py", line 200, in main
model = load_model_from_config(config, f"{opt.ckpt}")
File "d:\code\stable-diffusion\scripts\img2img.py", line 34, in load_model_from_config
model = instantiate_from_config(config.model)
File "D:\ProgramData\Anaconda3\envs\dmodel2\lib\site-packages\ldm\util.py", line 78, in instantiate_from_config
return get_obj_from_str(config["target"])(**config.get("params", dict()))
File "D:\ProgramData\Anaconda3\envs\dmodel2\lib\site-packages\ldm\models\diffusion\ddpm.py", line 461, in __init__
self.instantiate_cond_stage(cond_stage_config)
File "D:\ProgramData\Anaconda3\envs\dmodel2\lib\site-packages\ldm\models\diffusion\ddpm.py", line 519, in instantiate_cond_stage
model = instantiate_from_config(config)
File "D:\ProgramData\Anaconda3\envs\dmodel2\lib\site-packages\ldm\util.py", line 78, in instantiate_from_config
return get_obj_from_str(config["target"])(**config.get("params", dict()))
File "D:\ProgramData\Anaconda3\envs\dmodel2\lib\site-packages\ldm\util.py", line 86, in get_obj_from_str
return getattr(importlib.import_module(module, package=None), cls)
AttributeError: module 'ldm.modules.encoders.modules' has no attribute 'FrozenCLIPEmbedder'
Any one knows how to solve this issue?
It is said this issue is solved in this post
https://github.com/CompVis/stable-diffusion/issues/59
I tried the method they mentioned, but the problem is still unsolved.
Copy the folder ldm from the main repo to the folder : scripts
Copy the folder ldm from the main repo to the folder : scripts
thx
After deleting /opt/conda/lib/python3.8/site-packages/ldm/ , copying ldm folder in the main repo to /opt/conda/lib/python3.8/site-packages/ldm/ and comment the 4th line of /opt/conda/lib/python3.8/site-packages/ldm/modules/encoders/modules.py where clip is imported, the demo can run successfully.
By the way, pytorch 1.11.0 with cuda 10.2 is needed.
@sike2017 You can also try this method.
I’ve already solve this problem successfully. Thank you very much.
发件人: @.> 发送时间: 2022年9月23日 00:22:40 收件人: @.> 抄送: @.>; @.> 主题: Re: [CompVis/stable-diffusion] AttributeError: module 'ldm.modules.encoders.modules' has no attribute 'FrozenCLIPEmbedder' (Issue #190)
Copy the folder ldm from the main repo to the folder : scripts
thx
After deleting /opt/conda/lib/python3.8/site-packages/ldm/ , copying ldm folder in the main repo to /opt/conda/lib/python3.8/site-packages/ldm/ and comment the 4th line of /opt/conda/lib/python3.8/site-packages/ldm/modules/encoders/modules.py where clip is imported, the demo can run successfully.
By the way, pytorch 1.11.0 with cuda 10.2 is needed.
@sike2017https://github.com/sike2017 You can also try this method.
― Reply to this email directly, view it on GitHubhttps://github.com/CompVis/stable-diffusion/issues/190#issuecomment-1255263072, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIDG7CW6AKFTQI5QIK4H3RLV7SBU5ANCNFSM6AAAAAAQEVINFQ. You are receiving this because you were mentioned.Message ID: @.***>
I found the problem: Upon upgrade (update the code), I ended up with two encoders folders: ./ldm/modules/encoders ./src/latent-diffusion/ldm/modules/encoders Bothe have modules.py, one is 8K the other 4K. Not consistent.
I solved the problem by deleting ./src/latent-diffusion/ldm/modules/encoders. (Actually copy the ./ldm/modules/encoders over ./src/latent-diffusion/ldm/modules/encoders also fix the problem.
It would be nice to fix the code, and make them consistent.
With out the fix, the webui.py failed to load and quit.
With fixing it, the webui.py filed to load
我发现了问题: 升级(更新代码)后,我得到了两个编码器文件夹: ./ldm/modules/encoders ./src/latent-diffusion/ldm/modules/encoders两个 都有modules.py,一个是8K另一个4K。不一致。
我通过删除 ./src/latent-diffusion/ldm/modules/encoders 解决了这个问题。(实际上将 ./ldm/modules/encoders 复制到 ./src/latent-diffusion/ldm/modules/encoders 上也可以解决问题。
修复代码并使其保持一致会很好。
it works!!! thanks very much!!
For me, it is because some inconsistency of several code versions. For some versions, the class is called FrozenCLIPEmbedder, with "models" having default value "ViT-L/14". For others, it is called FrozenClipEmbedder, with no default value for "model".