Find the holds in a photo of an indoor bouldering wall, work out which ones form a route, and propose a sequence of moves that climbs it.
The two halves of the problem are handled differently. Perception is learned, because finding holds in a photo is what neural networks are good at. The move sequence is searched rather than learned: a stance is a discrete assignment of four limbs to holds, so finding a sequence is graph search under physical constraints. That needs no training data, and every move can be explained by the cost that chose it.
- Indoor gym walls only. Holds are manufactured objects against a flat wall, and route membership is encoded in hold colour. Outdoor rock has neither.
- Public datasets for perception. No hand labelling unless the data runs out.
- Classical search for the move sequence. No learned policy, no RL.
- Input is a single RGB photograph.
- Output is the detected holds, the subset forming one route, an ordered move sequence, and a cost breakdown per move.
photo -> detector -> holds -> colour grouping -> route -> search -> beta
Instance segmentation rather than boxes. A hold's shape and orientation decide where it can be grasped, and boxes on a dense wall overlap badly.
Unsupervised, because route membership is not labelled in any dataset. Each
hold's mask pixels give a median colour in CIELAB, and those are clustered.
Groups are then scored on how route-like they are (see routes.py).
Stance s = (LH, RH, LF, RF)
Each limb sits on a hold. A move changes one limb. Search the graph of reachable stances from a start stance to any stance with a hand on the finish hold, minimising accumulated cost.
Hands and feet both stay on the route's holds, which is the rule in a gym. Feet may also smear on the bare wall: points on a 25 cm grid below the route, each costing more than any hold, and only well under the hips, since a smear grips only when the foot pushes down on it. Without smears a real route was unclimbable on paper, its one low foothold 1.26 m under the next.
A stance counts only if a body of the climber's height can hold it. Hip positions are tried on a grid, and a stance is kept if some hip position puts every hand and foot within reach with the feet below the hips, the hands above them, and no straight leg pointing more than 50 degrees out from straight down. The search then hands the figure the hips it found, so the drawing is the body the search assumed.
- travel: how far the moving limb goes
- move: a flat cost per move, so a beta does not shuffle
- posture: how far each limb sits from a relaxed bend, steeply more at full stretch, plus feet drawn up high, legs turned out, hands below the shoulders and hips outside the feet
- quality: hold size, as a proxy for how positive it is, and a smear costs more
The root holds the code that runs. Everything else is under experiments/,
with a README there saying what each piece established and why it is not here.
| file | purpose |
|---|---|
prepare.py |
ClimbInst Labelme JSON to YOLO segmentation format |
train.py |
fine-tune YOLO11-seg |
export_web.py |
export the weights to ONNX for the browser |
app.py |
the deployed API: geometry only, no detector |
check.py |
score tape-measure checks saved from the app |
figure.py |
a body that holds the beta's stances, for the animation |
video_check.py |
score any video of a beta against the transcript saved with it |
public/ |
the hosted app, detection included |
wall.py |
homography, wall angle, and image to wall-plane metres |
calibrate.py |
four bolt holes to a wall calibration, saved as JSON |
scene.py |
holds in metric 3D, the platform-neutral representation |
measurement.py |
validated calibrations, and what they place on the wall |
beta.py |
stance graph and the search over it |
server.py |
the measurement prototype |
tests.py, test_measurement.py, test_figure.py, test_video_check.py |
the checks |
Done. YOLO11s-seg at 960px, 60 epochs, 3.8 hours on an M5 Pro. On 106 held-out images containing 6,356 holds: mask mAP50 0.877, mAP50-95 0.548, box mAP50 0.919.
Training is I/O-bound rather than compute-bound, because Ultralytics forces 0 dataloader workers on MPS. YOLO11s at 768px ran 2.6 min/epoch against nano at 640's 2.5, despite roughly five times the compute. Resolution is nearly free on this machine, so spend it.
Known failure: objects that are not on the wall get detected as holds, such as brushes on the mat, a brush hanging from the ceiling, and wall signs. A calibration now removes the ones a wall plane can rule out, which is less than the problem: a brush on the mat in front of a vertical wall projects to a sensible size in a sensible place and survives. The floor line or a learned on-wall test is what the rest needs.
Done. Single linkage failed outright: hold colours form a continuum from orange through yellow to pink, so joining clusters by their nearest members chains straight through the gaps. On a 76-hold wall with obviously distinct routes it merged 43 of them even at a threshold of 5. Complete linkage requires every pair in a cluster to be close, which gives the gap no foothold.
Picking the largest group is also wrong, since that is usually the neutral
greys shared by every route. routes.py scores groups on rise, chain
connectivity and chroma instead.
Done. First working sequence is 14 moves on a colour-coded gym wall, selecting an 8-hold green route out of 121 detected holds.
Two modelling errors had to be fixed first, both found by testing rather than by reading the code:
Given any freedom, the search stacked all four limbs on one hold and shuffled up the wall, because coincident contact points drive strain and balance to zero. Fixed with a minimum torso span and a cap of two limbs per hold.
Maximum hand-to-foot span was set to 0.9x height, which deadlocked every real route: the hands could not rise until the feet had, and the feet could not rise until the hands had. A climber standing on a foothold and reaching overhead spans about 1.25x their height.
A jointed body model was considered and dropped. Shoulder, hip and torso parameters cannot be recovered from a photo, so each invented number would quietly decide the beta. Only the distances between the four contact points are observable, so only those were constrained.
That was wrong in practice. On the first gym test the contact distances allowed feet up beside the hands and a straight leg sticking out sideways 0.9 m, and the figure drawn afterwards had to contort to match. The search now holds every stance with the figure's own body, using standard segment proportions for the climber's height. Those proportions are a guess for any one person, but a guess at a human body is closer than no body at all.
Measure a route with a tape measure and compare, which is the first real error
figure the geometry will have had. Then tune the reach limits and cost weights
against routes a person has actually climbed: step_max at 0.65 of height
limits how far one limb moves, and nothing has tested whether that is right.
Infer hold orientation from mask geometry.
ClimbInst: 1,509 images claimed, 1,219 present, 89,020 instance masks, one class. Labelme polygon JSON, one file per image, about 4.2 GB. CC BY-NC-SA 4.0.
The validation split advertised on the dataset card is empty, so prepare.py
carves one out of train by hashing filenames.
Masks came from SAM3 and were corrected by hand. Hold type (jug, crimp, sloper) is not labelled, so the hold-quality term has to be inferred from mask geometry. Route membership is not labelled either, which is what V2 recovers from colour.
- Does colour clustering survive gym lighting? Partly. Complete linkage handles the hue continuum, but chalk and shadow are untested.
- How should reach be calibrated without knowing the wall's scale? By asking.
The T-nut grid was the automatic candidate and it does not work. Gym walls
are drilled on a regular lattice, so the bolt holes should be a ruler lying
in the image. Tested two ways in
experiments/lattice.pyacross three walls: dark-blob detection with a pair-distance histogram returns about 13,000 candidates per image, which is wall texture rather than holes, and an FFT power spectrum of a bare-wall patch shows no dominant peak (top five radii at 3.4 to 3.8x median, with inconsistent periods, where a lattice would give one sharp spike). At these resolutions a T-nut is 3 to 5 px and barely darker than the wall, many are hidden behind holds, and perspective smears whatever periodicity survives. Scale is now an input: two image points a known distance apart. - Is the stance graph small enough to search exhaustively? So far yes, with feasibility pruning.
- Should feet be restricted to route holds? No, answered above.
- How do you evaluate proposed beta when there is no single correct answer? Still open, and the hardest question here. Nothing in any dataset labels the moves a climber made, with the partial exception of hold-usage work such as "The Way Up" (CVPR 2025 workshop).
- Does mask geometry predict hold type well enough to be worth using? Untested.
Run .venv/bin/python server.py and open http://127.0.0.1:8000.
The browser works out the beta for one route:
- Upload a JPEG, PNG, or WebP photo (up to 20 MB / 40 megapixels).
- Tap any hold on the route. Every hold of the same colour is picked, and tapping a hold again adds or drops it. Add a point covers a hold the detector missed.
- Set an explicit scale: two points a known distance apart for an approximate, straight-on measurement, or four bolt-grid corners for perspective correction. Grid dimensions count gaps, not holes. Enter the actual spacing at the gym.
- Find the beta, then optionally measure the gaps to check it with a tape.
Many gyms mark a route's start and finish with a strip of tape under the hold,
its colour giving the grade. tape.js looks for that strip next to each hold:
thin, straight, pointing away from the hold, and standing out from the wall.
Among the picked holds, the lowest tagged ones in the bottom half are the start
and the highest tagged one in the top half is the finish. On two photos of one
taped gym it found 25 of 30 tags. Bright tape is reliable; purple and black
tape look like shadow, so a dark route may get no marks and fall back to the
lowest and highest holds.
All points must lie on the same flat wall panel. Distances are between the selected points projected onto that panel; protruding holds and routes crossing wall corners are not reconstructed in 3D. The reported rise is the span along that panel's up-axis, not a gravity-referenced vertical height. Real accuracy still needs comparison with tape-measured gaps. Two-point calibration does not remove perspective distortion.
The browser never assumes a wall height. POST /api/measure requires an explicit
calibration and either points (image pixel coordinates) or route (detected
hold IDs). For example:
{
"id": "<photo id returned by /api/photo>",
"points": [[100, 800], [400, 400]],
"calibration": {
"method": "reference",
"points": [[0, 0], [1000, 0]],
"metres": 1
}
}For a grid, use {"method":"grid", "corners":[[0,0],[1000,0],[0,1000],[1000,1000]], "cols":10, "rows":10, "spacing_m":0.1}. Corners are TL, TR, BL, BR.
Gap from/to values index the submitted sequence, not detector IDs.
POST /api/beta takes the same calibration, plus route as detected hold IDs
and an optional height_m. seed is the hold the route was picked by, and only
holds reachable from it count, since a gym sets several routes in one colour.
start (one or two IDs) and finish are the taped holds. A start above the
middle of the route, a finish below it, or either one the search cannot use is
dropped, and marked in the reply says which were kept. It has no assumed wall height either: a
beta used to be computable from a scale /api/measure would have refused, which
is how a calibration putting holds across 11.4 m of wall once reached the
geometry unchallenged.
A calibration also gives the wall plane, so detections it cannot place are
reported as off_wall rather than entering the search: masks across the
projective horizon, masks whose wall-plane span is not a hold's, and masks
beyond the calibrated block by more than a boulder's height. On 542 detections
across four gym photos the span bounds dropped nothing, with holds reading 2 to
66 cm against bounds of 1 cm and 1.2 m, so they are a guard against a wrong
scale rather than a filter that fires. The horizon bands do real work on a
steeply angled wall, where the vanishing line falls inside the frame. None of
this identifies a brush lying on the mat in front of a vertical wall, which
projects to a sensible size in a sensible place; that known detector failure
needs the floor line or a learned on-wall test and is still open.
Photos are stored locally; detections remain in memory and must be uploaded
again after a server restart. Detection selects MPS, CUDA, or CPU automatically.
The trained weights must exist at runs/v1_960_best.pt.
Checks: .venv/bin/python tests.py and
.venv/bin/python -m unittest test_measurement test_figure (API tests require httpx).
Live at https://climbing-beta-theta.vercel.app
public/ is a measuring tool a climber can open on their phone, deployed on
Vercel. Detection runs in the browser and the photo is never uploaded.
That split is forced rather than chosen. The detector cannot be deployed with
the API: torch is 558 MB against Vercel's 500 MB Python bundle, and there is no
GPU. So the weights are exported to ONNX and run in the page over WebGPU,
through onnxruntime-web. Ultralytics' own browser library was tried first and
panics inside its WASM segmentation path on this model, so public/detect.js
does its own letterboxing and NMS instead. On a 24 MP wall photo it returns
152 holds where the Python pipeline returns 152, in 0.67s.
The export costs 0.3 points of recall, 96.6% at 1280px against 96.9% for the
.pt model at 1600px, measured on the test split. export_web.py has the table.
What stays in Python is the part worth keeping in one language: the homography,
the checks that refuse a calibration, and the distances. Those have tests and
are about to be checked against a tape measure, so they are not reimplemented
in JS where the two could drift. app.py is that API, and it is stateless. The
browser holds the photo and the detections and sends the points it picked, so
there is no upload, no cache and no photo id.
Boxes, not masks: detect.js ignores the 32 mask coefficients and uses a box
centre where the Python pipeline uses a mask centroid. On an asymmetric hold
that differs by a centimetre or two. Worth revisiting once there is a real
error figure to compare it against.
No distance this project produces has been checked against a real one yet, so the app collects that check where it happens. After measuring, type what the tape reads beside each gap (inches or centimetres) and the app shows the error on the spot. Save this check writes one file with the photo, the taps, the calibration, the measurement and the tape readings, and on a phone it opens the share sheet so the file can be sent straight on.
Written down by hand, a reading has to be matched to the right pair of taps afterwards from a description like "blue jug to pink crimp", which is where ground truth goes wrong. Saved with the taps, it cannot.
.venv/bin/python check.py hold-distance-*.json --photoscheck.py reruns every saved measurement through the API's own code and sets
aside any file that does not reproduce, then reports the error. It also
separates the two causes. A wrong bolt spacing or a miscounted grid scales
every gap by one factor, so tape over measured holds steady; tapping error
scatters. With three or more gaps it says which, and when it is the scale, what
spacing would fit: 6 inches entered on an 8 inch wall comes back as a
consistent x1.333 and names 8 in, while a grid miscounted by one comes back as
a spacing no gym uses and says to recount.
After measuring, Find the beta runs the search on the server and plays it back
as a figure climbing the photo, hands and feet on the route. The
browser only plays frames; figure.py works out every one of them, so what is
drawn is what was computed.
The search decides where the hands and feet go and roughly where the hips
sit. The figure settles the rest around them and is not allowed to change the
answer.
test_figure.py holds it to that. Every stance is held exactly; while one limb
moves, the other three stay on their holds; bones keep their length in three
dimensions to a tenth of a millimetre; the figure is drawn through the same
calibration as the holds, so it has their perspective; and a stance no body of
that height can hold is drawn stretched and red, never shortened onto a hold it
does not reach. Each of those was checked by breaking the code on purpose and
confirming the test fails.
Two things the first version got wrong, both found by looking at it. A body built from the standard segment table spans 1.20 times height from sole to palm, short of what climbers reach, and half the frames of an easy ladder came out over-reaching; shoulders now lift and toes point, within limits, as real ones do. And bends were worked out flat in the wall plane, so a fifth of the limbs folded sharper than a right angle across the photo; elbows and knees now bend partly out of the wall, which brought that to 9%.
The overlay's first finding was about the beta, not the drawing. On a real wall it showed one hand reaching the top while the other never left its first hold: legal under the reach limits, and nothing like how anyone climbs. The search stopped at the first hand on the finish. It now ends matched, with both hands on the finish hold as most gyms require, and on that wall both hands climb.
Matching made the moves longer, and the longer moves exposed a jump: a body
solved one frame at a time sat still through a reach, then snapped its hips up
to 48 cm in a single frame. The body is now placed at each stance first and
carried between them, with the largest step 3.5 cm. The ladder test had stayed
smooth throughout, so the real wall's hold positions are in test_data/ and
checked as well.
Each move is also timed the way a climber makes it. For a hand, the body shifts first and the hand follows; for a foot, the foot steps first and the body settles onto it. Before, every limb glided while the body slid evenly under it.
Save as video records the canvas while the beta plays through once, so the file is the same frames at the same pace as the player: MP4 where the browser can write it, WebM in Firefox. Lines are drawn at a fixed scale for the recording rather than one that depends on the screen. Stopping playback partway throws the recording away. When it finishes, the button changes to Save video and transcript: phones only open the share sheet straight after a tap, and the one that started the recording is too old by then.
A transcript is saved with it. It has the moves in words, with the direction and length of each and when it happens in the video, a prompt built from them for a video model, and every frame's joints in video pixels with the time it was drawn. On a recorded beta the video's frames change a median 6 ms from the times the transcript gives.
The prompt alone will not make a video model follow a beta. Text is loose about left and right, order and position, and those are the beta. The pose video is what carries the moves; the prompt describes the scene around them. To tell whether a generated video kept them:
.venv/bin/python video_check.py climbing-beta-*.json generated.mp4 --draw checked.mp4It finds the climber in each frame with an Ultralytics pose model and reports
how far each wrist and ankle is from where the beta put it, in centimetres on
the wall, then goes stance by stance: whether the limb that moved landed within
15 cm of its hold, how far the other three drifted while it moved, and how
often left and right came out swapped. A video longer or shorter than the
original is stretched to fit. --draw writes the video back with the beta in
green and what was found in red.
Each frame is lined up with the photo, which the transcript carries, by
matching the wall between them and fitting a homography, so the video only has
to be shot from about the same spot. It is redone every second, for a phone
held by hand. On the gym photo warped to a phone's 16:9 from a step to the
side, and darkened, the route holds land within 0.15 px; a real video adds
parallax from volumes, blur and people in the way, so the line-up count is in
the report.
It is for videos with a person in them. The pose model does not take the
app's stick figure for one, so the app's own video comes back not seen
throughout, rather than passing. On ClimbInst photos it does find climbers
on the wall from behind, with left and right the right way round.
test_video_check.py feeds it videos with a known fault each (an offset, a
hand that never arrives, a still foot that slides, left and right swapped, a
climber who drops out of frame) and every one is caught; each was also checked
by breaking the checker and watching a test fail.
A person does not climb at the beta's pace, so for a video of one:
.venv/bin/python video_check.py climbing-beta-*.json me.mp4 --own-pace --draw checked.mp4This drops time altogether and keeps order. Every stance of the beta is given the moment of the video that fits it best, each later than the one before, and the whole set is chosen together, so a stance is matched where you held it, not where a limb passed by on the way somewhere else. A stance is reached when all four limbs are on its holds: hands within 15 cm at the wrist, feet within 25 cm at the ankle, which sits further from the toe. For one not reached it says where each stray limb was instead, such as a foot 40 cm right of the beta's foothold. Of everyone in a frame, the climber is whoever looks most like a stance of the route, so people on the mats are passed over.
The tests climb the beta at random paces with moves of up to three seconds, and then wrongly: a different foothold, two moves in the other order, two stances out of order, a quarter of the limbs lost by the pose model, someone standing on the mat throughout. Each is reported as it should be.
To film one: save the beta as a video in the app first, since that writes the transcript; then film the climb on a tripod or held still, from where the photo was taken, with the whole route and your feet in frame.
What the overlay still cannot vouch for is whether the beta is the one a climber would choose. That, and the reach limits it runs on, are what the gym trip is for.
Run the whole thing locally with one process:
.venv/bin/python -m uvicorn app:app --port 8000Deploying needs a Vercel account:
npx vercel deploy --prod.vercelignore keeps the 4.2 GB dataset, the 1.1 GB venv and runs/ out of
the upload, which leaves about 39 MB, nearly all of it the model. Vercel
installs from uv.lock, so the lock has to be regenerated whenever the
dependencies move: a stale one still listing torch made the first deploy 5.8 GB
against a 500 MB limit.
uv sync --extra dev
.venv/bin/python prepare.py
.venv/bin/python train.py --model yolo11s-seg.pt --epochs 60 --imgsz 960 --batch 6 --name v1_960
.venv/bin/python -m experiments.v3_beta photo.jpg -1 "150,1750,4.5" 1.68The last three arguments are the route group (-1 picks the best-scoring one), a
scale reference given as y_top,y_bottom,metres, and climber height in metres.
--extra dev is what installs torch, Ultralytics and the export tooling. The
default dependencies are only what the deployed API needs, because torch alone
is larger than Vercel's whole Python bundle.
Use .venv/bin/python rather than uv run. uv run re-syncs the environment
and takes a lock on it, which deadlocks against any other uv process, including
a long download.
AGPL-3.0, see LICENSE. This project imports Ultralytics, which is AGPL-3.0, so anything built on it and distributed has to be AGPL too. Details and the dataset terms are in THIRD_PARTY.md.