In modern automotive manufacturing, the turbocharger has become a critical component for enhancing engine efficiency and power output. The increasing demand for turbocharged vehicles has placed enormous pressure on foundries to produce high-quality castings at scale. However, casting processes are inherently prone to various surface and internal defects, which compromise the mechanical integrity and functional safety of the final product. Traditional manual inspection methods are no longer adequate for the required throughput and consistency. This thesis focuses on developing a fast and accurate intelligent detection algorithm for turbocharger casting defects using deep learning techniques. The entire research pipeline includes image acquisition, preprocessing, data augmentation, network architecture design, training optimization, performance evaluation, and post-processing. The proposed algorithm achieves high recall and precision, satisfying the strict industrial requirements.
1. Introduction
Castings are indispensable in the automotive industry, accounting for approximately 17% of all components in a typical vehicle. Among these, the turbocharger is a key powertrain component that relies heavily on high-quality castings. The production environment for turbocharger castings involves complex interactions between molten metal, sand molds, binders, and atmospheric gases. Even with well-controlled processes, defects such as blows, gas holes, inclusions, and binder-related cavities can appear on the casting surface due to improper gating design, insufficient venting, or variations in pouring parameters. These defects not only affect the aesthetic appearance but also degrade mechanical properties and may lead to catastrophic failures under cyclic loading.
Currently, most foundries still employ manual visual inspection to identify and mark defects. This approach suffers from several inherent drawbacks. First, it is labor-intensive and time-consuming, creating a bottleneck in high-volume production lines. Second, the subjective judgment of inspectors leads to inconsistent results, especially when defects have vague boundaries or when workers become fatigued after long shifts. Third, the harsh environment of a foundry—noise, dust, heat, and poor lighting—further reduces the reliability of human inspection. Consequently, there is a pressing need for an automated, objective, and efficient inspection system that can operate in real time.
Recent advances in deep learning, particularly convolutional neural networks (CNNs), have demonstrated remarkable capability in image classification, object detection, and semantic segmentation. Unlike traditional machine vision methods that rely on hand-crafted features, deep learning automatically learns hierarchical feature representations from raw images. This makes deep learning algorithms highly adaptable to diverse defect appearances and complex backgrounds. The primary objective of this research is to design a deep learning based detection algorithm tailored to the specific characteristics of turbocharger casting defects, achieving both high detection accuracy and real-time processing speed.
The main contributions of this work are summarized as follows:
- Comparison and selection of image denoising algorithms: An experimental study is conducted to evaluate several denoising methods using peak signal-to-noise ratio (PSNR) and structural similarity index (SSIM). The bilateral filter achieves the best trade-off between quality and speed.
- Novel data augmentation strategy: A random cropping and translation method based on prior annotation information is proposed, combined with color space transformations, to effectively increase the dataset size without compromising defect integrity.
- Improved detection network: Based on YOLOv3, a multi-path fusion detection network is designed to enhance information flow across scales, addressing the long-path problem in the original architecture and improving the detection of small and irregular defects.
- Optimized training scheme: A two-stage transfer learning strategy is employed, along with the CIoU loss for position regression and label smoothing for class prediction, leading to better convergence and higher robustness.
- Post-processing pipeline: Defect-specific post-processing methods are developed to generate masks or circular regions for different defect types, facilitating downstream analysis and database construction.
2. Deep Learning Fundamentals and Algorithm Analysis
2.1 Multilayer Perceptron and Backpropagation
An artificial neural network (ANN), also known as a multilayer perceptron (MLP), is a computational model inspired by biological neural systems. It consists of an input layer, one or more hidden layers, and an output layer. Each neuron in a layer receives weighted inputs from the previous layer, applies an activation function, and passes the result to the next layer. The output of a neuron can be expressed as:
$$ O_{\omega,b}(x) = f\left( \sum_{n=1}^{N} \omega_n x_n + b \right) \tag{1} $$
Training an MLP requires the backpropagation (BP) algorithm, which adjusts the weights and biases to minimize the error between predicted and target outputs. The BP process involves a forward pass to compute outputs and a backward pass to propagate error gradients through the network using the chain rule. This forms the foundation for modern deep neural networks.
2.2 Convolutional Neural Networks
A convolutional neural network (CNN) is a specialized type of ANN designed for processing grid-structured data such as images. CNNs exploit local connectivity and weight sharing to dramatically reduce the number of parameters compared with fully connected networks. The main building blocks of a CNN are:
- Convolutional layers: Filters (kernels) slide over the input feature map to produce output feature maps. Each filter learns to detect a particular local pattern.
- Activation functions: Non-linear functions such as ReLU introduce non-linearity into the network, allowing it to model complex mappings. ReLU is defined as:
$$ \text{ReLU}(x) = \max(0, x) \tag{2} $$
- Pooling layers: These layers downsample feature maps, reducing spatial dimensions and increasing receptive fields. Common operations include max pooling and average pooling.
- Fully connected layers: Typically placed at the end of a CNN, they integrate global features for classification.
- Batch normalization: Normalizes the activations of each layer to stabilize training and accelerate convergence.
Convolutional operations can be mathematically represented as:
$$ y(i,j) = \sum_{u=-\infty}^{\infty} \sum_{v=-\infty}^{\infty} x(i-u,j-v) \cdot w(u,v) \tag{3} $$
where $x$ is the input feature map, $w$ is the convolution kernel, and $y$ is the output feature map.
2.3 Two-stage Object Detection Algorithms
Two-stage detectors first generate a set of candidate regions (region proposals) and then classify and refine them into final predictions. The R-CNN family is the most prominent representative.
R-CNN
R-CNN uses selective search to generate about 2000 candidate regions, resizes each region to a fixed size, and feeds them into a CNN for feature extraction. The extracted features are then classified with support vector machines (SVMs) and refined with a bounding-box regressor. Although effective, R-CNN is extremely slow because it performs a separate CNN forward pass for each candidate region.
Fast R-CNN
Fast R-CNN improves upon R-CNN by sharing the convolutional computation across all candidate regions. It applies a region of interest (ROI) pooling layer to extract fixed-length feature vectors from a single feature map. The network is trained end-to-end using a multi-task loss, but candidate generation still relies on external selective search, which limits speed.
Faster R-CNN
Faster R-CNN eliminates the external region proposal step by introducing the Region Proposal Network (RPN). The RPN predicts objectness scores and bounding-box offsets for a set of anchor boxes, enabling fully end-to-end training. This significantly boosts throughput and accuracy. The architecture is illustrated by the concept that an RPN shares the backbone with the detection network.
2.4 One-stage Object Detection Algorithms
One-stage detectors directly predict object categories and bounding boxes from image pixels without a separate proposal stage. They are generally faster and more suitable for real-time applications.
SSD Series
Single Shot MultiBox Detector (SSD) uses a set of default boxes of different scales and aspect ratios and predicts their categories and offsets from multiple feature maps at different resolutions. SSD achieves a good balance between speed and accuracy. The Deconvolutional Single Shot Detector (DSSD) later adds deconvolution layers to fuse high-level semantic information with low-level details, further improving small-object detection.
YOLO Series
You Only Look Once (YOLO) treats detection as a regression problem. The original YOLO divides the input image into a grid and predicts bounding boxes and class probabilities from a single pass. YOLOv2 introduces anchor boxes, batch normalization, and multi-scale training. YOLOv3 adopts a stronger backbone (Darknet53) and a feature pyramid network (FPN) to make predictions at three different scales, greatly enhancing detection of objects of varying sizes.
2.5 Comparative Analysis and Requirement Assessment
To select a suitable baseline for turbocharger casting defect detection, we compare representative algorithms in terms of backbone parameters, detection performance on the COCO dataset, and multi-scale processing strategies. Table 1 summarizes this comparison.
| Type | Algorithm | Backbone | Parameters | COCO mAP50 | Multi-scale approach |
|---|---|---|---|---|---|
| Two-stage | Faster R-CNN | ResNet-101 | 44.7M | 55.7 | None |
| Two-stage | Faster R-CNN (FPN) | ResNet-101 | 44.7M | 59.1 | Feature pyramid |
| One-stage | YOLOv2 | Darknet-19 | 20.8M | 44.0 | Fine-grained layer |
| One-stage | YOLOv3 | Darknet-53 | 40.6M | 55.3 | Feature pyramid |
| One-stage | SSD300 | VGG16 | 22.9M | 41.2 | Multi-layer detection |
| One-stage | SSD513 | ResNet-101 | 44.7M | 50.4 | Multi-layer detection |
| One-stage | DSSD | ResNet-101 | 44.7M | 53.3 | Upsampling fusion |
From the analysis, YOLOv3 offers a compelling combination of speed, accuracy, and efficient multi-scale fusion. Given the industrial requirement of near-real-time inference on limited hardware, YOLOv3 is chosen as the baseline algorithm. Its architecture will be adapted to the specific characteristics of casting defects, which include extreme size variations, irregular shapes, and poor contrast against the background.
3. Image Preprocessing and Data Augmentation
3.1 Object Description and Defect Types
The research target is the exhaust turbocharger, a device that compresses intake air using energy from exhaust gases. The turbocharger housing is typically produced by sand casting and must withstand high temperature, pressure, and vibration. Defects commonly found on the casting surface include:

- Blow: Caused by trapped gases from the mold core or inadequate venting. The defect appears as large, extremely irregular, rough-edged cavities on the surface. Blows directly cause the part to be scrapped.
- Hole (gas porosity): Small spherical or near-spherical cavities with smooth inner walls, often dark gray after shot blasting. These result from dissolved gases that fail to escape during solidification.
- Inclusion (slag inclusion): Irregular depressions containing slag or mold material. They form when molten metal carries foreign particles into the mold cavity. Inclusions often appear on upper surfaces or where flow stagnates.
- Binder defect: A type of inclusion caused by excess core binder that flows out and becomes embedded in the casting. It usually manifests as a shallow, smooth-bottomed circular depression, sometimes repairable.
A typical turbocharger casting is shown in the figure above. Since these four defect types are frequent and have a severe impact on product quality, they are selected as the target classes for the detection algorithm.
3.2 Detection Technical Specifications
Based on consultations with foundry engineers and the current production environment, the following technical indicators were defined for the detection system:
- The algorithm shall detect all four defect types simultaneously.
- The recall (detection rate) must be above 95%.
- The precision shall be higher than 95%.
- The inference time per image must be less than 1 second.
3.3 Image Denoising
The foundry environment is harsh, with airborne dust, metal particles, and electro-magnetic interference. These factors introduce noise into acquired images. Noise can severely degrade the performance of a CNN, especially for small defects. Therefore, a reliable denoising pre-processing step is essential.
Five commonly used denoising algorithms were considered: median filtering, Gaussian filtering, mean filtering, bilateral filtering, and 2D discrete cosine transform (DCT). Their formulas and properties are briefly described below.
Median filter: Replaces the central pixel with the median value of the window:
$$ g(x,y) = \text{median}\{ f(x-k, y-l) \}, \quad (k,l) \in W \tag{4} $$
Gaussian filter: Weighted average based on a Gaussian kernel:
$$ G(x,y) = \frac{1}{2\pi\sigma^2} e^{-\frac{x^2+y^2}{2\sigma^2}} \tag{5} $$
Mean filter: Unweighted local average:
$$ g(x,y) = \frac{1}{m} \sum_{(k,l)\in W} f(x-k, y-l) \tag{6} $$
Bilateral filter: Combines spatial proximity and intensity similarity:
$$ g(x,y) = \frac{\sum_{(k,l)\in W} f(x-k, y-l) \cdot \omega_d(k,l) \cdot \omega_r(k,l)}{\sum_{(k,l)\in W} \omega_d \cdot \omega_r} \tag{7} $$
where the domain kernel and range kernel are:
$$ \omega_d = \exp\left( -\frac{k^2+l^2}{2\sigma_d^2} \right), \quad \omega_r = \exp\left( -\frac{\|f(x,y) – f(x-k,y-l)\|^2}{2\sigma_r^2} \right) \tag{8} $$
2D DCT: Transforms the image to the frequency domain, where high-frequency noise can be suppressed:
$$ F(u,v) = c(u)c(v) \sum_{i=0}^{N-1}\sum_{j=0}^{N-1} f(i,j) \cos\left[\frac{(i+0.5)\pi u}{N}\right] \cos\left[\frac{(j+0.5)\pi v}{N}\right] \tag{9} $$
Evaluation methodology: For each denoised image, we computed the peak signal-to-noise ratio (PSNR) and the structural similarity index (SSIM). PSNR is defined as:
$$ \text{PSNR} = 20 \log_{10} \left( \frac{\text{MAX}}{\sqrt{\text{MSE}}} \right) \tag{10} $$
where MSE is the mean squared error between the original and processed images. SSIM measures luminance, contrast, and structure similarity:
$$ \text{SSIM}(x,y) = l(x,y) \cdot c(x,y) \cdot s(x,y) \tag{11} $$
A window size of 7×7 was chosen for all spatial filters. Twenty randomly selected images from the production line were used for evaluation. The average PSNR, SSIM, and processing time are reported in Table 2.
| Algorithm | PSNR (dB) | SSIM | Average time (s) |
|---|---|---|---|
| Median filter | 34.499 | 0.812 | 0.870 |
| Gaussian filter | 35.715 | 0.925 | 0.150 |
| Mean filter | 34.057 | 0.801 | 0.165 |
| Bilateral filter | 38.572 | 0.963 | 0.346 |
| 2D DCT | 37.917 | 0.959 | 2.046 |
The bilateral filter outperforms all other methods in both PSNR and SSIM while maintaining a reasonable processing time (~0.35 s per image). Although its time is higher than the Gaussian filter, the quality gain is crucial for subsequent defect detection. The 2D DCT achieves comparable quality but is too slow for real-time applications. Therefore, the bilateral filter was selected for image denoising.
3.4 Dataset Construction and Annotation
A total of 304 raw images were collected from a turbocharger foundry. Such a small dataset is insufficient for training a deep network from scratch. To expand the dataset while preserving annotation consistency, we first annotated all raw images using the Labelimg tool. The tool generates XML files in the Pascal VOC format, containing image size, object class, and bounding-box coordinates. A sample annotation file structure includes:
| Field | Content |
|---|---|
| filename | Unique image name |
| size | Image width, height, and depth |
| object | Defect class and bounding box (xmin, ymin, xmax, ymax) |
Annotation ensures that any transformation applied during data augmentation is also applied to the corresponding bounding boxes, so the ground truth remains valid.
3.5 Geometric Data Augmentation
The limited number of samples necessitates the use of data augmentation techniques to create a more diverse training set. In this work, we designed a geometric augmentation scheme that first applies flips and rotations, then performs random cropping and translation based on prior annotation knowledge.
Flip and rotation: Horizontal and vertical flips, as well as 90° rotations, are applied to both the image and the associated bounding boxes.
Random cropping with annotation awareness: A simple random crop may accidentally cut off the defect, making the ground truth invalid. To avoid this, we calculate the minimal rectangle that contains all bounding boxes in the image. Based on this rectangle, the algorithm selects a random crop size and location that guarantee all objects remain within the cropped area. Let the coordinate of the top-left corner of the minimal containing rectangle be $(x_{\min}, y_{\min})$ and the bottom-right corner be $(x_{\max}, y_{\max})$. The four available regions around the rectangle are evaluated, and the smallest region is selected with a random point $(x_1,y_1)$:
$$ x_1 = \alpha \cdot x_{\min}, \quad y_1 = \beta \cdot y_{\min} \tag{12} $$
where $\alpha, \beta$ are uniform random variables in $(0,1)$. The side length $l$ of the crop is bounded by:
$$ l_{\max} = \min(x_{\max} – x_1, \; y_{\max} – y_1) \tag{13} $$
$$ l_{\min} = \max(x_1 – x_{\min}, \; y_1 – y_{\min}) \tag{14} $$
In this way, the crop not only retains full objects but also changes their relative positions, effectively introducing translation invariance.
Color space augmentation: Defect appearances can vary due to lighting and surface conditions. To simulate such variations, we adjusted brightness, contrast, hue, saturation, and value. The RGB adjustments are given by:
$$ g(x,y) = a \cdot f(x,y) + b \tag{15} $$
where $a$ controls contrast and $b$ controls brightness. For HSV augmentation, we perform:
$$ H_o = H + h, \quad S_o = S \cdot s, \quad V_o = V \cdot v \tag{16} $$
with random parameters in predefined ranges. These transformations are performed with probability to avoid over-synthesized images.
After applying the augmentation pipeline, the final dataset contains 2,192 training images, 240 validation images, and 240 test images. The distribution of defect instances across classes is listed in Table 4.
| Defect type | Number of instances |
|---|---|
| Binder | 140 |
| Hole | 112 |
| Blow | 111 |
| Inclusion | 60 |
4. Deep Learning Based Detection Algorithm for Turbocharger Casting Defects
4.1 Backbone Network
The backbone network is responsible for extracting discriminative features from the input image. We retain the Darknet53 architecture from YOLOv3 due to its excellent trade-off between depth and efficiency. Darknet53 is a fully convolutional network composed of 5 stages of residual blocks, with a total of 52 convolution layers. The residual blocks use shortcut connections to alleviate the vanishing-gradient problem and enable effective training of very deep networks. The detailed structure is summarized in Table 5.
| Type | Stride | Kernel | Output size |
|---|---|---|---|
| Convolution | 1 | 3×3 | 416×416×32 |
| Convolution | 1 | 3×3 | 208×208×64 |
| Residual Block ×1 | 1 | 1×1, 3×3 | 208×208×64 |
| Convolution | 2 | 3×3 | 104×104×128 |
| Residual Block ×2 | 1 | 1×1, 3×3 | 104×104×128 |
| Convolution | 2 | 3×3 | 52×52×256 |
| Residual Block ×8 | 1 | 1×1, 3×3 | 52×52×256 |
| Convolution | 2 | 3×3 | 26×26×512 |
| Residual Block ×8 | 1 | 1×1, 3×3 | 26×26×512 |
| Convolution | 2 | 3×3 | 13×13×1024 |
| Residual Block ×4 | 1 | 1×1, 3×3 | 13×13×1024 |
4.2 Multi-path Fusion Detection Network
YOLOv3 uses a feature pyramid network (FPN) to fuse features from three different scales. The FPN structure connects deep semantic information upward to shallow layers, but its path from deep to shallow is unidirectional. As a result, shallow-level information, which is crucial for detecting small defects, may be diluted after passing through many convolutional layers from the 52×52 feature map down to the 13×13 level. Casting defects such as tiny gas holes and irregular inclusion boundaries require fine-grained spatial details that are present in the low-level features. To mitigate this issue, we employ a multi-path fusion detection network inspired by PANet.
The proposed network takes the last three feature maps from the backbone: 13×13, 26×26, and 52×52. The FPN path (top-down) is kept intact, producing intermediate feature levels $F_1$ (13×13), $F_2$ (26×26), and $F_3$ (52×52). After the FPN process, an additional bottom-up path is introduced. Starting from $F_3$, the feature map is downsampled and concatenated with $F_2$, then further downsampled and concatenated with $F_1$. This creates a new set of prediction feature maps $P_1$, $P_2$, $P_3$. The bottom-up path reduces the distance between shallow layers and deep prediction heads, allowing low-level details to directly influence the final predictions.
The network design is represented by:
$$ F_1 = \text{Conv}(C_1) \quad (13\times13) $$
$$ F_2 = \text{Conv}(\text{Upsample}(F_1) \oplus C_2) \quad (26\times26) $$
$$ F_3 = \text{Conv}(\text{Upsample}(F_2) \oplus C_3) \quad (52\times52) $$
$$ P_3 = F_3 $$
$$ P_2 = \text{Conv}(\text{Downsample}(P_3) \oplus F_2) \quad (26\times26) $$
$$ P_1 = \text{Conv}(\text{Downsample}(P_2) \oplus F_1) \quad (13\times13) $$
where $C_1$, $C_2$, $C_3$ are the backbone outputs, and $\oplus$ denotes feature concatenation. To reduce the computational cost introduced by the extra path, the downsampling operations are implemented using depthwise separable convolutions. A depthwise separable convolution decomposes a standard convolution into a depthwise convolution and a pointwise (1×1) convolution. For input channels $C$ and output channels $N$, the parameter reduction factor is:
$$ \frac{HW C + CN}{HW C N} = \frac{1}{N} + \frac{1}{HW} \tag{17} $$
where $H$ and $W$ are the kernel spatial dimensions. This greatly reduces memory usage and speeds up training.
4.3 Loss Function and Position Regression Metric
To properly supervise the network, we adopt the YOLOv3 loss function, composed of four components: box center coordinate loss, width/height loss, confidence loss, and class loss. The total loss is:
$$ \mathcal{L} = \mathcal{L}_{xy} + \mathcal{L}_{wh} + \mathcal{L}_{\text{confidence}} + \mathcal{L}_{\text{class}} \tag{18} $$
The center coordinate loss is defined by binary cross entropy (BCE):
$$ \mathcal{L}_{xy} = \lambda_{\text{coord}} \sum_{i=0}^{S^2}\sum_{j=0}^{B} \mathbb{1}_{ij}^{\text{obj}} \left[ \text{BCE}(x_i, \hat{x}_i) + \text{BCE}(y_i, \hat{y}_i) \right] \tag{19} $$
where $\mathbb{1}_{ij}^{obj}$ indicates whether the $j$-th prior box at cell $i$ is responsible for an object. The width/height loss uses mean squared error:
$$ \mathcal{L}_{wh} = \lambda_{\text{coord}} \sum_{i=0}^{S^2}\sum_{j=0}^{B} \mathbb{1}_{ij}^{\text{obj}} \left[ (w_i – \hat{w}_i)^2 + (h_i – \hat{h}_i)^2 \right] \tag{20} $$
Confidence loss is a BCE term for both positive and negative samples:
$$ \mathcal{L}_{\text{confidence}} = \sum_{i=0}^{S^2}\sum_{j=0}^{B} \mathbb{1}_{ij}^{\text{obj}} \text{BCE}(c_i, \hat{c}_i) + \lambda_{\text{noobj}} \sum_{i=0}^{S^2}\sum_{j=0}^{B} \mathbb{1}_{ij}^{\text{noobj}} \text{BCE}(c_i, \hat{c}_i) \tag{21} $$
Class loss is also BCE, but we employ label smoothing to prevent over-confidence:
$$ \tilde{l}_k = (1-\alpha) l_k + \frac{\alpha}{K} \tag{22} $$
where $l_k$ is the original one-hot label, $K$ is the number of classes, and $\alpha$ is the smoothing coefficient.
In the original YOLOv3, the intersection over union (IoU) is used to decide whether a prior box contains an object. However, IoU is zero when two boxes do not overlap, giving no gradient to adjust their positions. To improve regression, we replace IoU with CIoU (Complete IoU), which takes into account the overlap area, the distance between center points, and the aspect ratio:
$$ \text{CIoU} = \text{IoU} – \frac{\rho^2(\mathbf{b},\mathbf{b}^{gt})}{c^2} – \alpha v \tag{23} $$
where $\rho$ is the Euclidean distance between central points, $c$ is the diagonal length of the smallest enclosing box, and $v$ measures the aspect ratio consistency:
$$ v = \frac{4}{\pi^2} \left( \arctan \frac{w^{gt}}{h^{gt}} – \arctan \frac{w}{h} \right)^2 \tag{24} $$
$$ \alpha = \frac{v}{(1-\text{IoU}) + v} \tag{25} $$
This metric provides a more informative gradient even for non-overlapping boxes, improving the convergence and localization accuracy.
4.4 Training Strategy
Given the relatively small dataset, training the entire network from scratch would likely lead to overfitting. We therefore employ transfer learning in a two-stage scheme.
Stage 1: The backbone Darknet53 weights, pretrained on ImageNet, are loaded as initial parameters. The backbone weights are frozen, and only the detection network (multi-path fusion heads) is trained. The batch size is set to 24, and the learning rate is kept at $10^{-3}$. This stage lasts for 5 epochs, allowing the detection heads to adapt to the feature representations produced by the frozen backbone.
Stage 2: All layers are unfrozen and trained jointly. The batch size is reduced to 4 due to increased memory consumption. The learning rate is dynamically reduced by a factor of 10 when the validation loss does not improve for 3 consecutive epochs. Early stopping is applied after 15 epochs without improvement. This strategy effectively fine-tunes the entire network for the casting defect domain.
The training was performed on an i7-8700 CPU with an NVIDIA GTX 1060 6GB GPU, using Python and Keras. The learning rate schedule is illustrated in Figure 1.
$$ \text{LR} = \begin{cases} 0.001 & \text{if epoch } \le 5 \\ \text{reduce on plateau} & \text{otherwise}\end{cases} \tag{26} $$
5. Experimental Results and Performance Analysis
5.1 Evaluation Metrics
We use recall (detection rate) and precision as the primary metrics, along with mean average precision (mAP). Recall is the fraction of true defects that are correctly detected, while precision is the fraction of detected boxes that correspond to actual defects. mAP is computed by averaging the area under the precision-recall curve across all classes.
5.2 Effect of Dataset Size
To investigate the impact of data augmentation, we trained the proposed algorithm on three dataset sizes: 1,096, 1,644, and 2,192 images. The validation set was fixed at 11% of the training set. The mAP results are shown in Table 6.
| Number of images | Terminated epoch | mAP (IoU=0.5) |
|---|---|---|
| 1,096 | 47 | 89.94% |
| 1,644 | 58 | 95.25% |
| 2,192 | 64 | 97.66% |
As the data volume increases, the mAP improves, confirming that the proposed augmentation method effectively boosts the model’s performance. The improvement from 1,644 to 2,192 is modest because the augmented samples share the same latent distribution as the original ones.
5.3 Performance Comparison with YOLOv3
The proposed algorithm was compared with the original YOLOv3 under identical training conditions. The test set contained 240 images with the defect instance counts listed in Table 4. The evaluation threshold for IoU was 0.5, and the confidence threshold was 0.3. The model complexity and inference time are reported in Table 7.
| Model | Total parameters | Trainable params | Inference time per image |
|---|---|---|---|
| YOLOv3 | 61,592,497 | 61,539,889 | 0.297 s |
| Proposed method | 75,630,769 | 75,565,105 | 0.313 s |
Despite having about 23% more parameters, the proposed network incurs only a 5.4% increase in inference time, which remains well within the 1-second requirement.
Table 8 and Table 9 present the recall and precision values for each defect type for the original YOLOv3 and the proposed method.
| Defect type | YOLOv3 | Proposed |
|---|---|---|
| Binder | 98.6 | 97.9 |
| Hole | 90.2 | 97.3 |
| Blow | 95.5 | 98.2 |
| Inclusion | 95.0 | 98.3 |
| Total | 95.0 | 97.9 |
| Defect type | YOLOv3 | Proposed |
|---|---|---|
| Binder | 93.9 | 97.9 |
| Hole | 89.4 | 92.4 |
| Blow | 93.0 | 100.0 |
| Inclusion | 91.9 | 96.7 |
| Total | 92.2 | 96.7 |
The proposed method improves the overall recall by 2.9% and the overall precision by 4.5%. Notably, the recall for the “hole” category jumps from 90.2% to 97.3%, indicating that the multi-path fusion network significantly helps in detecting small spherical defects. The precision for “blow” reaches 100%, meaning no false positives were produced for this class.
The mAP comparison is shown in Figure 2. The proposed algorithm achieves an mAP of 97.66%, while the original YOLOv3 attains 94.00%, a relative improvement of 3.66 percentage points.
A visualization of the detection results is presented in Figure 3. The algorithm correctly identifies the location and category of each defect with a confidence score. These results confirm that the proposed deep learning based detection algorithm is feasible and practical for turbocharger casting defect detection.
5.4 Ablation Study on Multi-path Fusion
To verify the contribution of the bottom-up path, we also trained a variant of the network with only the FPN branch (removing the extra path) while keeping the same training hyperparameters. This variant is equivalent to YOLOv3 with the same backbone. The mAP of the variant was 94.0%, confirming that the added path yields a significant improvement. Furthermore, replacing the standard downsampling convolutions with depthwise separable convolutions in the extra path reduced the parameter growth from an expected 30% to about 23%, as shown in Table 7.
6. Post-processing of Defect Images
After the detection network outputs bounding boxes and class labels, further processing is often needed to facilitate defect repair, process analysis, and database construction. Because different defect types have distinct geometric appearances, we design specific post-processing routines.
6.1 Processing for Binder and Hole
Binder defects and gas holes are approximately circular in shape. For binder defects, the boundary is often blurred due to the smooth metallic surface after shot blasting. To reliably extract the circular region, we use a combination of grayscale conversion, Otsu thresholding, morphological opening/closing, and minimum enclosing circle computation. The procedure is as follows:
- Crop the region using the detected bounding box.
- Convert to grayscale.
- Apply Otsu’s method to obtain a binary image.
- Perform morphological erosion and dilation to remove small noise and smooth the boundary.
- Extract contours and retain the contour with the largest area.
- Fit a minimum enclosing circle to represent the defect region.
The morphological operation helps avoid an oversized circle caused by faint boundaries. The equation for the morphological dilation can be represented as:
$$ A \oplus B = \{ z \mid (B)_z \cap A \neq \emptyset \} \tag{27} $$
where $A$ is the binary image and $B$ is the structuring element.
For gas holes, the edges are relatively sharp and the defect appears darker against the bright surrounding. We use Laplacian sharpening to enhance edges, followed by Canny edge detection, and finally apply the Hough transform to fit a circle. The Laplacian kernel is:
$$ \nabla^2 f = \frac{\partial^2 f}{\partial x^2} + \frac{\partial^2 f}{\partial y^2} \tag{28} $$
The Hough transform maps edge points to a parameter space, where candidate circles are identified.
6.2 Processing for Blow and Inclusion
Blows and inclusions are irregular and large. They cannot be represented by circles. Instead, we use contrast enhancement, Otsu binarization, morphological processing, and contour extraction to obtain the actual defect boundary. The achieved mask can be overlaid on the original image for visualization or used as a binary segmentation result. Table 10 summarizes the post-processing steps for each defect type.
| Step | Binder | Hole | Blow | Inclusion |
|---|---|---|---|---|
| Grayscale conversion | ✓ | ✓ | ✓ | ✓ |
| Contrast enhancement | ✓ | ✓ | ✓ | |
| Edge sharpening | ✓ | |||
| Binarization | ✓ | ✓ | ✓ | ✓ |
| Edge detection | ✓ | |||
| Morphological transform | ✓ | ✓ | ✓ | |
| Largest contour | ✓ | ✓ | ✓ | |
| Minimum enclosing circle | ✓ | |||
| Hough transform | ✓ |
The segmented results are transformed back to the original image coordinates and saved. This allows for automatic creation of a defect database, and it also provides training material for future pixel-level segmentation networks.
7. Conclusion and Future Work
In this thesis, a deep learning based detection algorithm for turbocharger casting defects was developed and validated. The research addressed multiple challenges: the presence of noise in industrial images, the limited amount of annotated data, the large variation in defect size and shape, and the requirement for real-time detection. The main conclusions of this work are:
- The bilateral filter was selected as the optimal preprocessing method, achieving a PSNR of 38.572 dB and an SSIM of 0.963 with acceptable processing speed.
- The proposed data augmentation method, which combines annotation-aware random cropping, flipping, rotation, and color space transformations, effectively increased the dataset and improved the model’s generalization.
- A multi-path fusion detection network based on YOLOv3 was designed to enhance the flow of shallow-level features to deeper prediction layers. The use of depthwise separable convolutions limited the parameter growth while preserving accuracy.
- The improved network achieved a total recall of 97.9% and a total precision of 96.7% on the test set, meeting the industrial specification. The mAP was 97.66%, significantly higher than the original YOLOv3’s 94.00%.
- Defect-specific post-processing methods successfully extracted circular regions for binder and gas holes, and arbitrary masks for blows and inclusions, facilitating downstream tasks.
Future research could explore the following directions:
- Data augmentation with generative models: The integration of generative adversarial networks (GANs) could synthesize more realistic defect samples, further addressing the class imbalance problem.
- Lightweight network design: To enable deployment on edge devices with limited computational resources, techniques such as knowledge distillation and neural architecture search could be employed.
- Extension to other defect types: The algorithm can be extended to detect machining defects, coating defects, or other surface anomalies, making it a universal industrial inspection solution.
In summary, the proposed deep learning based detection algorithm demonstrates superior performance on turbocharger casting defect detection and provides a solid foundation for fully automated quality control in foundries.
