Skip to content
MiraiTech
All work

Case study · AI

Visual inspection on a factory line

Cameras watch parts on a moving line. A detection model flags surface and assembly defects as they pass, and the operator dashboard shows the frame, a heatmap and the reason, so a person can confirm or override the call in a few seconds.

Year
2024
Duration
5 months, then ongoing partnership
Type
AI
Status
In production
Visual inspection on a factory line, main screen

Results

  • 99.1% defect recall
  • 38 ms per frame on an edge GPU
  • 60% fewer manual inspections

The problem

A parts manufacturer in Kanagawa inspected every unit by eye at the end of the line. Inspectors caught most defects, but fatigue pushed miss rates up late in each shift, and once a part was scrapped there was no record of what the defect looked like. An off-the-shelf vision system had been trialed and abandoned because it flagged 30% of good parts and nobody could tell why.

What we built

We built a pipeline that takes frames from the existing line cameras and runs a YOLOv8 model, fine-tuned on the plant's own labeled defects, on an edge GPU. Operators see every flag with the frame, a heatmap and a plain-language reason, and confirm or override it with one tap. Each decision is stored in ClickHouse and feeds the next training cycle. The model never stops the line on its own. Operators decide what happens to each part.

Inference on site
YOLOv8, exported to TensorRT, runs at 38ms per frame on a single GPU in the plant, so no images leave the factory network.
Flags with a reason
Each detection comes with a Grad-CAM heatmap and a short template reason ("scratch, 4mm, top-left face"), so operators can see why a part was flagged.
One-tap feedback
Confirm and override buttons on a touch dashboard. Overrides become labeled examples and are reviewed before they enter the training set.
Defect analytics
ClickHouse stores every frame decision. The plant can now see defect trends by shift, station and supplier, which it never could before.
Shadow-mode rollout
A new model version runs next to the current one for a week. It is promoted only if it matches or beats recall on the held-out set, and operators never see it before then.

How it works

Detection runs on an edge GPU, operators confirm each flag, and their decisions feed retraining.

  1. 01

    Capture

    Line cameras → frame sampler synced to the conveyor encoder

  2. 02

    Inference

    YOLOv8 / TensorRT on the edge GPU → detections + Grad-CAM heatmaps (38ms)

  3. 03

    Operator review

    Next.js touch dashboard shows the flag, heatmap and reason → one-tap confirm or override

  4. 04

    Decision store

    Every frame decision and operator action written to ClickHouse

  5. 05

    Retrain and promote

    Overrides labeled → nightly fine-tune → shadow-mode comparison → gated promotion

Screens

Visual inspection on a factory line, screen 1
1 / 2

Decisions

YOLOv8 (PyTorch)AI / ML
Fast enough for real-time detection on modest edge hardware, and easy to fine-tune on the small, imbalanced defect dataset we started with. Segmentation models were more accurate on paper but too slow for the line.
FastAPIBackend
A thin inference service on the edge box serves detections over a local API, so the dashboard, logging and future stations all share one contract.
ClickHouseData
The per-frame decision log grows by millions of rows a week. ClickHouse keeps the per-shift and per-supplier analytics interactive without a separate warehouse.
OpenTelemetryInfrastructure
Inference latency, camera dropouts and GPU memory are traced end to end. When the line slows down, we can tell within minutes whether the model, a camera or the network is responsible.

What went wrong

Night-shift lighting

Problem
Accuracy dropped sharply on the night shift. The cause was the building: skylights changed the ambient light, and a model trained on day-shift frames produced 3x more false positives at night.
Fix
We added a lighting normalization step, augmented training with synthetic exposure shifts and installed a $120 diffused light panel at the inspection station. We also track false positives per hour, so drift shows up before operators start complaining.
Result
Night-shift false positives came down to within 10% of day-shift levels. The per-hour metric has since caught two degrading cameras early.

Rare defects with few examples

Problem
Hairline cracks, the most expensive defect class, appeared in fewer than 40 labeled frames. The model either ignored them or flagged every scratch as a crack.
Fix
We ran a focused data collection sprint with the plant's QA lead and used copy-paste augmentation to transplant crack regions onto good parts. Then we trained a small secondary classifier that only runs on frames the detector marks as ambiguous.
Result
Crack recall rose from 61% to 97% with no measurable increase in overall false positives.

Team and stack

Hiroshi owned the inference pipeline, the edge deployment and the operator dashboard. Kenta built the inference service and the shadow-mode rollout. Hiroki built ingestion, labeling and the ClickHouse analytics layer.

  • PyTorch
  • YOLOv8
  • FastAPI
  • Next.js 15
  • ClickHouse
  • Redis
  • OpenTelemetry
  • Docker