Repository: huggingface/diffusers

Issue:
[Error] got an unexpected keyword argument `eta`
### Describe the bug

When I try to make a sampling using DDIM pipeline, an error occurs
```bash
python utils/ddim.py
  0%|                                                                                                                                                                      | 0/50 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "utils/ddim.py", line 10, in <module>
    image = ddim(num_inference_steps=50).images[0]
  File "/home/sr5/se91.kim/.venv/diffusers/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 28, in decorate_context
    return func(*args, **kwargs)
  File "/home/sr5/se91.kim/.venv/diffusers/lib/python3.8/site-packages/diffusers/pipelines/ddim/pipeline_ddim.py", line 129, in __call__
    image = self.scheduler.step(
  File "/home/sr5/se91.kim/.venv/diffusers/lib/python3.8/site-packages/diffusers/schedulers/scheduling_ddpm.py", line 259, in step
    predict_epsilon = deprecate("predict_epsilon", "0.12.0", message, take_from=kwargs)
  File "/home/sr5/se91.kim/.venv/diffusers/lib/python3.8/site-packages/diffusers/utils/deprecation_utils.py", line 43, in deprecate
    raise TypeError(f"{function} in {filename} line {line_number-1} got an unexpected keyword argument `{key}`")
TypeError: step in /home/sr5/se91.kim/.venv/diffusers/lib/python3.8/site-packages/diffusers/schedulers/scheduling_ddpm.py line 258 got an unexpected keyword argument `eta`
```

Is there anything I can do? 

Thnaks!

### Reproduction

I used code lines the same as the typical example code:
```python
from diffusers import DDIMPipeline

model_id = "/home/sr5/se91.kim/AMP/Diffusers/models/google/ddpm-cifar10-32"

# load model and scheduler
ddim = DDIMPipeline.from_pretrained(model_id)

# run pipeline in inference (sample random noise and denoise)
image = ddim(num_inference_steps=50).images[0]

# save image
image.save("ddim_generated_image.png")
```

### Logs

_No response_

### System Info

I saw a closed issue (https://github.com/huggingface/diffusers/issues/170) but the diffusers in my virtual env. is already of the latest version (0.12.dev):
```bash
$ pip list
Package            Version
------------------ ------------
accelerate         0.15.0
certifi            2020.12.5
chardet            4.0.0
diffusers          0.12.0.dev0
filelock           3.0.12
fsspec             2022.11.0
huggingface-hub    0.11.1
idna               2.10
importlib-metadata 3.7.3
numpy              1.20.1
packaging          20.9
Pillow             8.1.2
pip                21.0.1
psutil             5.8.0
pyarrow            10.0.1
pyparsing          2.4.7
PyYAML             5.4.1
regex              2021.3.17
requests           2.25.1
setuptools         54.1.2
torch              1.9.1+cu111
torchaudio         0.9.1
torchvision        0.10.1+cu111
tqdm               4.64.1
typing-extensions  3.7.4.3
urllib3            1.26.4
wheel              0.36.2
zipp               3.4.1
```
I tried under two versions of diffusers; 0.12.dev and 0.11.1, and both give the same error message.


Discussion:
Even though you are instantiating a DDIMPipeline, the [configuration for the model](https://huggingface.co/google/ddpm-cifar10-32/blob/main/scheduler_config.json) you are loading specifies a DDPMScheduler. The pipeline assumes the scheduler is a DDIMScheduler and therefore sends in the parameter `eta` for the `step`-method. 

I am not sure if this behavior is intended, as the [documentation for the `from_pretrained`-method](https://huggingface.co/docs/diffusers/v0.11.0/en/api/diffusion_pipeline#diffusers.DiffusionPipeline.from_pretrained.example) gives an example of loading a different scheduler from the one specified in the configuration.

Anyway, I managed to get this modified code of yours to run:
```python
from diffusers import DDIMPipeline, DDIMScheduler 

model_id = "google/ddpm-cifar10-32"

# load model and scheduler
ddim = DDIMPipeline.from_pretrained(model_id)
scheduler = DDIMScheduler.from_config(ddim.scheduler.config) # Create a new scheduler with the same variance schedule as the original one
ddim.scheduler = scheduler

# run pipeline in inference (sample random noise and denoise)
image = ddim(num_inference_steps=50).images[0]

# save image
image.save("ddim_generated_image.png")
```

Hmm, nevertheless the following should work:

```python
from diffusers import DDIMPipeline

pipeline = DDIMPipeline.from_pretrained("google/ddpm-cifar10-32")

image = pipeline(num_inference_steps=50).images[0]
```

, but I'm also getting the same error you're getting.

The solution posted by @willdalh is a very nice workaround, but I think since it's such a common case, we should adapt it directly in the code. Will open a PR for it :-) 

Resolving patch:
diff --git a/src/diffusers/pipelines/ddim/pipeline_ddim.py b/src/diffusers/pipelines/ddim/pipeline_ddim.py
--- a/src/diffusers/pipelines/ddim/pipeline_ddim.py
+++ b/src/diffusers/pipelines/ddim/pipeline_ddim.py
@@ -16,6 +16,7 @@
 
 import torch
 
+from ...schedulers import DDIMScheduler
 from ...utils import deprecate, randn_tensor
 from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput
 
@@ -34,6 +35,10 @@ class DDIMPipeline(DiffusionPipeline):
 
     def __init__(self, unet, scheduler):
         super().__init__()
+
+        # make sure scheduler can always be converted to DDIM
+        scheduler = DDIMScheduler.from_config(scheduler.config)
+
         self.register_modules(unet=unet, scheduler=scheduler)
 
     @torch.no_grad()


Test patch: