AI Learning Hub
medium

Image generation

Text-to-image is a parallel ecosystem to chat AI — different architecture (diffusion, not transformers), different models (DALL-E, Flux, Stable Diffusion, Midjourney), different trade-offs.

What image generation actually does

Image AI is a parallel universe to chat AI: same idea (model trained on billions of examples), totally different machinery. Instead of predicting the next token, a diffusion model starts with random noise and removes the parts that don't look like what you asked for. Fifty passes later, you've got a picture.

That mechanism is why specific prompts win so hard: each detail you add — lens, lighting, era, composition — is more guidance for the chiselling. A vague prompt produces the average of every matching image the model has seen, which usually looks generic.

That's the whole concept. Below: the major models, where they differ, and the production techniques (inpainting, ControlNet) that turn one-shot demos into actual design work.

When you'd reach for it

Image AI has crossed into mainstream production use:

  • Marketing creative — hero images, ad variants, social posts at a fraction of stock-photo cost.
  • Product mockups and concept art — exploring 50 directions before committing to one.
  • In-app generated content — avatars, scene illustrations, custom thumbnails.
  • Inpainting and editing — fixing a small bad region instead of redoing the whole image.
  • Image-to-video workflows — the still is the seed for short generated clips.

You wouldn't reach for image AI when you need exact factual images (real people, specific buildings) or perfect typography — image models still mangle text and identity.

How it's actually built

A diffusion model works in roughly four steps:

  1. Encode the text prompt into a vector (using a model like CLIP that maps text and images into a shared space).
  2. Start with pure random noise in image space (or in a compressed "latent" space, for speed).
  3. Iteratively denoise: a neural network looks at the current noisy image + the text vector and predicts what noise to remove. Repeat 30–80 times.
  4. Decode the final clean latent into an actual image.

The whole pipeline takes 1–10 seconds depending on model size and steps. The model has been trained on billions of image-text pairs, so it has seen what "a golden retriever in a tutu" should plausibly look like and can guide noise removal toward that.

The major image models (mid-2026)

Closed / API-based

  • DALL-E 3 (OpenAI) — built into ChatGPT. Strong at following complex prompts (often via an LLM rewriting your prompt under the hood). Good at text-in-image. Conservative content policy.
  • Imagen / Gemini (Google) — strong photorealism, integrated into Gemini.
  • Midjourney — distinctive aesthetic, beloved in creative communities. Excellent at "vibes" prompts; less precise at literal instructions. Discord-based or web app.

Open / self-hostable

  • Flux (Black Forest Labs) — current open-weight leader in quality. Several variants: schnell (fast), dev (high-quality), pro (commercial via API).
  • Stable Diffusion (Stability AI) — the most-deployed open image model lineage. Versions 1.5, SDXL, SD3, etc. Massive ecosystem of fine-tunes (LoRAs) for specific styles.
  • Specialised LoRA(Low-Rank Adaptation) fine-tunes — small "adapter" weights trained for a specific style (anime, photorealistic, cyberpunk). Combine a base model + a style LoRA = unlimited custom generators.

Beyond text-to-image

  • Image-to-image — start from an existing image, modify with prompt.
  • Inpainting — replace just a masked region of an image.
  • Outpainting — extend an image beyond its borders.
  • ControlNet / IP-Adapter — condition generation on poses, depth maps, sketches, reference images. Crucial for production use.
  • Video — Runway, Sora, Luma, Veo — generating short clips from text. Same diffusion principles, much heavier compute.

Where it bites in real life

Under the hood (optional)

Two paths if you ever generate images programmatically: a managed API (DALL-E via OpenAI, ~10 lines) or self-hosted (Flux via the diffusers library, ~10 lines + a GPU). Skip if you don't code — both routes look similar from your side: prompt in, image URL or file out.

Show example code (Python, ~20 lines across two routes)click to expand

Generating an image via API:

from openai import OpenAI
client = OpenAI()
 
resp = client.images.generate(
    model="dall-e-3",
    prompt="A golden retriever wearing a tiny chef's hat, photorealistic, kitchen background, soft natural light",
    size="1024x1024",
    quality="hd",
    n=1,
)
print(resp.data[0].url)

For self-hosted Stable Diffusion / Flux, the popular path is the diffusers library:

from diffusers import FluxPipeline
import torch
 
pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev",
                                    torch_dtype=torch.bfloat16)
pipe.enable_sequential_cpu_offload()    # for limited GPU memory
 
image = pipe("a fox reading a newspaper, oil painting style",
             num_inference_steps=30,
             guidance_scale=3.5).images[0]
image.save("fox.png")

Try it yourself (~5 minutes)

Generate your first image:

  1. In ChatGPT (free or paid): just say "Generate an image of [whatever]". DALL-E is built in.
  2. Or Flux on Hugging Face Spaces — free demo, no signup needed.
  3. Or Midjourney (paid, but free trial): join the Discord, type /imagine.

Try the same prompt in two of them. Try once with a vague prompt ("a city street at night"), then with a richly specific one ("a rain-slicked Tokyo backstreet at 2am, neon signs reflecting in puddles, low-angle 35mm shot, cinematic colour grade, vapour rising from a manhole"). Notice the difference.

Check your understanding

  1. 1. How does a diffusion model generate an image?
  2. 2. Why does a richly detailed prompt produce a better image than a vague one?
  3. 3. Why is **inpainting** useful even when you can re-generate the whole image?

Found this useful? Share it with someone learning AI.

Further reading

Related lessons in this track