r/StableDiffusion • • Oct 10 '22
A bizarre experiment with negative prompts
[deleted] — view deleted post
225
Upvotes
r/StableDiffusion • • Oct 10 '22
[deleted] — view deleted post
120
u/[deleted] Oct 11 '22
Super interesting experiment.
If anyone is wondering why this effect happens (and they should be wondering if they want to push SD to it's limits) it's the SEO media marketing word cloud noise coming up in the labelling of the dataset SD was trained on.
I'll try not to be long winded, want to get back to my SD project but think it's valuable enough to put down here since this experiment is a clear visual aid for the idea.
Top searches in 2019 in my example here: (didn't use 2020 onward as results of covid would skew this out of normalization).
News, people, celebrities and Trump is up there among all those at the top.
Disney
Food/food blogs
Fashion
Royalty
Sex
Home furnishing/decorating
I hope that gets the picture across to anyone in thought about this. Look at those images above and read the above list again.
What happens is that media marketing types, including stock image people tag their images of EVERYTHING with this word cloud noise so that it's picked up by algorithms in the searches we all use.
Common Crawl scrapes all these images, bad tags included then SD gets trained on this data. Models are released, but the shit-tier labelling remains intact until pruned out. But there's billions of images and so much of it is infected by this noise. Current SD 1.4 is less than 900m parameters after extensive pruning but it's still there this noise in the labelling.
The diffuser is godlike. The API tokenizer is godlike. They're SO GOOD at what they do. The math is profound, magical with this latent space diffusion stuff.
But the labelling of the data is driving the diffuser to resolve into dogshit.
One day spent experimenting with a model trained on curated and meticulously labelled data in terms of coherency will show you all you need to know about this. Wow all of a sudden SD jumps up in coherency and quality, ya don't say.
So yeah, to sum up, get good with negative prompt understanding and don't just copy paste someone's negative prompt list since they just copy pasted from someone else who got good results. Do stuff like this to find out how to neg out the static from the signal and watch the quality of your images skyrocket as a result.
Pretty quick your negative list ends up with words like "pizza", "simpsons", et al. Even though what you're prompting has nothing to do with any of that even in a tangential way. It's some mad science shit, but to me it's fun cracking all this. Since I can't code and suck at math it's all I'm left with lol. Left handed artist here, SD lights up the right side of my brain when I use this thing, can barely sleep anymore way too inspired. Got really busy working on figuring all this out and LOVE this thread to showcase some of this stuff that's on my mind. Great clear examples here.
Oh one last thing, want to know why "mutant" works in negative prompts to make your faces look better?
It's not because it's negating mutant, it's because it's negating a ton of data tagged with New Mutants, now go look at the poster/cover for the movie New Mutants. See all those horrible extra heads? All those twisted ugly deformed extra heads? Yeah you see it now don't you.
So negging out mutants takes out a slew of data involving this horrible image. But why would that matter? Well here's why. That movie stars Maisie Williams, one of the most searched for actresses in 2019. That's why.
So she comes up in a TON of tags for otherwise harmless images, and they also include the tag "New Mutants" in that media marketing toxic word cloud that infects the data, since they want their images to be associated with all these popular searches.
So by negging out "mutant" you're getting rid of a ton of bad data associated with Maisie Williams improper tagging to drive SEO shit. In one word you cleaned up the data so the diffuser has a much easier time to resolve into coherent images of what you're after.
Damn, thought I said I'd try not to be long winded, oops.
12
u/ellaun Oct 11 '22 edited Oct 11 '22
I want to propose another theory.
The default negative prompt is
""or empty string which can be considered a center of all prompts. The formula that involves prompts and CFG scale is just a simple linear extrapolation:model(neg) + cfg_scale * (model(pos) - model(neg))x * cfg_scale.2 * x * cfg_scalebecause it uses variables in opposite edges of hypersphere instead of edge minus center.The thing I'm pointing at is that this just leads to effectively doubling the cfg_scale. Of course your negative prompt may skew generation a bit but I think most of the effect just comes from doubled cfg_scale. Another evidence of that is how your initial image of blue cars is grimy and low contrast, which is characteristic of low CFG and with negative prompt it's high contrast but washed out in details and that's how high CFG results look like.
82
u/tinymoo Oct 11 '22
I was today years old when I realized that the opposite of a blue car is a conjoined twin orgy potluck.
I wish I could get a better handle on using CFG to tweak my results, but I can barely handle the positive numbers. Treading into negative latent spaces just does my head in. You're a braver soul than I.
3
u/throttlekitty Oct 11 '22
That's an interesting find, thanks! Could be a version thing, but using a negative cfg in the XY script spat out a div by zero error. It turns out that you can copy and paste your original prompt, but edit the CFG scale to a negative to get around the UI not letting you do this by hand. eg, paste this into the prompt, then apply the style.
18
u/960018 Oct 11 '22
You can also notice that the opposite pictures all have a brown-red color scheme, which happens to be the inverse of blue.
15
u/aiolive Oct 11 '22
I wanted you to reverse the meatball indian dresses and see if you would obtain blue cars, proving these things are the true opposite
13
u/WazWaz Oct 11 '22
A blue car is not:
4
u/bloc97 Oct 11 '22
This a very interesting observation! I suspect that using "negative prompts" instead of an empty string both "lengthens" and adds more meaning to the CFG vector used in classifier-free guidance. Instead of pushing "nonsense" towards our prompt, we are pushing the negative prompts (which can actually impact the final image) towards our intended prompt.
As you noticed, the inverse of a "blue car" is a bunch of nonsense images, then it might be good to put a bunch of nonsense words in the negative prompts.
3
u/Sigmund_slayer Oct 11 '22
That's really interesting!!! Now if only we could wrap our minds around why that latent space is being learned and weighted with opposition in such a way. Still, what an awesome experiment leading to a new technique
2
u/ggkth Oct 11 '22
unexpected technique!
2
u/jingo6969 Oct 11 '22
Great thread, fascinating concepts of why and what works, watching this one...
2
u/[deleted] Oct 11 '22
You need to try coming up with a negative prompt with "food, naked people, Trump, Indians etc." that by itself produces blue cars. That'll be hilarious.
3
u/The_Choir_Invisible Oct 11 '22
tl;dnr: It's my completely baseless and controversial pet theory that negative prompts may actually be reproducing only (relatively) slight variations on of the millions of discrete, individual test images the system was trained on, and that's why things look 'better'.
50 cent version: To the best of my limited understanding, our text prompts are turned into a vector which will always point somewhere in the volume of the .ckpt database. A .ckpt which has intentionally been pruned to contain material from, say, an aesthetic score of 6 to 10- nothing lower. It's my current belief that the 'best' (whatever that means) negative prompts we use alter our prompt's vector in such a way that it is more likely to traverse the most aesthetically pleasing region of that space. The kicker being that the most "aesthetically pleasing region" is really composed of the highest aesthetic-scoring test images the system was trained on.
Kind of like the "Runs home to mama" scene in Hunt for Red October. I know it sounds weird but just keep the possibility in the back of your mind as you (hopefully) continue experimenting. Also, if you aren't already using this, it may help in some fashion. You'll want to check and uncheck certain boxes on the left, depending.
1
u/Rottenaddiction Oct 11 '22
Not sure if ur using the prompt right but it’s specifically [::-1]
1
u/me219iitd Oct 11 '22
Nice one
1
u/fpoppecporto Oct 11 '22
I know it is a stupid question but im pretty new in Stable diffusion comunity: what is cfg value?
Ps: i've only experimented with ai image generator with dalle 2 and midjourney
1
u/ChrisJD11 Oct 12 '22
I find longer prompts produce “better” more detailed images. Might explain why the negative version was better, the prompt is far longer.
1
u/Jujarmazak Dec 21 '22
Why stop at (-7) CFG ... Why not go further?
1
u/IrisColt Dec 22 '22
Truly visionary and essential. Even at 150+ upvotes, this still one of the most underrated posts in this subreddit.
1
u/ILoveAllTheSex Mar 07 '23
Oh
0
u/[deleted] Oct 11 '22
[deleted] — view deleted comment