AI Beyond Language Models · Generating Images
Image generators learn one skill: spotting the noise in a noisy picture. Mix noise into a tiny 4-pixel image, then remove it step by step.
# Diffusion models make images by learning to remove noise, a little at a time.
pixels = ["px 0", "px 1", "px 2", "px 3"]
image = [0.0, 1.0, 1.0, 0.0] # a tiny 4-pixel image: a bright bar in the middle
noise = [0.8, -0.6, 0.4, -0.9] # random noise (fixed here so the lesson repeats)
# Training pictures: noise mixed in, more at every step.
picture = image
for t in range(3):
picture = [round(p + 0.5 * n, 2) for p, n in zip(picture, noise)]
print("noisy:", picture)
# Generating: a trained network predicts the noise in the picture, and part of it is removed each step.
for t in range(3):
predicted = noise # a perfect network; real ones are close, not exact
picture = [round(p - 0.5 * n, 2) for p, n in zip(picture, predicted)]
print("cleaned:", picture)t is created with the value 0.t changes from 0 to 1.t changes from 1 to 2.for t in range(3).noisy: [1.2, 0.1, 1.6, -1.35].t changes from 0 to 1.predicted = noise # a perfect network; real ones are close, not exact.picture now points to a different list: [0.4, 0.7, 1.2, -0.45].t changes from 1 to 2.predicted = noise # a perfect network; real ones are close, not exact.for t in range(3).