PyCon Portugal 2026

From Pixels to Plastic: Multi-Agent Python Pipelines for 3D-Printed Repair

A snapped fridge handle. A missing washing-machine knob. A bracket that broke off your scooter. The replacement part costs three pounds and ships in two weeks, or you throw the whole thing away.

This talk is about teaching Python to fix it instead.

This talk walks through an open-source Python pipeline that takes a photo of a broken object and produces a 3D-printable patch automatically. Seven specialised agents handle calibration, segmentation, measurement, thickness estimation, mesh generation, validation, and printing. Each agent runs multiple competing computer-vision strategies, then uses an LLM to choose the most trustworthy result through a consensus protocol. The validated mesh streams straight to a BambuLab printer over MQTT, and a finished patch comes off the bed by the time the talk ends.

The whole system is built on Python, using frameworks such as FastAPI, OpenCV, Shapely, trimesh, SAM, Depth Anything, and a Three.js front end, plus an LLM acting as the decision engine inside every agent. You'll see how far Python's ecosystem reaches when the output has to obey physics, and where the interesting failures live.


Most "AI for the physical world" coverage in 2026 is about robots and autonomous vehicles. This talk is about something smaller and stranger: getting a Python program to look at a broken object and print the missing piece.

The core problem: natural language and even photos are ambiguous, but geometry is not. A wall thickness of 0.1mm instead of 1.0mm is not a minor error. It is an unprintable model and wasted filament. "Generate and hope" doesn't work when the output has to fit in your hand.

I'll walk through the system end-to-end: a real, open-source, seven-agent pipeline.

  1. The repair scenario. Real before-and-after objects passed around the audience. Repair is a more honest test of physical AI than from-scratch generation because there is a ground truth, the original part, and a literal pass/fail question: does the new piece fit?

  2. Seven agents, one pattern. A walk through the pipeline: Calibration, Segmentation, Measurement, Thickness, Mesh, Validation, and Print. The same architectural pattern repeats at every stage. Each agent runs multiple computer-vision strategies, then hands all candidate results to an LLM that picks the best one, or blends them, and explains its reasoning.

  3. The consensus protocol. A close look at the calibration and thickness agents, where consensus matters most. Calibration runs ArUco markers, HEIF depth, reference-line detection, WebXR, and a vision fallback in parallel. Thickness estimation combines LiDAR, multi-view stereo from short videos, side-photo geometry, and monocular depth from Depth Anything. The LLM sees each candidate with its confidence score, flags implausible values, and produces one authoritative result with an explained rationale.

  4. Segmentation, measurement, mesh. SAM handles segmentation from point prompts, with the LLM assessing mask quality and suggesting better click points. OpenCV contour analysis handles measurement, while the LLM arbitrates between competing measurements. Shapely and trimesh generate the patch mesh, with the LLM assessing printability and suggesting thickness adjustments before anything goes near the printer.

  5. Validation and the live print. The validation agent cross-checks the pipeline results, verifies the mesh, and makes a final go/no-go judgment. Then bambulabs api over MQTT/FTP streams the STL to the printer on stage. Print status flows back into the system in real time.

  6. What this teaches us about Python in the wild. The transferable patterns are multi-strategy execution, LLM arbitration, structured outputs, and continuous validation. They work for any AI system where outputs must satisfy hard constraints: medical imaging, financial document generation, robotic control, and scientific simulation. Python is more capable here than people realise, and the under-appreciated libraries that make it possible, including Shapely, trimesh, SAM via transformers, Depth Anything, and bambulabs_api, deserve a wider audience.


Audience Level: Intermediate What are the main topics of your talk?:

ulti-agent systems, computer vision, 3D printing, physical AI, repair, FastAPI, OpenCV, SAM, Depth Anything, Shapely, trimesh, LLM consensus, Python hardware integration