Deep Learning and GAN-Based Surface Defect Detection for Engine Cylinder Block

Abstract

In industrial applications for engine cylinder block surface defect detection, the scarcity of defect datasets often leads to low accuracy and slow detection speeds. This paper proposes a machine vision-based defect detection system that integrates deep learning and generative adversarial networks (GANs). To address the challenge of limited training data, the pix2pix GAN model is employed to augment defect image datasets. Traditional image preprocessing techniques, including grayscale enhancement and band-pass filtering, are combined to highlight defect features. The YOLOv5 network is then utilized for defect recognition. A hardware-software system is developed and validated on an automotive production line, achieving an overall defect detection accuracy of 98.4% with a processing time of less than 0.5 seconds per image. This approach effectively resolves the limitations of small-sample datasets in deep learning training, demonstrating significant potential for industrial inspection of engine cylinder blocks.


1. Introduction

Engine cylinder blocks are critical components in automotive manufacturing, requiring stringent quality control. During casting and machining processes, defects such as shrinkage pores, cracks, sand holes, and surface contaminants inevitably arise. Traditional manual inspection methods are labor-intensive and inefficient, necessitating automated solutions. While convolutional neural networks (CNNs) have improved defect detection accuracy, their performance heavily relies on large-scale datasets. In practical scenarios, acquiring sufficient defect samples for engine cylinder blocks remains challenging due to low defect occurrence rates.

Recent advancements in generative adversarial networks (GANs) offer promising solutions for dataset augmentation. Unlike conventional methods (e.g., noise injection, rotation, or flipping), GANs generate synthetic defect images that closely mimic real-world variations. This paper integrates the pix2pix GAN model with YOLOv5 to enhance detection accuracy while maintaining computational efficiency.


2. Methodology

2.1 System Framework

The proposed system comprises two modules:

  1. Hardware: A CMOS camera (MV-CS200-10GM) and LED lighting (MV-LRDS-170-20-W) capture high-resolution images of engine cylinder block surfaces under controlled illumination.
  2. Software:
    • Data Augmentation: Pix2pix generates synthetic defect images from limited samples.
    • Image Preprocessing: Grayscale enhancement and band-pass filtering accentuate defect features.
    • Defect Detection: YOLOv5 localizes and classifies defects in real time.

2.2 Image Preprocessing

Defect features are enhanced using:

  1. Grayscale Enhancement: Adjusts pixel intensity to improve contrast.
    Ienhanced​(x,y)=αIoriginal​(x,y)+β
    where α and β control contrast and brightness.
  2. Band-Pass Filtering: Isolates defect-related frequency components. 1 & \text{if } D_0 – \Delta D \leq D(u,v) \leq D_0 + \Delta D, \\ 0 & \text{otherwise.} \end{cases} $$

2.3 Pix2pix GAN for Data Augmentation

The pix2pix model translates defect-free images into defect-containing counterparts. Its loss function combines adversarial and L1 losses:
LGAN​(G,D)=Ex,y​[logD(x,y)]+Ex,z​[log(1−D(x,G(x,z)))]
LL1​(G)=Ex,y,z​[∥yG(x,z)∥1​]
Ltotal​=LGAN​+λLL1​
where λ balances the two objectives.

2.4 YOLOv5 for Defect Detection

YOLOv5 divides input images into grids, predicting bounding boxes and class probabilities. The confidence score for each box is:
Confidence=Pr(Object)×IoUpredtruth​
The loss function includes classification, localization, and confidence losses:
L=Lcls​+Lbox​+Lobj​


3. Experimental Setup

3.1 Dataset and Training

  • Original Dataset: 87 defect-free and 185 defective images (2580×1944 pixels) of engine cylinder blocks.
  • Defect Distribution:Defect TypeCountShrinkage204Crackle41Sand Hole56Dirty38
  • Augmented Dataset: Pix2pix generated 206 shrinkage, 64 crackle, and 62 sand hole defects.

3.2 Evaluation Metrics

  • PrecisionTP+FPTP
  • RecallTP+FNTP
  • mAP: Mean average precision across classes.
  • Inception Score (IS): Measures image quality and diversity.
  • Fréchet Inception Distance (FID): Compares feature distributions between real and synthetic images.

4. Results and Analysis

4.1 Data Augmentation Performance

Pix2pix-generated images achieved IS and FID scores comparable to real defects:

Defect TypeIS (Real)IS (Synthetic)FID (Real)FID (Synthetic)
Shrinkage1.471.4615.5515.79
Crackle1.041.0515.8916.29
Sand Hole1.121.1120.7218.63

4.2 Defect Detection Accuracy

After 1,000 training epochs, YOLOv5 achieved:

Defect TypePrecisionRecallmAP
Shrinkage92.7%95.7%98.4%
Crackle97.9%98.3%96.7%
Sand Hole92.6%98.0%99.3%
Dirty98.4%100%99.5%
Overall95.4%98.0%98.4%

4.3 Computational Efficiency

  • Single-image inference time: ​**<0.5 seconds**
  • Hardware: NVIDIA Tesla T4 GPU, 16 GB VRAM

5. Discussion

5.1 Key Contributions

  1. Small-Sample Adaptation: Pix2pix effectively augmented rare defects (e.g., crackle), enabling robust YOLOv5 training.
  2. Industrial Applicability: The system’s speed and accuracy meet production-line requirements for engine cylinder block inspection.

5.2 Limitations and Future Work

  • False Positives: Minor surface irregularities (e.g., machining marks) were occasionally misclassified.
  • Generalization: Testing on diverse engine cylinder block designs and materials is needed.

6. Conclusion

This work presents a deep learning framework for engine cylinder block surface defect detection, combining pix2pix-based data augmentation and YOLOv5. The system achieved 98.4% mAP with real-time performance, addressing the critical challenge of limited defect samples in industrial settings. Future efforts will focus on multi-modal defect detection and edge computing deployment.

Scroll to Top