This isn't a photo. It's tens of thousands of blobs of colour that taught themselves to be one.
One photo goes in. The code starts from pure noise, and every step it paints the blobs, measures how wrong the picture is, and nudges every blob to be a little less wrong. No diffusion model and no image generator: the right-hand picture is drawn entirely by code. The method is the same training loop that AI image models use (gradient descent), pointed at a single photo.
The code was written by Claude (Fable 5.2 and Opus 5.5 in Claude Code).
Left is the real photo. Right is the code, after 3,540 steps and 50,400 blobs.
Left: the same eye with every blob shrunk and drawn as a hard disc, so you can see what it's made of. Right: that eye forming from noise over the whole run.
- A blob is a soft, see-through dab of colour. Each one is nine numbers: where it sits (2), how wide and tall it is (2), its angle (1), its colour (3) and how strong it is (1).
- Start random. 1,500 blobs with random positions, sizes and colours. It looks like confetti.
- Paint. The code draws all the blobs into a picture.
- Measure the mistake. It compares that picture with the photo and gets one number for how wrong it is: the loss.
- Nudge. The maths works out, for every number on every blob, which way makes the mistake smaller, and moves it a tiny step that way (the Adam optimiser).
- Repeat, thousands of times. Nobody tells it "this is an eye". The eye appears because it lowers the mistake.
Three tricks make it work:
- Blurry first, sharp later. It learns a 160 px version of the photo, then 320 px, then close-up crops at 640 px and finally at the photo's full 1200 px.
- More blobs where it's wrong. Every few steps it finds the spots with the biggest mistake and adds small new blobs there. The count grows from 1,500 toward 100,000.
- Close-ups. Late in training it studies random zoomed-in patches, mostly of the face. That's where the lashes and stubble come from.
The blob painting is pushed onto a depth surface and the camera turns. Honest note: the depth is not learned by the blobs. It comes from a separate, ready-made depth model (Depth Anything V2 Small) that guesses depth from the single photo. A full 360° spin isn't possible from one photo, because there is nothing behind the head to learn from. The blink and small smile are hand-made warps of the painting, not learned.
The repo includes a recorded run, so you can play the film straight away. It only needs Python's built-in web server:
python3 -m http.server 5793Then open http://localhost:5793/index.html and drag the bar at the bottom to scrub. graphic/loop-reel.html is the 9:16 explainer of the loop. Opening the files directly (file://) won't work, because the page has to fetch its data.
Needs Python 3.10+. It picks the fastest device it finds: an NVIDIA GPU (CUDA), an Apple-silicon GPU (MPS), or the CPU. It was built and tested on an M3 Pro; the CUDA path has not been tested.
python3 -m venv .venv && .venv/bin/pip install -r requirements.txtTrain. This replaces the included recorded run in train_v2/ (about an hour on an M3 Pro for the full 7,000 steps; add --quick for a 60-step smoke test):
.venv/bin/python train_v2/train.pyA finished run writes train_v2/meta.json and the film picks it up. If you stop early, write the playback data for what exists so far (same file):
.venv/bin/python train_v2/live_meta.pyThe depth surface for the 3D turn is already included (train/depth-tex.f32). To rebuild it, for example after changing the photo:
.venv/bin/python train/depth.pyTo use your own photo, replace reference/sirio-portrait.webp and adjust the crop near the top of train_v2/train.py.
| Path | What it is |
|---|---|
train_v2/train.py |
The trainer: a hand-written 2D Gaussian splat renderer in PyTorch, Adam, densification and coarse-to-fine crops |
train_v2/snapshots.bin, meta.json |
The recorded run the film replays (12 bytes per blob per snapshot) |
train_v2/live_meta.py |
Writes the playback data for a run that stopped before the end |
train/ |
An early 300-step test run, plus the depth files the 3D turn uses |
train/depth.py |
Depth estimate and background mask for the 3D turn |
index.html |
The film: one WebGL page that replays the real run, then the zoom proof and the 3D turn |
graphic/ |
The 9:16 explainer of the loop, built from frames of the real run |
BRIEF.md |
The original build brief |
- It learns one photo. It can copy a face perfectly, but it can't invent a new one.
- The 3D is a depth guess from one photo, not real 3D.
- The numbers on screen come from the recorded run. The included recorded run stops at step 3,960 of a planned 7,000 (58,800 blobs); the pictures above were captured at step 3,540.
Inspired by "Gradient Descent for Orchestra", a piece that shows music being learned by gradient descent.







