google / prompt-to-prompt

Apache License 2.0
3.07k stars 285 forks source link

Unexpected argument to scheduler #54

Open andreemic opened 1 year ago

andreemic commented 1 year ago

The Error

I'm getting this when running the original Stable Diffusion notebook with diffusers==0.3.0

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ in <module>:4                                                                                    │
│ in run_and_display:6                                                                             │
│                                                                                                  │
│ /usr/lib/python3/dist-packages/torch/autograd/grad_mode.py:27 in decorate_context                │
│                                                                                                  │
│    24 │   │   @functools.wraps(func)                                                             │
│    25 │   │   def decorate_context(*args, **kwargs):                                             │
│    26 │   │   │   with self.clone():                                                             │
│ ❱  27 │   │   │   │   return func(*args, **kwargs)                                               │
│    28 │   │   return cast(F, decorate_context)                                                   │
│    29 │                                                                                          │
│    30 │   def _wrap_generator(self, func):                                                       │
│                                                                                                  │
│ /home/ubuntu/p2p2/ptp_utils.py:164 in text2image_ldm_stable                                      │
│                                                                                                  │
│   161 │                                                                                          │
│   162 │   # set timesteps                                                                        │
│   163 │   extra_set_kwargs = {"offset": 1}                                                       │
│ ❱ 164 │   model.scheduler.set_timesteps(num_inference_steps, **extra_set_kwargs)                 │
│   165 │   for t in tqdm(model.scheduler.timesteps):                                              │
│   166 │   │   latents = diffusion_step(model, controller, latents, context, t, guidance_scale,   │
│   167                                                                                            │
│                                                                                                  │
│ /home/ubuntu/.local/lib/python3.8/site-packages/diffusers/schedulers/scheduling_pndm.py:171 in   │
│ set_timesteps                                                                                    │
│                                                                                                  │
│   168 │   │                                                                                      │
│   169 │   │   self.ets = []                                                                      │
│   170 │   │   self.counter = 0                                                                   │
│ ❱ 171 │   │   self.set_format(tensor_format=self.tensor_format)                                  │
│   172 │                                                                                          │
│   173 │   def step(                                                                              │
│   174 │   │   self,                                                                              │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'PNDMScheduler' object has no attribute 'tensor_format'

When updating to diffusers 0.8.0:

AttributeError: 'PNDMScheduler' object has no attribute 'tensor_format'

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ in <module>:4                                                                                    │
│ in run_and_display:6                                                                             │
│                                                                                                  │
│ /usr/lib/python3/dist-packages/torch/autograd/grad_mode.py:27 in decorate_context                │
│                                                                                                  │
│    24 │   │   @functools.wraps(func)                                                             │
│    25 │   │   def decorate_context(*args, **kwargs):                                             │
│    26 │   │   │   with self.clone():                                                             │
│ ❱  27 │   │   │   │   return func(*args, **kwargs)                                               │
│    28 │   │   return cast(F, decorate_context)                                                   │
│    29 │                                                                                          │
│    30 │   def _wrap_generator(self, func):                                                       │
│                                                                                                  │
│ /home/ubuntu/p2p2/ptp_utils.py:164 in text2image_ldm_stable                                      │
│                                                                                                  │
│   161 │                                                                                          │
│   162 │   # set timesteps                                                                        │
│   163 │   extra_set_kwargs = {"offset": 1}                                                       │
│ ❱ 164 │   model.scheduler.set_timesteps(num_inference_steps, **extra_set_kwargs)                 │
│   165 │   for t in tqdm(model.scheduler.timesteps):                                              │
│   166 │   │   latents = diffusion_step(model, controller, latents, context, t, guidance_scale,   │
│   167                                                                                            │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: set_timesteps() got an unexpected keyword argument 'offset'

Explanation

The PNDM Scheduler API in Diffusers has to receive steps_offset at initialization.

So we either move the "offset = 1" somewhere else, or understand why the first error occurs.

Any ideas?

laolongboy commented 1 year ago

https://github.com/google/prompt-to-prompt/issues/37#issuecomment-1468319082