Google Colab Error - Keyerror: 'sample'

by Olfway - opened

Hi There,
I was recently trying to generate images through google colab and also kaggle and every time I would try it would pop up with this error:
I have tried this with a verity of different generations and all return the same error.
Just wanted to know if this is just me or if everyone is having this error. - The google colab I was the vanilla one btw.

Hope everyone's days go fine :)

Here is a text version of the above screenshot:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/gradio/", line 285, in run_predict
fn_index, raw_input, username, session_state, iterators
File "/usr/local/lib/python3.7/dist-packages/gradio/", line 950, in process_api
result = await self.call_function(fn_index, inputs, iterator)
File "/usr/local/lib/python3.7/dist-packages/gradio/", line 793, in call_function
block_fn.fn, *processed_input, limiter=self.limiter
File "/usr/local/lib/python3.7/dist-packages/anyio/", line 32, in run_sync
func, *args, cancellable=cancellable, limiter=limiter
File "/usr/local/lib/python3.7/dist-packages/anyio/_backends/", line 937, in run_sync_in_worker_thread
return await future
File "/usr/local/lib/python3.7/dist-packages/anyio/_backends/", line 867, in run
result =, *args)
File "", line 20, in infer
images = pipe([prompt] * num_samples, guidance_scale=7.5)["sample"]
File "/usr/local/lib/python3.7/dist-packages/diffusers/utils/", line 88, in getitem
return inner_dict[k]
KeyError: 'sample'

Update: this appears to be an error or incompatibility with new diffusers library (0.6.0).
Setting the install parameters like this fixes it:
!pip install transformers gradio scipy ftfy "ipywidgets>=7,<8" datasets "diffusers==0.5.1"

Hope this helps :)

Olfway changed discussion status to closed

Change the line with error to this:

images = pipe([prompt] * num_samples, guidance_scale=7.5).images

Sign up or log in to comment