In recent years, there was an explosion of platforms that allow the creation of images generated by artificial intelligence, producing increasingly convincing results starting from a textual input, called a prompt. What is the theory behind this impressive technology, that sometimes almost looks like magic?
Generative artificial intelligence
The technology underlying the creation of images is the so-called generative artificial intelligence, which in addition to this field is now widely exploited in the generation of texts (chatGPT), musical pieces, etc.
The process used is called "diffusion" and consists of progressively adding noise to a clear starting image in the forward diffusion phase. During back diffusion, on the contrary, starting from the noise we return towards a clear image, and the model is trained to perform this action through millions of examples.

The diffusion process is guided by the text entered by the user, called a prompt, which can be more or less complex depending on the result you want to obtain: it is often useful to indicate the style you want to follow, the format of the image or other useful parameters. For this reason, this type of artificial intelligence is also called "text-guided diffusion model", or "conditional image generation".
The state of the art of this technology is today represented by Midjourney, Stable Diffusion, Adobe's Firefly generative model and DALL-E, now also integrated into Microsoft's Bing search engine.
Generative adversarial network (GAN)
One of the most used models for the creation of generative images is the GAN (Generative adversarial network), which consists of two distinct neural networks, called Generator and Discriminator, which interact in a competitive process whereby the generator creates synthetic images to try to " deceive” the discriminator, whose task is instead to distinguish a synthetic image from a real one.

The interaction between these two components allows the generation of photorealistic images or images that are difficult to distinguish from real images. During the learning phase, the generator is given a randomized input. This will generate a candidate to be submitted to the discriminator for evaluation. Backpropagation mechanisms are then applied to both neural networks, in order to make the generator increasingly better at creating synthetic images, and the discriminator increasingly capable of distinguishing them from real ones, until a good degree of precision is achieved in generating convincing images.
When the GAN is used in image creation, the types of neural networks used are typically a deconvolutional neural network for the generator, and a convolutional neural network for the discriminator.
Conclusion
In the next article we'll see in more detail how a neural network works, and what a convolutional network is and why it's the best choice when you need to analyze visual inputs.
Thanks for reading!