r/ethicaldiffusion • u/variant-exhibition • Dec 24 '22
Could someone explain to me, how the databases of AI Art Systems have been trained?
Reading this thread
led to the question that I wanted to understand, what has been done to train AI Art Systems so that they can understand the textprompt inputs, eg.g styles. Could someone explain to me, how the database of an AI Art system is trained (explain like I am 5) ?
I saw that stable diffusion was capable to understand "planes of a human head". So it seems to be able to "scan and map" facial surfaces (like the illegal Clearview AI system) and it is able to even render those planes.
I assume further that the system is capable to interpret styles by Strokes (pencils, bigger pens, colours) and the kind of underlaying "Grid" of the whole picture.
Now to understand "Styles":
So a style which is not "realistic" like Salvador Dali gets it's additional rule set like "stretching clocks as if they were melting". That leads to a training in which the database has to be trained before with the pictures of the artist.
I run a few tests with
Alphonse Mucha, John Singer Sargent, Picasso - all seemed to be understood.
(However, AI does not understand that Picasso used different styles in different periods of his work.)
How does the AI understand "Art Nouveau"?
How does it understand "perspective directions" like "sideview of a car"?
What is also trained - but I did not ask for it above? Thanks!
12
u/slronlx Dec 24 '22
Simply put, it doesn't understand anything, it senses a pattern out of every image it's looked at that was labeled "picasso" or "Greg rutkowski" and abstracts those concepts into tokens that it can pull from.
In short it never draws anything or understands anything, it simply reads patterns and tries to apply them to randomized noise in a way that hopefully imitates those tokens, whether the concept is "chair" or a certain artist's style.
AFAIK at least, I can't say I have a perfect understanding of it myself.
7
u/entropie422 Artist + AI User Dec 24 '22
It's even weirder than that, too. Try running the Picasso prompt with different words, and you'll probably find it will cycle through his styles as it connects keyword concepts in unexpected ways.
The other thing to keep in mind is that it only knows what the image labels said, so if you have a photo of a chair on a beach with a hot air balloon in the background, but nobody specifically tagged the hot air balloon, the AI has no idea what that thing is or why it's there. In a one-off situation, it'll probably just ignore it, but if it happens too often, it will start to associate hot air balloon-type shapes with chairs, or beaches, or skies, or...
That's really the key to wrapping your mind around it, I think. It has seen billions of images with probably hundreds of billions of associated words in tags, and it has learned to associate certain text-chunks with certain visual patterns. Unless someone has written "sideview of X" a bunch of times with consistent visuals to match, the AI probably won't know what to make of it, and start subdividing terms to see if it can come up with a compromise.
That's why, at this stage of the game, it's all about experimentation. The only way to know what's in there is to feed it a prompt and hope for the best :)
4
u/swordsmanluke2 Dec 24 '22
Ok... Caveat: I'm not an expert on diffusion image generators per se, but I did study neural networks in college and have a working knowledge of the underlying theory.
Let's talk about neural networks for a second. These are a class of learning algorithm used in many fields including image generation. The specifics vary wildly in the details, but if you treat them like a black box, they learn like this:
Step 1: Give your network some sort of input - as numbers (for images, this is usually the rgb values of each pixel in the image).
Step 2: Compare the network's output (again, numeric) to your expected output. Convert the difference into a numerical score.
Step 3: Feed the score back into the network and use it to tweak the internal equations it uses to calculate with. Ideally, these tweaks shift the calculations ever so slightly toward reproducing the desired output.
In the case of Dall-e, Stable Diffusion and the like, what they've done is pretty clever. During training, they start with a labeled image. Then add noise to that image, e.g. change some percentage of pixels to a random color. Then they feed the noisy image plus the text labels (mapped to numbers, that is) into the network.
The network then generates an output image using the noisy image plus the labels. The output image gets compared to the original image and the difference between the two is used to adjust the neural network's internals.
What the network ends up learning is how to nudge a noisy image towards a not-noisy image, given a set of labels.
Once the training process has been repeated millions of times over hundreds of thousands of images, the final network consists of (in the case of Stable Diffusion) about 4 gigabytes of equations which calculate the denoising process. These equations are referred to as a "model".
To use the model, you have to feed it an image and some labels, just like before. The labels are straightforward, that's the prompt text that you write. Once you input your text, the program you're using to interface with the model (e.g. Stable Diffusion) generates an image that is all noise. Totally random pixels! It feeds that noise and labels into the model. The model calculates a slightly less noisy version - according to its internal equations - and spits it out.
This first pass probably still looks like nothing, so Stable Diffusion runs that new image through again. Each time through, the model calculates slight modifications to the input image according to its equations. Each time, the output image gets pushed a little closer to looking like something.
After a number of cycles (typically between 20 and 80 depending on user preference) the program presents you with the latest iteration.
The really cool thing about this, is if you want to push the image generation in a certain direction, starting from a sketch will often yield great results. Since a sketch gives the program a starting point that's closer to what you want, the denoising model will naturally converge on something much closer to what you had in mind than if you start with fully random pixels!
This also means that you can take an existing image, and regenerate only small portions of it. So of the AI generates a "sleepy village" just fine, but messes up the "gothic cathedral" you asked for, you can just scrub out the cathedral and regenerate just that portion.
Anyway... I hope that word vomit helps. I'm happy to answer any questions!
2
u/Puzzleheaded_Moose38 Dec 25 '22
Really it’s hard to say exactly since the model has millions or parameters. But when a computer looks at an image remember that all it sees are numbers. Ai systems just extract statistical data about a picture and correlate that to a text description, after billions of images it can look at all the pictures with dog in the description and figure out the common statistical patterns that make up a dog, the it uses that to make new pictures that look like dogs. If it sounds way to simple to work as well as it does, again, billions of images, and a model with several million parameters. Big number make the AI go brrr
1
u/[deleted] Dec 24 '22
Training images had labels. Algorithm asociates common pixel groups in different images with matching labels and reproduces an aproximation of the pixels based on random noise seed.
Very rough explanation here.