Gadersd / stable-diffusion-xl-burn

Stable Diffusion XL ported to Rust's burn framework
MIT License
248 stars 15 forks source link

How can we add negative prompts? #6

Open danielclough opened 1 year ago

danielclough commented 1 year ago

I can not figure out how to add negative prompts. I would be excited to learn how to send a PR for that if you like.

Can you suggest some reading to help me learn about what's going on here?

I have worked in Rust a bit. I need to understand the torch part.

Gadersd commented 1 year ago

The diffusion guidance works by computing DP = (P-B)g + B where DP is the diffused latent image, P is the diffused positive prompt, B is the diffused blank prompt, and g is the guidance scale. Adding a negative prompt could be as simple as DN = (N-B)ng + B, D = 0.5(DP - DN) where D is the desired diffused latent image.

It shouldn't be too difficult so give it a try if you are interested. Otherwise I'll probably get around to it after I implement the refiner model.