
What it is
You give it a photo of a metal casting. A Gemini agent runs up to three checks and writes an inspection report.
| Step | Tool | Output |
|---|---|---|
| Classify | ViT-Tiny | defective or OK, with confidence |
| Locate | ResNet18 + Grad-CAM | boxes around the suspicious regions |
| Measure | U-Net | percent of the surface covered by the defect |
The agent only runs steps 2 and 3 when step 1 says the part is defective. Every number in the report comes from a tool call, and the report includes the full tool trace, so a reviewer can see exactly what the system looked at.

The same tools are exposed four ways: a CLI, a FastAPI service, a Gradio app and an MCP server.
Segmentation without pixel labels
The dataset only says whether each part is defective. It has no masks. So the pipeline makes its own:
- run Grad-CAM on the classifier for each defective image;
- threshold the heatmap into a mask, which gave 3,758 pseudo-masks;
- train a U-Net, written from scratch, on those masks.
Its 0.706 Dice is measured against the Grad-CAM pseudo-masks, not hand-drawn ones, so it shows how well the U-Net learned the heatmaps. It isn’t a true defect-segmentation score.
Results
From the held-out test split, recorded in models/metrics.json:
| Model | Test F1 | Notes |
|---|---|---|
| ResNet18 baseline | 92.4% | |
| ViT-Tiny, fine-tuned | 99.67% | recall 99.56%, precision 99.78% |
| MobileNetV3, distilled from ResNet18 | 99.11% | beats its teacher with 94.9% fewer parameters |
| ViT-Tiny, INT8 | 22.2 MB → 6.3 MB (71.7% smaller), 1.34x faster | |
| U-Net on pseudo-masks | Dice 0.706 | see above |
The whole six-stage pipeline (classifiers, distillation, pseudo-masks, U-Net, quantization) trained on one NVIDIA A10 in about 48 minutes. It can resume after a crash.
Weights are on Hugging Face.