Imagine: a camera and a neural network were installed on the conveyor to detect defects. At first everything is great — the model catches 7 out of 10 defective parts. But a week passes, the lighting changes, glare appears on the metal, and accuracy drops to 50%. Sound familiar? This is the classic problem of deploying AI in a factory. In this article, we'll break down why this happens and how, with the right approach to data, lighting, and retraining, you can achieve a stable 95% accuracy.
Myth 1: "It's enough to train a model on labeled photos — and it will work"
Many believe that to launch quality control with AI, you just need to collect a dataset of several hundred images of good and defective parts, train YOLO or another model, and you're done. In practice, a model trained on ideal laboratory images falls apart in real production.
Why does this happen? The neural network memorizes not the defects, but the background, lighting, and camera position. If during training all defective parts had scratches in the bottom right corner under bright light, the model will look for exactly that combination. Move the lamp or add a new type of defect — and accuracy collapses.
What to do? Collect a dataset so that it includes variations:
- different lighting conditions (morning, evening, lamps on and off);
- different angles and positions of parts (if possible);
- glare, shadows, background contamination;
- several types of defects, including rare ones.
The more diversity in the training data, the more robust the model. But there's a nuance: if there's too little data (less than 500 images per class), even perfect labeling won't save you.
Myth 2: "Lighting can be set up once and forgotten"
It seems: put a ring light, fix the camera — and everything works. But in production, lighting changes constantly: during the day the sun shines through the window, in the evening the overhead lights are turned on, at night there's emergency lighting. Plus glare from metal surfaces, which depends on the camera angle and the position of the part.
Real example: at one factory, a model for inspecting weld seams showed 85% accuracy in the morning and 60% during the day when the sun hit the parts. The solution turned out to be not in the neural network but in physics: they put polarizing filters on the camera and lens, changed the lighting angle so that glare went away from the lens. Accuracy rose to 92% without retraining the model.
Conclusion: before tweaking hyperparameters, check whether the shooting conditions are stable. The ideal option is to organize uniform diffuse lighting and eliminate direct sunlight. If this is impossible, add images under different conditions to the dataset and use augmentation (e.g., random changes in brightness and contrast).
Myth 3: "The model was trained — and it no longer changes"
Even a well-trained model degrades over time: the batch of materials changes, equipment wears out, new types of defects appear. Without regular retraining, accuracy drops. But retraining also needs to be done correctly.
Typical mistake: collect new data, add it to the old, and retrain the model from scratch. This is long and expensive. It's better to use fine-tuning on new examples while preserving old knowledge. For YOLO, this can be done by partially unfreezing layers or adjusting the learning rate.
What else is important? Organize the collection of "hard" examples: those where the model makes mistakes. To do this, you can keep a prediction log and periodically analyze which images produce false positives. This data is gold for retraining.
Myth 4: "The bigger the model, the better"
The temptation to take the largest and most modern neural network (e.g., DETR or SAM) is great. But in production, speed and computational cost are often more important. A large model may require a powerful GPU that doesn't fit the budget or can't keep up with processing parts on the conveyor.
Trade-off: YOLOv8n (nano) runs in real time on a CPU and provides sufficient accuracy for many tasks if the data is high-quality. Large models win on complex defects but require a GPU and more data for training.
Tip: start with a lightweight model. If accuracy is insufficient, move to a heavier one, but only after you've exhausted improvements to data and lighting.
How to actually achieve 95%: a step-by-step plan
- Audit the shooting conditions. Check whether the lighting is stable, whether there is glare, whether the camera resolution is sufficient. Eliminate physical problems.
- Collect a diverse dataset. Include different conditions, types of defects, backgrounds. At least 500–1000 images per class.
- Label with quality control. Labeling errors are the main cause of low accuracy. Use double checking or semi-automatic labeling with model assistance.
- Choose a model and train. Start with YOLOv8. Use augmentations, monitor class balance.
- Validate on a holdout set. Test on data the model hasn't seen and under different conditions.
- Deploy and monitor. After launch, collect error statistics and retrain the model regularly.
This process requires time and expertise. Going through all the steps on your own is difficult: you need knowledge of computer vision, experience with industrial cameras, and an understanding of MLOps. The course AI Engineering in Industry and Robotics provides a structured path: from dataset collection and lighting setup to model retraining and integration with production infrastructure. You will work through real cases and receive feedback on your solutions. More on the topic: “Computer Vision and Image Processing: How to Go from CNN to Generative Models Without Getting Stuck in the Middle”.
Who this suits and who it doesn't
Suits: process engineers, automation specialists, data scientists who want to move into industry. If you're ready to understand the physics of processes and work extensively with data — this is your path.
Doesn't suit: those looking for a quick "out-of-the-box" solution without diving into the subject area. Quality control with AI is not just running a script, but an engineering task at the intersection of optics, mechanics, and machine learning.
Implementing computer vision in manufacturing is a complex but rewarding process. The main thing is not to chase trendy models, but to systematically work on data and shooting conditions. Then accuracy will rise from 70 to 95%, and you'll get a reliable quality control tool.