Surface defect detection in engine cylinder block manufacturing is critical for ensuring product quality. Traditional manual inspection methods suffer from inefficiency and high labor costs. This paper proposes a vision-based defect detection framework combining a pix2pix generative adversarial network (GAN) and YOLOv5 deep learning model to address challenges caused by limited defect datasets in industrial applications. The system achieves 98.4% detection accuracy with processing times under 0.5 seconds per image, demonstrating significant improvements over conventional approaches.
1. System Architecture
The proposed framework comprises three core components:
$$ \text{System} = \{ \mathcal{G}_{pix2pix}, \mathcal{P}_{image}, \mathcal{D}_{YOLO} \} $$
where 𝒢pix2pix denotes the image generation module, 𝒫image represents image preprocessing functions, and 𝒟YOLO indicates the YOLOv5 detection network. A typical engine cylinder block casting with surface imperfections is shown below:

2. Key Technical Components
2.1 Dataset Augmentation with pix2pix GAN
For engine cylinder block defect generation, the pix2pix model minimizes the conditional adversarial loss:
$$ \mathcal{L}_{cGAN}(G,D) = \mathbb{E}_{x,y}[\log D(x,y)] + \mathbb{E}_{x,z}[\log(1-D(x,G(x,z)))] $$
Combined with L1 regularization:
$$ \mathcal{L}_{L1}(G) = \mathbb{E}_{x,y,z}[\|y – G(x,z)\|_1] $$
This enables high-fidelity defect synthesis from limited samples. Table 1 compares natural and synthetic defect characteristics.
Defect Type | Natural Samples | Synthetic Samples | IS Score | FID |
---|---|---|---|---|
Shrinkage | 185 | 206 | 1.46±0.16 | 15.79 |
Crackle | 10 | 64 | 1.05±0.15 | 16.29 |
Sand Hole | 50 | 62 | 1.11±0.24 | 18.63 |
2.2 Image Preprocessing Pipeline
The enhancement process combines:
- Adaptive histogram equalization
- Butterworth bandpass filtering:
$$ H(u,v) = \frac{1}{1 + \left(\frac{D(u,v)D_0}{D^2(u,v)-D_0^2}\right)^{2n}} $$ - Morphological top-hat transformation:
$$ T_{hat}(f) = f – (f \circ b) $$
2.3 YOLOv5 Optimization
The detection network employs modified anchor boxes optimized for engine cylinder block defects:
$$ \text{Anchors} = \left\{
\begin{aligned}
&(12,16), (19,36), (40,28), \\
&(36,75), (76,55), (72,146), \\
&(142,110), (192,243), (459,401)
\end{aligned}
\right\} $$
Parameter | Value |
---|---|
Input Resolution | 640×640 |
Batch Size | 16 |
Initial LR | 0.01 |
Momentum | 0.937 |
Weight Decay | 0.0005 |
3. Performance Evaluation
Testing on 696 engine cylinder block images from production lines yielded:
$$ \text{Precision} = \frac{TP}{TP+FP} = 95.4\%,\ \text{Recall} = \frac{TP}{TP+FN} = 98.0\% $$
$$ mAP_{@0.5} = 98.4\%,\ \text{Inference Time} < 500ms $$
Defect Class | AP | F1-Score |
---|---|---|
Shrinkage | 98.4% | 0.942 |
Crackle | 96.7% | 0.981 |
Sand Hole | 99.3% | 0.952 |
Dirty | 99.5% | 0.992 |
4. Industrial Implementation
The deployed system for engine cylinder block inspection features:
- MV-CS200-10GM CMOS camera (5472×3648)
- MV-LRDS-170-20-W环形光源
- Intel i7-10750H + Tesla T4 GPU
Field tests demonstrated 98.4% detection accuracy with 0.57% false positive rate, significantly outperforming human inspectors in consistency and throughput.
5. Conclusion
This research presents a robust solution for engine cylinder block defect detection under small-sample conditions. The pix2pix-YOLOv5 framework effectively overcomes data scarcity challenges while maintaining computational efficiency for production-line deployment. Future work will extend the method to other automotive components and 3D defect analysis.