AUTOMATIC1111 / stable-diffusion-webui

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

[Feature Request]: Allow plugins to hook into latent noise generation #14641

Open githubcustomerserviceistrash opened 6 months ago

githubcustomerserviceistrash commented 6 months ago

Is there an existing issue for this?

What would your feature do ?

Add a generate_latent_noise callback hook, that would by default use the normal(0,1) tensor, but which could be overridden to let plugins control the distribution of latent noise. Currently there's no way to override the latent noise, but other distributions such as beta are better suited to the -4/+4 clamped latent range/provide support for non-spherical distributions and there are a few techniques such as brownian/procedural surfaces that could be used to nudge generations in very interesting ways.

Proposed workflow

(this could/would be part of a plugin, but the callback needs to exist for it to work afaict)

  1. Go to txt2img or img2img
  2. Enable alternate noise generation, and choose between pixel space (rgb/hsl) and latent space noise, then drag sliders to control beta distributions for each channel in whatever space I'm working in to shape the noise in that channel.
  3. Optionally specify a procedural surface generator to introduce autocorrelation in the noise and nudge the generation with micropatterns.

Additional information

No response

w-e-w commented 6 months ago

generally speaking if you need a callback to make a extension work, you wll have to be the one who makes the PR to add the callback

otherwise it is hard for us to imagine what exactly do you need


Currently there's no way to override the latent noise

I wouldn't say there's no way, you could always hijack class ImageRNG https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/cb5b335acddd126d4f6c990982816c06beb0d6ae/modules/rng.py#L99 in some cases hijacking might even be better

githubcustomerserviceistrash commented 6 months ago

Are you talking about monkeypatching the hot webui code during extension load (or with callbacks during generation)?

w-e-w commented 6 months ago

Are you talking about monkeypatching

yes


like I said if you want a call back then make a PR for the exact callback you want

or you can patch it, both have their merits and use cases

w-e-w commented 6 months ago

just want to make it clear new callbacks are welcome but you have to add it via PR your self (or explain it good enough that so someone add it for you)

image

https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Contributing