huggingface / huggingface/diffusers

DPM++ leaves residual noise in SDXL images, which is unexpected

Ouverte
#5,689 13 commentaires 1 réaction 1 personne assignée Voir sur GitHub

@yiyixuxu y travaille déjà.

Depuis le 13/11/2023.

bug scheduler stale
Langage dominant
Python
Étoiles
34.5k
Forks
7.3k
Merge moyen
3 j 3 h
PR mergées (30 j)
91

Description

### Describe the bug

When using DPM++ with SDXL, there is residual noise in the result.

Upon investigation, my colleague @CodeCorrupt and I found that the final sigma was non-zero which we empirically deemed to be the culprit - i.e. when we set the final sigma to 0 artificially, the images were clean.

### Reproduction

```python3
import torch
from diffusers import StableDiffusionXLPipeline
from typing import cast
from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline,

sdxl_model = cast(StableDiffusionXLPipeline, StableDiffusionXLPipeline.from_pretrained(
'stabilityai/stable-diffusion-xl-base-1.0',
torch_dtype=torch.float16,
use_safetensors=True,
variant="fp16",
revision="76d28af79639c28a79fa5c6c6468febd3490a37e",
)).to('cuda')
common_config = {'beta_start': 0.00085, 'beta_end': 0.012, 'beta_schedule': 'scaled_linear'}
scheduler = DPMSolverMultistepScheduler(**common_config)

generator = torch.Generator(device='cuda')
sdxl_model.scheduler = scheduler
generator.manual_seed(96404382)
params = {
'prompt': ['clorful abstract background, glowing gradient waves on black background'],
'negative_prompt': [''],
"num_inference_steps": 40,
"guidance_scale": 8,
"width": 1024,
"height": 1024
}
sdxl_res = sdxl_model(**params, generator=generator, output_type='pil')
sdxl_img = sdxl_res.images[0]
display(sdxl_img)
```

Output with diffusers `main`:
![image](https://github.com/huggingface/diffusers/assets/485488/136d7ee9-7864-4d22-8381-4d5d3ef80ee0)

Output with a hack to set the last sigma to 0:
![image](https://github.com/huggingface/diffusers/assets/485488/82bd3da4-1c48-45ba-b900-0fd3c15db2c9)

### Logs

_No response_

### System Info

- diffusers version: 0.22.1
- Platform: Linux-5.4.0-166-generic-x86_64-with-glibc2.31
- Python version: 3.11.5
- PyTorch version (GPU?): 2.1.0+cu121 (True)
- Huggingface_hub version: 0.17.1
- Transformers version: 4.34.0
- Accelerate version: 0.22.0
- xFormers version: not installed
- Using GPU in script?: yes
- Using distributed or parallel set-up in script?: no

### Who can help?

@yiyixuxu @patrickvonplaten

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.