
More and more factories want AI to take over manual visual inspection. A common story is that accuracy looks great in the lab, then misjudgments pile up once the system is on the line. The problem is rarely the model itself — it is what happens before and after it. These are the steps we recommend.
1. Define what a defect is
Work with your quality team to list the defect types and the acceptable size and severity, and prepare reference samples. If inspectors do not agree with each other, the AI cannot learn a consistent standard either.
2. Lighting matters more than the model
Good lighting makes defects stand out on their own and makes the model's job much easier:
- Backlight: for outlines, holes and defects that let light through.
- Coaxial light: for scratches and dents on reflective surfaces.
- Low-angle ring light: highlights surface relief, engraving and fine scratches.
Shield the setup from ambient light and choose the right camera resolution, lens and shutter speed so images stay sharp while parts are moving.
3. Collect and label data
Defective parts are usually far rarer than good ones, so imbalanced data is normal. Keep collecting samples of each defect type, label them consistently, and set aside part of the data for validation only.
4. Choose the right model type
| Task | What it does | When to use it |
|---|---|---|
| Classification | Judges the whole image OK / NG | Obvious defects, no location needed |
| Object detection (e.g. YOLO) | Draws boxes around defects with their class | You need defect location and count |
| Segmentation | Outlines the exact defect shape | You need to measure defect area |
5. Use the right metrics
Production lines usually care most about the escape rate (defective parts passed as good) and the false reject rate (good parts rejected). The two pull against each other, so set the decision threshold together with quality control instead of looking at a single accuracy figure.
6. Deploy at the edge
For real-time response and to keep data on site, models usually run on an edge computing device next to the line. Model compression and quantization (e.g. INT8) let you meet the line's cycle time with limited computing power.
7. Integrate with the line and keep improving
- Trigger image capture with a sensor or PLC signal so every part is imaged in the same position.
- Send the result as a DO signal to the PLC or reject mechanism.
- Store NG images and decisions for traceability and retraining.
- Review misjudged cases regularly and keep extending the dataset.
Written by the Balin R&D team as general technical guidance. Always check your specific product requirements and the latest regulations. Related service: AI Vision


