AUTOMATIC1111 / stable-diffusion-webui

Stable Diffusion web UI
GNU Affero General Public License v3.0
139.92k stars 26.51k forks source link

[Bug]: Some samplers (ex: Euler a, DDIM) produce different results via API #12708

Closed jcowles closed 1 year ago

jcowles commented 1 year ago

Is there an existing issue for this?

What happened?

Using identical text2img parameters, a REST API call produces a different image from the web UI when using /some/ samplers (note that some samplers produce identical images, ex: Euler).

Steps to reproduce the problem

  1. Setup a txt2image as follows:

image

  1. Generate the same image via API call

Note that the results are different, shown below

Web: image

API: image

API JSON Request:

{"enable_hr":false,"hr_scale":2,"hr_upscaler":"Latent","hr_second_pass_steps":0,"hr_resize_x":0,"hr_resize_y":0,"denoising_strength":0.7,"firstphase_width":0,"firstphase_height":0,"prompt":"palm tree","styles":[],"seed":256,"subseed":-1,"subseed_strength":0.0,"seed_resize_from_h":0,"seed_resize_from_w":0,"batch_size":1,"n_iter":1,"steps":20,"cfg_scale":7.0,"width":512,"height":512,"restore_faces":false,"tiling":false,"do_not_save_samples":false,"do_not_save_grid":false,"negative_prompt":"","eta":1.0,"s_churn":0,"s_tmax":0,"s_tmin":0,"s_noise":1,"override_settings":{},"override_settings_restore_afterwards":true,"sampler_name":"DDIM","sampler_index":"DDIM","script_args":[],"send_images":true,"save_images":false,"alwayson_scripts":{}}

What should have happened?

Produced identical images

Version or Commit where the problem happens

version: v1.4.0  •  python: 3.9.2  •  torch: 2.0.1+cu118  •  xformers: 0.0.17  •  gradio: 3.32.0  •  checkpoint: 1a189f0be6

What Python version are you running on ?

Python 3.9.x (below, no recommended)

What platforms do you use to access the UI ?

Linux

What device are you running WebUI on?

Nvidia GPUs (RTX 20 above)

Cross attention optimization

xformers

What browsers do you use to access the UI ?

Mozilla Firefox

Command Line Arguments

--xformers --listen

List of extensions

ControlNet

Console logs

100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:08<00:00,  2.32it/s]

Additional information

No response

catboxanon commented 1 year ago

This is expected behavior -- your eta value is set to 1.0, which will correspondingly set the eta_ddim or eta_ancestral values depending on the sampler chosen. In particular, in the version you're using (1.4.0), it will only affect those samplers you listed. eta_ancestral technically should affect more k-diffusion samplers but that's only supported on dev currently.

Compare your eta values in the UI here to your API request. That will allow you to reproduce the images. image