stable-diffusion icon indicating copy to clipboard operation
stable-diffusion copied to clipboard

cannot import name VectorQuantizer2

Open samuel-reyes opened this issue 3 years ago • 2 comments

I did a fresh clone of the official SD repo today and setup a fresh conda environment. When I added the optimizedSD folder and I try to run it I get the following. Any ideas how to resolve this?

I get this when running any of the py in optimizedSD python optimizedSD/txt2img_gradio.py python optimizedSD/optimized_txt2img.py etc

Loading model from models/ldm/stable-diffusion-v1/model.ckpt Global Step: 470000 Traceback (most recent call last): File "optimizedSD/txt2img_gradio.py", line 66, in model = instantiate_from_config(config.modelUNet) File "/mnt/e/StableDiffusion/stable-diffusion/ldm/util.py", line 85, in instantiate_from_config return get_obj_from_str(config["target"])(**config.get("params", dict())) File "/mnt/e/StableDiffusion/stable-diffusion/ldm/util.py", line 93, in get_obj_from_str return getattr(importlib.import_module(module, package=None), cls) File "/home/samuel/anaconda3/envs/ldm/lib/python3.8/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 975, in _find_and_load_unlocked File "", line 671, in _load_unlocked File "", line 783, in exec_module File "", line 219, in _call_with_frames_removed File "/mnt/e/StableDiffusion/stable-diffusion/optimizedSD/ddpm.py", line 15, in from ldm.models.autoencoder import VQModelInterface File "/mnt/e/StableDiffusion/stable-diffusion/ldm/models/autoencoder.py", line 6, in from taming.modules.vqvae.quantize import VectorQuantizer2 as VectorQuantizer ImportError: cannot import name 'VectorQuantizer2' from 'taming.modules.vqvae.quantize' (/home/samuel/anaconda3/envs/ldm/lib/python3.8/site-packages/taming/modules/vqvae/quantize.py)

samuel-reyes avatar Aug 31 '22 23:08 samuel-reyes

Hi, can you once try upading the conda env using conda env update -f environment.yaml?

basujindal avatar Sep 01 '22 08:09 basujindal

for me I was getting similar but different error, "ModuleNotFoundError: No module named 'optimizedSD'"

however, conda env update -f environment.yaml and conda update -n base -c defaults conda fixed it for me.

tabishz avatar Sep 02 '22 20:09 tabishz