In my research, I study the automatic detection and classification of casting defect patterns on industrial castings. The specific object I examine is an automobile brake bracket, a part whose surface frequently shows dark holes, shallow pits, cracks, notches, bulges, and depressions. These casting defect forms are not merely cosmetic. They reduce the mechanical strength of the part, loosen the connection between assembled components, and create safety risks. Traditional inspection methods, including manual visual inspection, X-ray testing, ultrasonic testing, eddy-current testing, magnetic-flux leakage, and infrared imaging, have been used for many years. However, these methods often suffer from high cost, low efficiency, strong dependence on human expertise, and limited flexibility. For these reasons, I propose a deep-learning-based casting defect detection algorithm that can locate suspicious regions, recognize the presence of a casting defect, and classify the type of casting defect with high accuracy.
The central challenge in my work is that a casting defect is usually a small and subtle pattern inside a very large image. If I directly resize a high-resolution image to a small square, the fine details of a casting defect disappear. If I instead search the entire high-resolution image with a single convolutional network, the target is too small and the computational cost becomes excessive. Additionally, the surface of a casting is often frosted, with natural spots, textures, and slight unevenness that can be confused with a casting defect. Different types of casting defect also share visual similarities, while the same type of casting defect can vary greatly in shape, size, and contrast. These properties make casting defect detection fundamentally different from ordinary large-scale image classification.
To solve these problems, I designed a two-stage architecture. The first stage uses a YOLO-based detector to locate the regions of the casting that need to be inspected. The second stage uses an improved ResNet-50 classifier to determine whether the extracted region contains a casting defect and, if so, which category of casting defect is present. This design transforms the original problem from “finding a tiny target in a very large image” into “finding a medium-sized casting region in a large image, and then detecting a small casting defect inside that medium-sized region.” The transformation preserves pixel-level detail, reduces irrelevant background interference, and makes the classification task tractable for a deep residual network.
Research Background and Industrial Motivation
The production of castings involves melting metal, pouring or injecting the liquid metal into a mold, solidifying the material, and then finishing the part by grinding or machining. Each step can introduce a casting defect. Uneven material distribution can cause internal shrinkage and produce a dark hole. Liquid metal splashing can create a series of shallow pits. Mold collision can generate cracks and notches. Insufficient grinding can leave a bulge, while excessive grinding can produce a depression. Once a casting defect appears, it can be difficult or impossible to repair without compromising the part. Therefore, real-time inspection during or immediately after production is highly valuable.
Manual inspection is flexible but inconsistent. Human inspectors become tired, apply different standards, and cannot easily inspect every part at high speed. Non-destructive testing methods can detect internal or surface anomalies, but they often require special equipment, careful coupling, or contact with the part. Computer vision methods based on handcrafted features have improved automation, but they still depend on expert-designed descriptors. A handcrafted feature may capture one type of casting defect while missing another. It may also be sensitive to lighting changes, surface texture, and viewpoint. Deep learning avoids explicit feature engineering by learning hierarchical representations directly from data. In my approach, a convolutional neural network learns the visual signatures of a casting defect without requiring me to define every possible edge, blob, or texture pattern manually.
The casting process itself can be highly automated. A modern pouring line moves molds, controls metal flow, and monitors temperature, but it does not necessarily inspect every surface for a casting defect. The figure below shows an automatic pouring line, which illustrates the industrial context in which high-speed casting defect detection is needed.

In such a line, a casting defect that escapes inspection may reach assembly and cause a functional failure. My motivation is therefore not only to improve classification accuracy but also to build a detection pipeline that can eventually operate near real time. I use a high-resolution industrial camera, a fixed mechanical handling system, and controlled illumination so that the captured image is stable enough for automated analysis. The casting defect itself remains the central object of every design decision, because its small size and subtle appearance determine the required image resolution, network depth, and data augmentation strategy.
Characteristics of Casting Defect Patterns
I group the common surface casting defect patterns into six categories. The definitions below guide both my labeling process and my network design.
| Casting Defect Category | Typical Appearance | Usual Cause | Potential Effect |
|---|---|---|---|
| Dark hole | Small dark opening, often 2–5 mm in diameter, with a deeper interior | Uneven material shrinkage during solidification | Reduces strength and may create internal stress concentration |
| Shallow pits | Circular or irregular shallow depressions, sometimes appearing in groups | Liquid metal splashing or gas entrapment | Damages surface finish and slightly weakens the part |
| Crack | Elongated narrow line, variable in depth and length | Thermal stress, pressure imbalance, or material weakness | Severe strength reduction and risk of fracture |
| Notch | Missing material at an edge or corner | Collision after solidification or mold damage | Usually makes the part unusable |
| Bulge | Local edge protrusion | Insufficient grinding or finishing | Interferes with assembly and fit |
| Depression | Local edge indentation | Excessive grinding or finishing | Reduces stiffness and loosens connections |
These categories are not always visually separable. For example, a dark hole and a shallow pit both appear as small dark or shadowed regions. A crack and a normal surface texture can both appear as thin lines. A notch and a depression both remove material from an edge. This overlap means that a casting defect classifier must learn fine-grained differences rather than broad object categories. The presence or absence of a casting defect is often easier to determine than the exact category, so I evaluate my system using two metrics: whether a casting defect exists, and which casting defect category is present.
Task Difficulty and Problem Formulation
I formulate the casting defect detection task as a combination of region detection and region classification. Let the original image be \(I\) with width \(W\) and height \(H\). In my dataset, \(W = 2566\) and \(H = 1940\). The image contains several casting regions \(R_1, R_2, \ldots, R_N\), each of which may contain zero, one, or several casting defect instances. My goal is to produce a set of predictions
$$
\hat{Y} = \{(\hat{b}_i, \hat{c}_i, \hat{p}_i)\}_{i=1}^{M}
$$
where \(\hat{b}_i\) is a bounding box, \(\hat{c}_i\) is a class label, and \(\hat{p}_i\) is a confidence score. The class label may be “no casting defect” or one of the six casting defect categories. A successful system must both localize the region and classify the casting defect.
The first difficulty is target size. A dark hole may occupy only \(10 \times 10\) pixels in a \(2566 \times 1940\) image. If I resize the whole image to \(416 \times 416\), that dark hole becomes approximately \(1.6 \times 1.6\) pixels. Such extreme downsampling destroys the visual evidence of a casting defect. The second difficulty is interference. The casting surface contains normal spots, grinding marks, and texture. These are not casting defect patterns, but they can look similar to a shallow pit or a crack. The third difficulty is intra-class variation. A crack may be short or long, straight or curved, dark or faint. A bulge may be large or small. The fourth difficulty is inter-class similarity. A dark hole and a shallow pit share shadow and circularity cues. A notch and a depression share edge-discontinuity cues. These difficulties motivate the use of a high-resolution input and a two-stage detector.
Overall Architecture
My overall architecture contains a YOLO-based region detector and an improved ResNet-50 classifier. The input image is first adjusted to a size suitable for YOLO. The YOLO detector finds the casting regions that need to be inspected. Each detected region is cropped from the original high-resolution image and resized to \(256 \times 256\). The improved ResNet-50 then classifies each region as “no casting defect” or as one of the six casting defect categories. Finally, the system combines the region coordinates with the classification result to report the location and type of casting defect.
The pipeline can be described as follows:
- Remove invalid background regions and resize the original image to \(416 \times 416\) for region detection.
- Run YOLO-v3 to detect \(N\) casting regions and predict their bounding boxes and region classes.
- If no region is found, mark the image as an interference sample.
- For each detected region, crop the corresponding area from the original \(2566 \times 1940\) image.
- Resize each cropped region to \(256 \times 256\).
- Run the improved ResNet-50 classifier on each region.
- If any region is classified as a casting defect, mark the original image as defective and output the casting defect category and location.
- If all regions are classified as “no casting defect,” mark the original image as non-defective.
This architecture avoids the loss of resolution that occurs when a whole image is compressed. It also reduces the search space because the second network only examines medium-sized regions rather than the entire image. The casting defect remains the core target of the second network, while the first network only needs to identify the casting area.
Region Detection with YOLO-v3
I use YOLO-v3 because it treats object detection as a single regression problem and can predict bounding boxes and class probabilities in one forward pass. The network divides the input image into an \(S \times S\) grid. Each grid cell predicts \(B\) bounding boxes. For each bounding box, the network predicts the center coordinates \((x, y)\), width \(w\), height \(h\), an object confidence score, and class probabilities. The predicted tensor has the form
$$
\text{Tensor} = S \times S \times B \times (5 + C)
$$
where \(C\) is the number of classes. In my region detection task, the classes are the different casting regions rather than the casting defect categories. The object confidence is defined as
$$
\text{Confidence} = \Pr(\text{Object}) \times \text{IOU}_{\text{pred}}^{\text{truth}}
$$
where \(\Pr(\text{Object})\) is the probability that an object exists in the box and \(\text{IOU}_{\text{pred}}^{\text{truth}}\) is the intersection over union between the predicted box and the ground-truth box. The class-specific confidence is
$$
\Pr(\text{Class}_i \mid \text{Object}) \times \Pr(\text{Object}) \times \text{IOU}_{\text{pred}}^{\text{truth}}
$$
YOLO-v3 uses Darknet-53 as its backbone. Darknet-53 contains 53 convolutional layers, uses \(1 \times 1\) and \(3 \times 3\) kernels, and applies residual connections. It has no fully connected layer at the detection stage. Instead, it predicts objects at three different scales, which helps detect casting regions of different sizes. The network uses upsampling and concatenation to combine features from different depths. This multi-scale prediction is important because the casting regions vary in size and position.
For each training sample, I label the casting regions with bounding boxes and region categories. The loss function balances localization error, confidence error, and classification error. In simplified form, the YOLO loss can be written as
$$
L = \lambda_{\text{coord}} \sum_{i=0}^{S^2} \sum_{j=0}^{B} \mathbb{1}_{ij}^{\text{obj}} \left[ (x_i – \hat{x}_i)^2 + (y_i – \hat{y}_i)^2 \right]
+ \lambda_{\text{coord}} \sum_{i=0}^{S^2} \sum_{j=0}^{B} \mathbb{1}_{ij}^{\text{obj}} \left[ (\sqrt{w_i} – \sqrt{\hat{w}_i})^2 + (\sqrt{h_i} – \sqrt{\hat{h}_i})^2 \right]
+ \sum_{i=0}^{S^2} \sum_{j=0}^{B} \mathbb{1}_{ij}^{\text{obj}} (C_i – \hat{C}_i)^2
+ \lambda_{\text{noobj}} \sum_{i=0}^{S^2} \sum_{j=0}^{B} \mathbb{1}_{ij}^{\text{noobj}} (C_i – \hat{C}_i)^2
+ \sum_{i=0}^{S^2} \mathbb{1}_{i}^{\text{obj}} \sum_{c \in \text{classes}} (p_i(c) – \hat{p}_i(c))^2
$$
where \(\mathbb{1}_{ij}^{\text{obj}}\) indicates whether the \(j\)-th box in cell \(i\) is responsible for the object, \(\mathbb{1}_{ij}^{\text{noobj}}\) indicates the opposite, and \(\lambda_{\text{coord}}\) and \(\lambda_{\text{noobj}}\) are balancing weights. This loss encourages the network to localize casting regions accurately while suppressing false detections in the background.
In my dataset, the casting regions include the left top platform, left upper link, left lower link, right top platform, right upper link, and right lower link. The region detector does not need to identify the casting defect directly. It only needs to find the region and crop it. This separation is important because the YOLO network can be trained on region labels even when the number of casting defect samples is limited.
| Training Epoch | Training Accuracy | Test Accuracy | IOU Score | FPS |
|---|---|---|---|---|
| 5 | 38.5% | 33.4% | 0.45 | 34 |
| 10 | 66.3% | 61.3% | 0.53 | 34 |
| 15 | 75.2% | 67.2% | 0.67 | 34 |
| 20 | 80.8% | 74.2% | 0.72 | 35 |
| 25 | 83.2% | 75.5% | 0.75 | 34 |
| 30 | 85.0% | 80.8% | 0.75 | 34 |
| 35 | 88.3% | 84.2% | 0.79 | 34 |
| 40 | 90.2% | 86.6% | 0.83 | 34 |
| 42 | 93.1% | 87.0% | 0.85 | 34 |
| 44 | 92.3% | 87.8% | 0.85 | 34 |
| 46 | 91.8% | 88.5% | 0.86 | 34 |
| 48 | 92.5% | 89.0% | 0.86 | 34 |
| 50 | 93.1% | 88.0% | 0.87 | 34 |
I observe that the region detector reaches its best test accuracy at epoch 48. The training accuracy continues to rise slightly after that, but the test accuracy does not improve, which indicates the beginning of overfitting. The FPS remains around 34, which is above the common real-time threshold of 25 FPS. The IOU score reaches 0.87, meaning the predicted region boxes overlap well with the ground-truth boxes. Although the classification accuracy among region types is only 89.0%, the recall of casting regions is high: the network detects 2933 out of 3000 target regions, giving a detection rate of 97.76%. For my pipeline, this is acceptable because the region detector only provides candidate regions for the second-stage casting defect classifier.
Defect Recognition with ResNet-50
After the region detector crops the casting regions, each region is resized to \(256 \times 256\). I use ResNet-50 as the backbone for casting defect classification. ResNet-50 contains 50 convolutional layers organized into stages. It uses residual blocks to ease gradient propagation. A residual block computes
$$
H(x) = F(x) + x
$$
where \(x\) is the input and \(F(x)\) is the residual mapping. Instead of learning \(H(x)\) directly, the network learns \(F(x) = H(x) – x\). This makes it easier to train very deep networks because the identity mapping \(x\) provides a shortcut path for gradients. The two main residual block types in ResNet-50 are the convolutional block, which changes feature dimensions, and the identity block, which keeps dimensions unchanged.
I modify the output layer of ResNet-50 for my seven-class problem: six casting defect categories plus “no casting defect.” The original 1000-class fully connected layer is removed and replaced by a seven-class softmax layer. The softmax function is
$$
\text{Softmax}(z_i) = \frac{e^{z_i}}{\sum_{j=1}^{K} e^{z_j}}
$$
where \(K = 7\). The predicted class is the one with the highest probability. I use categorical cross-entropy as the classification loss:
$$
L_{\text{CE}} = – \sum_{i=1}^{K} y_i \log(\hat{y}_i)
$$
where \(y_i\) is the ground-truth label and \(\hat{y}_i\) is the predicted probability. Because my dataset contains only 1600 initial images, I use transfer learning from a model pretrained on ImageNet. I keep the first five stages and replace the final classification layer. This allows the network to benefit from general visual features while adapting to the specific appearance of a casting defect.
| Input | Stage 1 | Stage 2 | Stage 3 | Stage 4 | Stage 5 | Output |
|---|---|---|---|---|---|---|
| \(256 \times 256 \times 3\) | \([7 \times 7, 64]\), max pool | 9 conv, 256 channels | 12 conv, 512 channels | 18 conv, 1024 channels | 9 conv, 2048 channels | 7 classes |
| Status | Kept | Kept | Kept | Kept | Kept | Replaced |
Data Normalization and Augmentation
Before training, I normalize each input image. For a pixel value \(X_0\) in the range \([0, 255]\), I compute
$$
X = \frac{X_0}{128} – 1
$$
The normalized value \(X\) lies in \([-1, 1]\). This improves the numerical stability of gradient descent, accelerates convergence, and reduces the influence of extreme pixel values. Normalization also helps the network avoid being dominated by a few bright or dark regions on the casting surface.
To reduce overfitting and improve robustness, I expand the dataset with four augmentation operations. The first is mirror flipping, which reverses the \(x\)-axis pixels and doubles the number of samples. The second is random rotation, which includes \(90^\circ\), \(180^\circ\), and \(270^\circ\) rotations plus a random rotation between \(-10^\circ\) and \(+10^\circ\). The third is random scaling, which stretches or compresses the image along the \(x\) and \(y\) axes by a factor between 0.9 and 1.1. The fourth is random translation, which shifts the image by a step between \(-20\) and \(+20\) pixels. By combining these operations, I can expand one original image into up to eight images while preserving the essential appearance of the casting defect. This is important because a casting defect can appear at different positions and orientations, and the classifier should not depend on a single absolute location.
Learning Rate Optimization
I use an exponential decay learning rate schedule. The learning rate at a given global step is
$$
\eta = lr \times \text{decay\_rate}^{\frac{\text{global\_step}}{\text{decay\_step}}}
$$
where \(lr\) is the initial learning rate, \(\text{decay\_rate}\) is the decay coefficient, \(\text{global\_step}\) is the current training step, and \(\text{decay\_step}\) is the update interval. I set the initial learning rate to 0.01, use a batch size of 50 images, and set \(\text{decay\_step} = 20\). The learning rate starts at 0.01 and gradually decays to approximately \(1.0 \times 10^{-3}\). A large initial learning rate helps the network move quickly toward a good region of the parameter space, while the later decay allows fine-grained updates. This schedule improves convergence and avoids the oscillations that can occur when the learning rate remains too high.
ASoftReLU Activation Function
The standard ReLU activation function is
$$
\text{ReLU}(x) = \max(0, x)
$$
ReLU is computationally efficient and promotes sparsity, but it has a well-known problem: when \(x \leq 0\), the gradient is zero. If a neuron receives only negative inputs for a long time, its weights may never update again. This is called neuron death. To address this, I propose the ASoftReLU function, which combines ReLU with the smooth negative region of the Softplus function. The Softplus function is
$$
\text{Softplus}(x) = \log(1 + e^x)
$$
My ASoftReLU function is defined as
$$
\text{ASoftReLU}(x) =
\begin{cases}
x, & x > 0 \\
A \log(1 + e^x), & x \leq 0
\end{cases}
$$
where \(A\) is a parameter between 0 and 1. When \(A = 0\), ASoftReLU becomes ReLU. When \(A = 1\), the negative side becomes Softplus. For intermediate values, the function retains a small gradient for negative inputs while keeping the linear, non-saturating behavior for positive inputs. This reduces the risk of neuron death, preserves fast convergence on the positive side, and allows the network to learn useful negative-side representations. I treat \(A\) as a hyperparameter and select it through experiments.
| Parameter \(A\) | Epoch at Best Accuracy | Y/N Accuracy | Category Accuracy |
|---|---|---|---|
| 0.0 | 63 | 91.3% | 84.6% |
| 0.1 | 63 | 91.6% | 85.7% |
| 0.3 | 65 | 92.1% | 86.2% |
| 0.5 | 65 | 91.8% | 86.0% |
| 0.7 | 66 | 91.7% | 85.6% |
| 0.9 | 67 | 91.5% | 85.8% |
The results show that \(A = 0.3\) gives the best overall performance. The Y/N accuracy, which measures whether a casting defect exists, reaches 92.1%. The category accuracy, which measures the exact casting defect type, reaches 86.2%. Compared with \(A = 0\), which is equivalent to the original ReLU, the ASoftReLU version improves both accuracy and convergence speed. This confirms that avoiding neuron death and retaining a small negative-side gradient is beneficial for casting defect recognition.
Multi-Channel Convolutional Neural Network
Even with a strong backbone and a better activation function, a single-channel network may still lose some information during convolution and pooling. The casting defect may be faint, low-contrast, or partially obscured by surface texture. To improve robustness, I use a multi-channel convolutional neural network. The idea is to create several parallel input paths, each with a different preprocessing style, and then average their predictions. This exposes the network to multiple views of the same casting defect and reduces the chance that a casting defect is missed because of one preprocessing choice.
The feature enhancement module has two main operations. The first is histogram equalization, which stretches the intensity distribution and increases global contrast. The second is intensity adjustment, which maps the original gray values to a wider or narrower range. For each image \(P_n\) produced by data augmentation, I generate three inputs:
$$
P_{n,0} = P_n
$$
$$
P_{n,1} = \text{HistogramEqualization}(P_n)
$$
$$
P_{n,2} = \text{Imadjust}(P_n)
$$
Thus, each augmented image becomes three images. If data augmentation produces \(N+1\) images, the multi-channel system can produce up to \(3(N+1)\) training inputs. Each channel processes one preprocessed version and outputs a probability vector. At the end, the system averages the probability vectors:
$$
\hat{y} = \frac{1}{M} \sum_{m=1}^{M} \hat{y}^{(m)}
$$
where \(M\) is the number of channels and \(\hat{y}^{(m)}\) is the prediction from channel \(m\). This averaging operation is simple but effective. It reduces variance, combines complementary contrast information, and makes the final decision less sensitive to a single preprocessing artifact.
| Number of Channels | Training Steps (\(10^3\)) | Y/N Accuracy | Category Accuracy |
|---|---|---|---|
| 1 | 340 | 93.3% | 86.4% |
| 2 | 344 | 93.5% | 87.1% |
| 4 | 348 | 93.8% | 87.9% |
| 6 | 345 | 94.1% | 87.5% |
| 8 | 347 | 94.3% | 88.2% |
The multi-channel experiments show that the number of channels has little effect on the number of training steps required to converge. All variants converge between approximately 340,000 and 350,000 steps. However, the number of channels clearly affects accuracy. The eight-channel model performs best, reaching 94.3% Y/N accuracy and 88.2% category accuracy. This suggests that the multi-channel design provides a meaningful boost in casting defect detection, especially when the casting defect has low contrast or appears near a textured region.
Experimental Setup and Evaluation Metrics
I implement the networks on TensorFlow and use OpenCV for image processing. The hardware environment includes an Intel Core i7-4700 CPU, an NVIDIA RTX 2070 Ti GPU, and 32 GB RAM. The software environment includes Windows 10, Anaconda3, CUDA 9.1, and OpenCV 3.4. I evaluate the system with several standard metrics. Precision is defined as
$$
\text{Precision} = \frac{TP}{TP + FP}
$$
Recall is defined as
$$
\text{Recall} = \frac{TP}{TP + FN}
$$
The intersection over union is defined as
$$
\text{IOU} = \frac{\text{Area of Overlap}}{\text{Area of Union}}
$$
Mean average precision is defined as
$$
\text{MAP} = \frac{1}{n} \sum_{j=1}^{n} \text{AP}_j
$$
where \(\text{AP}_j\) is the average precision for class \(j\). Frames per second is used to measure detection speed. In industrial inspection, a speed above 25 FPS is often considered real-time. My YOLO region detector runs at approximately 34 FPS, which satisfies this requirement. The second-stage classifier is slower because it processes multiple cropped regions, but the overall pipeline remains usable for offline or near-line inspection.
Dataset Construction
For the region detection experiment, I use 850 automobile brake bracket samples. From these, I select 625 images as the original dataset. After sample deformation and randomization, each image is expanded into four images, giving a total of 2500 images. I use 2000 images for training and 500 for testing. Each training batch contains 100 images, and each test batch contains 100 images. The YOLO network is trained for up to 100 epochs.
For the casting defect classification experiment, I collect 1600 images of size \(256 \times 256\) from the cropped casting regions. The dataset contains dark holes (203 images), shallow pits (185 images), bulges (197 images), depressions (212 images), cracks (206 images), notches (197 images), and no casting defect (400 images). I then apply data augmentation and expand the dataset to 6400 images. From this expanded set, I use 5400 images for training and 1000 for testing. In the test set, each casting defect category contains 125 images, and the no-defect category contains 250 images.
| Casting Defect Category | Original Images | Expanded Images | Training Images | Test Images |
|---|---|---|---|---|
| Dark hole | 203 | 812 | 687 | 125 |
| Shallow pits | 185 | 740 | 615 | 125 |
| Crack | 206 | 824 | 699 | 125 |
| Notch | 197 | 788 | 663 | 125 |
| Bulge | 197 | 788 | 663 | 125 |
| Depression | 212 | 848 | 723 | 125 |
| No casting defect | 400 | 1600 | 1350 | 250 |
| Total | 1600 | 6400 | 5400 | 1000 |
Results and Discussion
I evaluate the full pipeline in three stages. The first stage measures the region detector. The second stage measures the ResNet-50 classifier with ASoftReLU. The third stage measures the multi-channel classifier. The final system combines the best region detector with the best classifier.
For the region detector, the best test accuracy is 89.0% at epoch 48. The IOU score is 0.86, and the FPS is 34. The detector finds 2933 out of 3000 target regions, giving a recall of 97.76%. This high recall is more important than the exact region-class accuracy because the second-stage classifier will inspect every detected region. A missed region is a missed casting defect, but a misclassified region type is less harmful because the region is still passed to the casting defect classifier.
For the ASoftReLU classifier, the best result occurs at \(A = 0.3\). The Y/N accuracy is 92.1%, and the category accuracy is 86.2%. This is higher than the original ReLU baseline, which reaches 91.3% Y/N accuracy and 84.6% category accuracy. The improvement is consistent with the expected benefits of avoiding neuron death and preserving negative-side gradients.
For the multi-channel classifier, the eight-channel model reaches 94.3% Y/N accuracy and 88.2% category accuracy. The confusion matrix shows that the “notch” category is the most frequently over-detected class, while “depression” has high precision but lower recall. This is reasonable because a notch and a depression both involve missing material at an edge. The “no casting defect” class has high recall because normal surface texture rarely produces a strong defect-like response after multi-channel averaging. The overall Y/N accuracy of 94.3% means that the system is highly reliable at deciding whether a casting defect exists, even if the exact category is sometimes confused.
| Method | Y/N Accuracy | Category Accuracy |
|---|---|---|
| KNN with handcrafted features | 67.3% | 55.2% |
| PCA + BP neural network | 75.2% | 69.9% |
| ResNet-50 baseline | 91.3% | 84.6% |
| ResNet-50 + ASoftReLU | 92.1% | 86.2% |
| Multi-channel ResNet-50 | 94.3% | 88.2% |
The comparison shows that deep learning substantially outperforms traditional handcrafted-feature methods. The baseline ResNet-50 already achieves a large improvement over KNN and PCA + BP. The ASoftReLU modification improves both metrics. The multi-channel design provides the best final performance. These results validate my central hypothesis: a casting defect detection system benefits from a two-stage architecture, high-resolution region cropping, a robust activation function, and multi-view feature enhancement.
Error Analysis
I analyze the remaining errors to understand the limitations of my casting defect detection system. The first source of error is inter-class similarity. Dark holes and shallow pits can both appear as small dark spots, and the network sometimes confuses them when the illumination is uneven. Cracks and normal grinding marks can both appear as thin lines. Notches and depressions can both remove material from an edge. The second source of error is intra-class variation. A crack can be very short or very long, and a bulge can be large or small. The third source of error is occlusion and shadow. A casting defect near a corner may be partially hidden by the geometry of the part. The fourth source of error is the limited size of the dataset. Although data augmentation increases the number of training images, it does not create new physical casting defect patterns. A larger and more diverse dataset would likely improve category accuracy.
I also observe that the region detector can miss a casting region when the part is slightly misaligned or when the background contains a strong reflection. Because the second-stage classifier only examines detected regions, a missed region leads directly to a missed casting defect. Future work should improve the robustness of the region detector to pose variation and lighting variation. One possible approach is to add a spatial transformer module or to use a more advanced anchor-free detector.
Computational Cost and Real-Time Considerations
The YOLO region detector runs at approximately 34 FPS, which is fast enough for real-time region detection. The ResNet-50 classifier is heavier. When eight channels are used, the classifier processes eight preprocessed versions of each region, so the computational cost increases. In my experiments, the full pipeline is slower than a single network but still practical for near-line inspection. To improve speed, I can reduce the number of channels at the cost of a small accuracy drop, or I can parallelize the channels on the GPU. Another option is to use a smaller backbone such as ResNet-34 or MobileNet for the classifier while keeping the multi-channel idea. The trade-off between accuracy and speed is an important engineering decision for industrial deployment.
| Component | Approximate Speed | Notes |
|---|---|---|
| YOLO region detector | 34 FPS | Runs on \(416 \times 416\) input |
| Single-channel ResNet-50 classifier | Moderate | Processes one \(256 \times 256\) region at a time |
| Eight-channel ResNet-50 classifier | Slower | Provides highest Y/N accuracy |
| Full pipeline | Near real-time | Can be optimized by parallel channels |
Conclusion
I have presented a deep-learning-based method for casting defect detection. The method uses a YOLO-v3 region detector to locate casting regions in a high-resolution image and an improved ResNet-50 classifier to identify whether a casting defect exists and which category it belongs to. I address the small-target problem by avoiding global image compression and by cropping high-resolution regions before classification. I address the interference problem by improving the activation function and by using a multi-channel convolutional neural network with contrast enhancement. The best configuration reaches 94.3% Y/N accuracy and 88.2% category accuracy on the test set. The YOLO region detector reaches 89.0% test accuracy and 97.76% region recall. These results show that the proposed architecture is effective for casting defect detection and provides a strong foundation for automated industrial inspection.
Future Work
There are several directions I plan to explore. First, I will improve the region detector for complex casting areas, including corners, symbols, characters, and link regions. Second, I will increase the dataset size and diversity so that the classifier can better distinguish similar casting defect categories. Third, I will optimize the multi-channel network for speed, possibly by pruning channels, sharing weights, or using a lightweight backbone. Fourth, I will integrate the system with a production line and test it under real factory conditions. Fifth, I will investigate semi-supervised and self-supervised learning to reduce the labeling burden for new casting defect categories. Finally, I will explore uncertainty estimation so that the system can flag low-confidence predictions for human review. These steps will move the casting defect detection system closer to robust, scalable industrial deployment.
