IndexError on num_inference_steps values: 3, 9, 27, ...?
See original GitHub issueDescribe the bug
Some num_inference_steps
values seem to be “problematic” and throw an IndexError.
Also the iteration status output does not end on that value in any relation. If it’s on purpose, it’s still confusing:
num_inference_steps: 5 6it [00:49, 8.27s/it]
num_inference_steps: 6 8it [01:02, 7.87s/it]
num_inference_steps: 7 9it [01:10, 7.88s/it]
num_inference_steps: 8 9it [01:13, 8.19s/it]
Reproduction
from diffusers import StableDiffusionPipeline
TOKEN = "(censored)"
MODEL_ID = "CompVis/stable-diffusion-v1-4"
pipe = StableDiffusionPipeline.from_pretrained(MODEL_ID, use_auth_token=TOKEN)
res = pipe("a photo of an astronaut riding a horse on mars", num_inference_steps=3, guidance_scale=7.5)
Tested on command line too. Unrelated to PyCharm environment.
Logs
/usr/bin/python3 /home/as/.config/JetBrains/PyCharm2022.2/scratches/scratch.py
0it [00:07, ?it/s]
Traceback (most recent call last):
File "/home/as/.config/JetBrains/PyCharm2022.2/scratches/scratch.py", line 7, in <module>
res = pipe("a photo of an astronaut riding a horse on mars", num_inference_steps=3, guidance_scale=7.5)
File "/home/as/.local/lib/python3.10/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "/usr/lib/python3.10/site-packages/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py", line 148, in __call__
latents = self.scheduler.step(noise_pred, t, latents, **extra_step_kwargs)["prev_sample"]
File "/usr/lib/python3.10/site-packages/diffusers/schedulers/scheduling_pndm.py", line 136, in step
return self.step_plms(model_output=model_output, timestep=timestep, sample=sample)
File "/usr/lib/python3.10/site-packages/diffusers/schedulers/scheduling_pndm.py", line 212, in step_plms
prev_sample = self._get_prev_sample(sample, timestep, prev_timestep, model_output)
File "/usr/lib/python3.10/site-packages/diffusers/schedulers/scheduling_pndm.py", line 230, in _get_prev_sample
alpha_prod_t = self.alphas_cumprod[timestep + 1 - self._offset]
IndexError: index 1000 is out of bounds for dimension 0 with size 1000
System Info
diffusers
version: 0.4.0.dev0- Platform: Linux-5.19.7-arch1-1-x86_64-with-glibc2.36
- Python version: 3.10.6
- PyTorch version (GPU?): 1.12.1+cu102 (True)
- Huggingface_hub version: 0.9.1
- Transformers version: 4.21.3
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No
Issue Analytics
- State:
- Created a year ago
- Comments:20 (18 by maintainers)
Top Results From Across the Web
Does "IndexError: list index out of range" when trying to ...
The IndexError is raised when you attempt to retrieve an index from a sequence, like a list or a tuple , and the...
Read more >List Index Out of Range – Python Error Message Solved
You'll get the Indexerror: list index out of range error when you try and access an item using a value that is out...
Read more >Indexerror: list Index Out of Range in Python - STechies
List index out of range means index error in Python. It occurs when you try to access an index ... Here we are...
Read more >Python indexerror: list index out of range Solution
If we try to access an item at the index position 3, an error will be returned. The last item in our array...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@natolambert Thank for fixing quickly. Will test it tommorrow too. Found some other non 3 related iterations yesterday.
I opened #465 to keep this on track about the indexing error / confusion.