How do you handle small defect detection in manufacturing?
How do you handle small defect detection in manufacturing?
"Small defect detection is a core challenge in industrial vision. The difficulties are:
- Extremely low pixel ratio: Micro-scratches may occupy only 0.01% of the image
- Low contrast: Subtle difference from background, barely visible to human eyes
- Severe data imbalance: Defect samples are rare, normal samples dominate 99.9%
- Real-time constraints: Production line speed doesn’t allow complex computation"
“First, optimize the imaging system to make defects physically prominent”
- Optical solution: Use low-angle ring light to enhance scratch shadows; coaxial light for surface dents
- Camera selection: High-resolution cameras (e.g., 25MP) with telecentric lenses to avoid perspective distortion
- Multi-spectral imaging: Visible + UV light combination—some material defects are more obvious under UV"
“For data scarcity, use augmentation + synthesis combined”
- Traditional augmentation: Random rotation, brightness/contrast adjustment, CutMix, Mosaic (forcing model to learn small objects)
- Defect synthesis: Use Photoshop/GAN to synthesize scratches/bubbles on normal images with auto-labeling
- Copy-Paste: Extract defect regions from real images and paste onto different backgrounds
- GAN generation: Use CycleGAN or Diffusion Models to generate realistic defect samples"
“At model level, use multi-scale + attention mechanisms”
Option A: Feature Pyramid Enhancement
- Use FPN or PANet to fuse deep semantic features with shallow positional features
- Small defects retain more detail on shallow feature maps (P2/P3)
Option B: High-resolution Input
- Increase input from 640×640 to 1280×1280 or higher
- Use Sliding Window or Image Pyramid for ultra-large images
Option C: Transformer Assistance
- Add Swin Transformer Blocks after YOLO backbone for global context
- Use self-attention to amplify defect-background differences
Option D: Dedicated Small-object Head
- YOLOv8’s P2 detection head (4× downsampling instead of default 8×)
- Add Tiny Object Prediction Layer in anchor-free design"
“Make the model focus more on small defects”
- Focal Loss: Reduce weights for easy samples (normal regions), focus on hard samples (defects)
- Dice Loss: For segmentation tasks, directly optimize IoU, more sensitive to small objects
- OHEM: Only train on hardest examples with highest loss
- Label Smoothing: Prevent over-confidence on normal samples
- Multi-scale Training (MST): Randomly change input size each epoch, forcing scale adaptation"
“Finally, system-level optimization ensures reliability”
- Multi-frame verification: Trigger alarm only when defect detected in N consecutive frames
- Multi-model cascade: YOLO fast screening → Transformer fine segmentation → Traditional CV (Blob Analysis) final confirmation
- Dynamic threshold: Auto-adjust sensitivity based on line speed and lighting changes
- Human-in-the-loop: Low-confidence samples sent for manual re-inspection, results fed back to training set"
For small defect detection, I implement a five-level strategy:
First, optimize imaging. Use low-angle ring light to enhance scratch shadows, with 25MP cameras and telecentric lenses to physically highlight defects.
Second, solve data scarcity. Use Mosaic, CutMix augmentation plus GAN-synthesized defects, expanding training data by 10×.
Third, model architecture. Add YOLOv8’s P2 detection head for 4× downsampling features, integrate Swin Transformer for global context, and use FPN multi-scale fusion.
Fourth, training strategy. Apply Focal Loss for hard examples, OHEM for mining difficult samples, plus multi-scale training.
Fifth, system reliability. Multi-frame verification reduces false positives. YOLO-Transformer-traditional CV three-stage cascade. Human-in-the-loop for low-confidence samples.
This solution improved 0.1mm scratch detection from 78% to 96% with <0.5% false positive rate in my previous phone mid-frame project, meeting UPH requirements.
更多推荐



所有评论(0)