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

TypeError: list indices must be integers or slices, not str

Open PhdShi opened this issue 2 years ago • 1 comments

An error occurred when I run python scripts/txt2img.py --prompt "a photograph of an astronaut riding a horse" --plms according to the ReadMe.md. The following is the detailed information:

Global seed set to 42
Loading model from models/ldm/stable-diffusion-v1/sd-v1-4.ckpt
Global Step: 470000
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 866.90 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
Creating invisible watermark encoder (see https://github.com/ShieldMnt/invisible-watermark)...
data:   0%|                                                                                                      | 0/1 [00:00<?, ?it/s]
Sampling:   0%|                                                                                                  | 0/2 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "scripts/txt2img.py", line 352, in <module>
    main()
  File "scripts/txt2img.py", line 298, in main
    uc = model.get_learned_conditioning(batch_size * [""])
  File "/*****/stable-diffusion/ldm/models/diffusion/ddpm.py", line 567, in get_learned_conditioning
    c = self.cond_stage_model(c)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "/*****/stable-diffusion/ldm/modules/encoders/modules.py", line 32, in forward
    c = batch[key]
TypeError: list indices must be integers or slices, not str

I don't know how to fix it. Thx for any advice!

PhdShi avatar Apr 19 '23 05:04 PhdShi

I meet the same problem. Have you fixed it now?

libalala avatar Nov 17 '24 14:11 libalala