A Lens Studio project that detects a real coffee cup through your Spectacles and rises steam off it. The detector was trained in one click — no machine-learning setup required — and you can retrain it on anything you like.
This Lens is a working example: the bundled coffee cup detector (coffee.onnx) was
trained exactly the way described below — real footage recorded on the Spectacles, plus
synthetic frames generated with FLUX. Everything here shows how it was made, how to retrain
it on anything you like, and how to tweak it.
The detector is trained on Replicate — open the link, fill in the form, hit Run. That's the whole pipeline:
⚠️ Download your result right away. Replicate only keeps the output.zipfor about an hour. Refresh the run page often and grab the file as soon as it finishes — once it expires you'll have to retrain.
- Real footage — upload a
.zipof frames captured through Spectacles (images_zip_url). - Synthetic data (FLUX) —
FLUX.1-schnellgenerates extra POV training frames from text prompts and mixes them in, so you don't need to capture hundreds of images yourself. - Auto-labeling — SAM 3 draws the bounding boxes for you against your class names.
- Train + export — YOLOv7-tiny is fine-tuned and exported to a 224×224 SnapML ONNX.
A synthetic FLUX frame with the bounding box SAM 3 auto-labeled for training — no manual annotation:
You get back a single .zip containing best.onnx, best.pt, data.yaml, and classes.txt.
The knobs that matter on the Replicate form:
| Input | What it does |
|---|---|
images_zip_url |
Your real Spectacles frames (the more, the better). |
classes |
What to detect, e.g. coffee cup or banana, apple. |
synthetic_count |
How many FLUX frames to generate (0 = real footage only). |
synthetic_prompts |
One POV scene per line — describe angle, object, surface, lighting. |
epochs |
Training length (200 is a good default). |
➡️ Full pipeline details: /Users/stijnspanhove/scripts/cog-spectacles-yolov7-trainer
- Unzip the Replicate output and rename
best.onnx→coffee.onnx. - Replace Assets/coffee.onnx with it.
- If you changed the class name, update the label in
Assets/Scripts/CoffeeMLController.ts:209
(
new CoffeeDetector(["coffee cup"], ...)).
- Share the trainer — the Replicate model is public. Anyone can open the link and train their own detector (their own objects, their own footage) with no code.
- Share the Lens — publish this project from Lens Studio to your Spectacles, or send the Lens link so others can try it on their own glasses.
- Open the project in Lens Studio and push it to your Spectacles (or run it in Preview).
- Pinch to place a surface in front of you (a tabletop works best).
- Look around to scan. Point your gaze at a real coffee cup.
- When it's detected, steam rises off the cup and "Coffee cup found" appears briefly.
No cup handy? Toggle previewSteamOnStart ON in the CoffeeExperienceController to show the
steam effect in front of the camera without placing or detecting anything.
The scene includes a debug overlay that shows exactly what the model sees: a small
screen-space inset of the live camera frame with the detection boxes drawn on top. It's driven
by the DetectionDebugOverlay component — toggle showCameraFeed and tune the panel
position/color in the Inspector. Use it to confirm the model is locking onto the cup (and where)
before worrying about the 3D steam placement.
The "score" is the model's confidence threshold — how sure it must be before it accepts a
detection. It lives on the CoffeeMLController component as the scoreThreshold slider
(0–1, default 0.5) — see
Assets/Scripts/CoffeeMLController.ts:31.
- Lower it (e.g.
0.3) → detects more easily, but more false positives (steam on non-cups). - Raise it (e.g.
0.7) → only fires on confident matches, but may miss cups.
You can drag the slider live in the Inspector during Preview — it updates every frame.
Related knobs on the same component:
iouThreshold(default0.45) — overlap cutoff for merging duplicate boxes.frameSkip(default3) — run inference every N frames; higher = better battery/perf.
| File | Role |
|---|---|
| CoffeeMLController.ts | Runs coffee.onnx on the camera feed, emits detections. |
| CoffeeDetector.ts | Decodes YOLO output into boxes + scores (NMS). |
| CoffeeExperienceController.ts | Surface placement, places & smooths the steam on the cup. |
| Assets/coffee.onnx | The trained detector — swap this to detect anything. |
Built for Spectacles with Lens Studio · detector trained via stspanho/spectacles-yolov7-trainer
Created by Pavlo & Stijn — pavlo-stijn.dev


