AUTOMATIC1111 / stable-diffusion-webui

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

img2img alternative give better result with negative values #546

Open alexfredo opened 2 years ago

alexfredo commented 2 years ago

Hi I have modified the ui-config.json and add negative value to "decoder CFG scale" and get better result on all my test, generally I use -3 values, someone know why it's work better ?

ghost commented 2 years ago

Probably related to this by u/Hoppss.

PSA: Developers - img2img decoder CFG effect is backwards from encoder CFG. Using the new img2img decoder to turn a image into noise should have the option in GUI distros for negative CFG numbers. Positive CFG numbers for the decoder is the equivalent to negative CFG for the encoder. For example in a picture you can use -10 decoder CFG for a photo with the prompt "an apple" and as it decodes it which will influence the noise to form an apple. Then on encoding you could use 0 CFG and the same prompt to generate an image from that noise showing only the work the decoder did, which will show the apple

Another example is you could use -3 decoder CFG and 3 encoder CFG to modify an image from both ends into the same prompt.

Pretty much: Don't use positive values for decoder CFG unless you want strange results like negative encoder CFG values give.

verderog commented 2 years ago

Confirmed this is the case. Using small negative decode CFG values (e.g. -0.3, -0.1) gives good results with small encode CFG values (e.g. 1.8). Also need to set denoising strength to '1' even though directions indicate that it doesn't matter.

cmp-nct commented 1 year ago

I've had great results with decode numbers from 0.3 to 1.6, sometimes it does not work at all though. Can't confirm any difference with negative CFGs, the whole functionality of that feature feels still quite random