Casting Defect Detection

I began this research with a practical industrial problem: casting defects are difficult to detect reliably, quickly, and consistently on a production line. In my work, the target object is an automobile brake bracket, a representative cast part with flat platforms, curved links, edges, and corners. Its surface may contain dark holes, shallow pits, cracks, notches, bulges, and depressions. These casting defects do not merely affect appearance. They weaken the part, loosen connections between components, reduce fatigue life, and create safety risks. My goal was to design a deep-learning-based inspection method that can locate suspicious regions on a large image and then classify whether those regions contain casting defects. I wanted the method to preserve fine detail, reduce manual feature engineering, and remain fast enough for industrial use.

Traditional inspection methods for casting defects include manual visual inspection, infrared inspection, ultrasonic testing, eddy-current testing, magnetic-flux leakage, and vibration analysis. These techniques can be effective in specific settings, but they often require special conditions, skilled operators, direct contact with the part, or expensive equipment. In many casting lines, the cost, cycle time, and dependence on human judgment make them unsuitable for full inspection. Image-based methods have therefore become attractive. Early image-processing methods often relied on handcrafted features such as gray-level differences, texture descriptors, edge maps, Fourier features, wavelet coefficients, and Gabor responses. Machine-learning methods then added classifiers such as support vector machines, k-nearest neighbors, sparse coding, and neural networks. However, handcrafted features are still limited. They may miss subtle casting defects, they are sensitive to illumination and surface texture, and they require experts to define what a defect looks like. Deep learning offered a different path: a convolutional neural network can learn hierarchical features directly from labeled images. This is exactly what I wanted for casting defects, because the appearance of casting defects is highly variable and difficult to describe with fixed rules.

I classified the common casting defects in my dataset into six categories. Each category has a different formation mechanism and a different impact on the cast part. A dark hole is a deep, dark opening on the surface. It usually forms when material distribution is uneven and internal shrinkage creates a cavity that draws in air. A shallow pit is a small, rounded depression, often appearing in groups. It is commonly caused by molten-metal spatter and can make the surface uneven. A crack is an elongated discontinuity that may occur near curved connections; it can seriously reduce strength and may lead to fracture. A notch is a clear missing region on an edge, often caused by collision after solidification; it is one of the most serious casting defects. A bulge is an outward projection, often caused by insufficient grinding, and it can interfere with assembly. A depression is an inward concave region, often caused by excessive grinding; it can reduce stiffness and create loose fitting. My inspection system must distinguish these casting defects from normal surface texture, because the cast surface itself is frosted and naturally contains spots and lines.

Defect type Visual characteristics Typical cause Impact on the casting
Dark hole Deep dark opening, small diameter Uneven material, internal shrinkage, air entrapment Reduces strength and may create stress concentration
Shallow pit Rounded shallow depression, often grouped Molten-metal spatter, surface turbulence Affects appearance and slightly weakens the surface
Crack Elongated, irregular line or separation Cooling stress, pressure imbalance, material weakness Severe strength loss and possible fracture
Notch Missing material on an edge or corner Collision during handling or finishing Often makes the part unusable
Bulge Outward projection on an edge Insufficient grinding or finishing Interferes with assembly and dimensional fit
Depression Inward concave region Excessive grinding or finishing Reduces stiffness and creates loose connections

The production environment matters because casting defects are generated before inspection even begins. In a typical foundry line, metal is melted, poured, pressed or injected, cooled, demolded, and then finished. Each stage can introduce casting defects. Uneven material can create internal cavities. Splashing can create surface pits. Mold impact can create cracks or notches. Grinding can create bulges or depressions. Because one weak step can cause irreversible damage, inspection must be repeated across multiple views. In my setup, I used a five-megapixel industrial camera and captured images of 2566 by 1940 pixels. I fixed the part with an industrial robotic arm and captured five views: front, back, top, left, and right. I used a closed box and consistent lighting to reduce variation. Even so, casting defects remained small, random, and easily confused with normal surface texture.

When I applied deep learning to casting defect detection, I immediately encountered three major difficulties. The first difficulty was pixel compression. Most convolutional neural networks resize input images to a small size such as 224 by 224 or 256 by 256 in order to limit parameters and computation. For ordinary object classification, this is acceptable because the object is large and its global shape is enough. For casting defects, however, the defect is often a small detail. A dark hole may occupy only ten to fifty pixels in the original image. If I resize the whole 2566 by 1940 image to 256 by 256, the dark hole may become only one or two pixels, or disappear entirely. The second difficulty was target size. Directly detecting a tiny casting defect in a very large image is similar to finding a needle in a haystack. A one-stage detector may generate many candidate boxes, but small defects may be missed or merged with background texture. The third difficulty was interference. The surface of the casting is not smooth. It has natural spots, grinding marks, and texture. Some casting defects are similar to these normal patterns. In addition, different casting defects may resemble one another. A dark hole and a shallow pit both appear as small dark or shadowed regions. A crack and a normal line may have similar orientation and contrast. Multiple casting defects may even appear in the same local area.

Challenge Why it matters for casting defects Consequence if ignored
Pixel compression Defect detail is lost when a large image is resized Small casting defects become invisible or ambiguous
Tiny target size A defect may occupy very few pixels in a large field of view Missed detections and low recall
Surface texture interference Frosted cast surfaces contain natural spots and lines False positives increase
Inter-class similarity Different casting defects share shape, color, or shadow cues Classification confusion increases
Intra-class variation The same defect type can vary greatly in size and shape Handcrafted features become unreliable
Limited labeled data Defective samples are less frequent than normal samples Overfitting and poor generalization
Real-time requirement Inspection must keep pace with production Slow models cannot be deployed

To solve these problems, I avoided a single-network solution. Instead, I designed a two-stage algorithm. In the first stage, I trained a YOLO detector to find the regions of the casting that need inspection. In the second stage, I used an improved ResNet-50 classifier to determine whether each region contains casting defects and, if so, which category it belongs to. This transforms the original problem from “find a tiny defect in a very large image” into “find medium-sized casting regions in a large image, then inspect small defects inside each region.” The first task is much easier for a detector, because the casting regions have clear boundaries, stable positions, and strong shape cues. The second task is much easier for a classifier, because each region is resized to a moderate resolution and the input no longer contains the entire background. In this way, I preserved defect detail while reducing the search space.

The overall algorithm starts by removing irrelevant background. In my images, the upper part is mostly background, the middle part contains the robotic gripper, and only the casting itself is the object of interest. The casting occupies roughly thirty percent of the image. If I ran a detector over the whole image, I would waste computation and risk learning the gripper as a casting-like object. Therefore, I first restrict attention to the casting area. I train YOLO to locate six target regions: left top platform, right top platform, left upper link, right upper link, left lower link, and right lower link. Each region is treated as a separate class for detection. The detector predicts a bounding box and a class label for each region. Then I map those boxes back to the original high-resolution image, crop the corresponding regions, and resize them to 256 by 256 pixels. These cropped region images become the input to the second-stage classifier.

Region label Region name Typical defect risk Detection difficulty
T1 Left top platform Dark holes, shallow pits, cracks Moderate
T2 Right top platform Dark holes, shallow pits, cracks Moderate
L1 Left upper link Cracks, notches, depressions High due to curved geometry
L2 Right upper link Cracks, notches, depressions High due to curved geometry
D1 Left lower link Notches, bulges, depressions High due to edge variability
D2 Right lower link Notches, bulges, depressions High due to edge variability

For the first stage, I used YOLO-v3. YOLO treats object detection as a regression problem and uses a single end-to-end network to predict bounding boxes and class probabilities. It divides the input image into an S by S grid. If the center of an object falls into a grid cell, that cell is responsible for detecting the object. Each cell predicts B bounding boxes. Each bounding box contains five values: center x, center y, width, height, and confidence. The confidence is defined as the product of objectness probability and intersection over union. The class posterior probability is predicted separately. The final detection tensor has the form:

$$ S \times S \times (B \times 5 + C) $$

where C is the number of classes. For each object class i, the class posterior is:

$$ C_i = \Pr(\text{class}_i \mid O) $$

The confidence score is:

$$ \text{confidence} = \Pr(O) \cdot IOU_{\text{pred}}^{\text{truth}} $$

Combining class probability and confidence gives the class-specific confidence:

$$ \Pr(\text{class}_i \mid O) \cdot \Pr(O) \cdot IOU_{\text{pred}}^{\text{truth}} = \Pr(\text{class}_i) \cdot IOU_{\text{pred}}^{\text{truth}} $$

This score is used to suppress weak boxes and keep the most reliable detections. YOLO-v3 uses Darknet-53 as its backbone. The backbone uses repeated 1 by 1 and 3 by 3 convolutions, residual connections, and no fully connected layers. It produces three prediction scales, which helps detect objects of different sizes. Although my casting regions are medium-sized rather than tiny, multi-scale prediction is still useful because the links and platforms differ in scale and aspect ratio.

Component Role in YOLO-v3 Benefit for casting region detection
Darknet-53 backbone Feature extraction with 53 convolution layers Strong shape representation for casting regions
Residual connections Reduce gradient degradation in deep layers Stable training on industrial images
Multi-scale prediction Detect objects at different sizes Handles platforms and links of different scales
Bounding-box regression Predicts x, y, width, height Provides precise crop coordinates
Class prediction Predicts the region category Separates left and right regions

The second stage is the core classification network. I selected ResNet-50 because of its strong balance between depth, accuracy, and computational cost. ResNet-50 uses residual blocks to solve the degradation problem that appears when very deep networks are trained. A residual block does not learn a direct mapping H(x). Instead, it learns the residual F(x) = H(x) – x, and the output becomes:

$$ H(x) = F(x) + x $$

This shortcut connection makes optimization easier. If a layer is already near optimal, the network can learn F(x) approximately zero, and the identity path preserves the information. This is important for casting defects because I do not want useful low-level texture and edge information to disappear as depth increases. The original ResNet-50 output layer has 1000 classes. I removed the final fully connected layer and replaced it with a seven-class Softmax classifier: six casting defect categories plus a no-defect class.

Stage ResNet-50 structure Output channels Purpose
Stage 1 7 by 7 convolution, max pooling 64 Initial edges and low-level texture
Stage 2 3 residual blocks 256 Local patterns and small casting defects
Stage 3 4 residual blocks 512 Mid-level shape and texture combinations
Stage 4 6 residual blocks 1024 Complex defect structures
Stage 5 3 residual blocks 2048 High-level semantic representation
Output Average pooling and Softmax 7 Defect category prediction

The general convolution operation in my network can be written as:

$$ M_i = f(M_{i-1} \otimes W_i + b_i) $$

where \(M_i\) is the feature map of layer i, \(M_{i-1}\) is the previous feature map, \(W_i\) is the convolution kernel, \(b_i\) is the bias, and \(f\) is the activation function. The output size of a convolution layer is:

$$ H_{\text{out}} = \frac{H_{\text{in}} + 2p – h_f}{s_1} + 1 $$

$$ W_{\text{out}} = \frac{W_{\text{in}} + 2p – w_f}{s_2} + 1 $$

Pooling compresses the feature map and enlarges the effective receptive field:

$$ M_i = g(M_{i-1}) $$

The final classification layer uses Softmax:

$$ Y_i = \frac{e^{\theta_i^T x}}{\sum_{j=1}^{k} e^{\theta_j^T x}} $$

During training, the network performs forward propagation to produce predictions and backward propagation to update weights. The output-layer error is:

$$ \delta_j^L = \frac{\partial C}{\partial a_j^L}\sigma'(z_j^L) $$

and the error is propagated backward by:

$$ \delta^l = ((W^{l+1})^T\delta^{l+1})\odot \sigma'(z^l) $$

These standard operations allow the network to learn the difference between casting defects and normal surface texture. However, I found that the original ResNet-50 was not sufficient by itself. The casting defect classification task is more difficult than ordinary image classification because the classes are fine-grained and the background is highly similar across classes. I therefore introduced three improvements: stronger data features, a better activation function, and a multi-channel convolutional neural network.

First, I normalized every input image before training. The pixel values originally ranged from 0 to 255. I mapped them to approximately minus one to one using:

$$ X = \frac{X_0}{128} – 1.0 $$

Normalization has two benefits. It improves numerical stability and makes gradient updates more consistent. It also reduces the influence of extreme brightness values. This matters because casting defects often appear as subtle dark or bright regions. If one local area has an extreme value, it may dominate the matrix multiplication and mislead the classifier. Normalization makes the network focus more on relative contrast and structure.

Second, I expanded the dataset. The number of labeled casting defects was limited, and deep residual networks have many parameters. Without augmentation, overfitting would be severe. I applied four operations: mirror flipping, random rotation, random scaling, and random translation. Mirror flipping reverses the x-axis pixels. Random rotation rotates the image by 90, 180, or 270 degrees and then applies a small random rotation between minus ten and plus ten degrees. Random scaling stretches or compresses the image along the x and y axes with a scale factor between 0.9 and 1.1. Random translation shifts the image along x and y by up to twenty pixels. These operations increase the diversity of the training set while preserving the essential appearance of casting defects.

Augmentation Operation Range or setting Purpose
Mirror flip Reverse x-axis pixel order Horizontal Reduce left-right bias
Random rotation Rotate by right angles and small angles 90, 180, 270, plus minus ten degrees Improve rotation invariance
Random scaling Stretch or compress axes 0.9 to 1.1 Improve scale robustness
Random translation Shift pixels along x and y Minus twenty to plus twenty pixels Reduce position dependence

Third, I optimized the learning rate. A fixed learning rate is rarely optimal. If the learning rate is too large, the loss may oscillate and skip a good minimum. If it is too small, training is slow and may fall into a poor local minimum. I used an exponential decay schedule:

$$ \eta = \eta_0 \cdot \gamma^{\lfloor g / d \rfloor} $$

Here \(\eta_0\) is the initial learning rate, \(\gamma\) is the decay rate, \(g\) is the global step, and \(d\) is the decay step. In my experiments, the initial learning rate was 0.01, the batch size was 50 images, the decay step was 20, and the final learning rate converged near \(1.000 \times 10^{-3}\). This schedule allowed fast exploration early in training and finer weight updates later.

Fourth, I replaced the standard ReLU activation with a new function called ASoftReLU. ReLU is defined as:

$$ \operatorname{ReLU}(x) = \max(x,0) $$

ReLU is fast and sparse, but it can cause neuron death. If a neuron receives negative inputs for all samples, its gradient becomes zero, and it may never recover. This reduces the effective capacity of the network. Softplus is a smooth alternative:

$$ \operatorname{Softplus}(x) = \ln(1+e^x) $$

Softplus has a nonzero gradient for negative inputs, but it is less sparse and can be slower. I combined the two ideas into ASoftReLU. In my implementation, the function is defined as:

$$ \operatorname{ASoftReLU}(x)=
\begin{cases}
x, & x>0,\\
A\,\dfrac{\ln(1+e^x)}{\ln 2}, & x\le 0.
\end{cases}
$$

Here \(A\) is a parameter between zero and one. When \(A=0\), the function becomes ReLU. When \(A=1\), the negative side becomes a normalized Softplus-like curve. The derivative for negative inputs is:

$$ \frac{d}{dx}\operatorname{ASoftReLU}(x) =
A\,\frac{1}{\ln 2}\cdot\frac{e^x}{1+e^x}, \quad x\le 0. $$

This derivative is nonzero for negative inputs, so neurons can continue to update. For positive inputs, the derivative is one, so the network retains fast convergence and avoids saturation. In my experiments, I tested \(A=0, 0.1, 0.3, 0.5, 0.7, 0.9\). The best result appeared at \(A=0.3\).

Property ReLU Softplus ASoftReLU
Negative gradient Zero Nonzero Nonzero when A is greater than zero
Positive gradient One Less than one and saturating One
Sparsity High Low Adjustable through A
Neuron death risk High Low Low
Convergence speed Fast when healthy Moderate Fast and stable

Fifth, I built a multi-channel convolutional neural network. The idea is to feed the same casting region through several differently enhanced input paths. Each path contains a data-augmented version of the image and a contrast-enhanced version. The purpose is to force the network to see the same casting defects under different appearance conditions. If one path loses a subtle feature because of pooling or downsampling, another path may preserve it. If one path is affected by illumination, another path may reveal the underlying structure. This improves robustness against interference from surface texture and lighting.

The feature enhancement module has two operations. The first is histogram equalization. It stretches the gray-level distribution and makes the image contrast more uniform. The second is intensity adjustment, often called imadjust. It maps the original gray values to a new range, which can brighten dark casting defects or suppress bright reflections. For each augmented image, I produce three versions: the original image, the histogram-equalized image, and the intensity-adjusted image. These three images form the input set for one channel. The outputs from all channels are then averaged to produce the final prediction.

Input version Operation Effect on casting defects
Original image No enhancement Preserves natural appearance
Histogram equalized Nonlinear gray-level stretching Increases contrast of dark holes and cracks
Intensity adjusted Gray-value range mapping Reveals subtle shadows and pits

The multi-channel design can be summarized as follows. First, data augmentation expands one image into up to eight images. Second, each augmented image is converted into three contrast versions. Third, each version is sent through a separate ResNet-50 path. Fourth, the probabilities from all paths are averaged. I tested channel counts of 1, 2, 4, 6, and 8. The eight-channel network gave the best result. The structure is not simply an ensemble of independent models; it is a coordinated feature-reinforcement system designed specifically for casting defects.

Module Input Output Main operation
Data expansion One casting region image Up to eight augmented images Mirror, rotate, scale, translate
Image enhancement Each augmented image Three contrast versions Histogram equalization and imadjust
Single-channel learning One contrast version Seven-class probability vector Improved ResNet-50
Feature aggregation All channel outputs Final probability vector Average pooling over predictions

For evaluation, I used several standard metrics. Precision measures how many detected casting defects are correct:

$$ \text{Precision} = \frac{TP}{TP+FP} $$

Recall measures how many true casting defects were found:

$$ \text{Recall} = \frac{TP}{TP+FN} $$

Intersection over union measures localization quality:

$$ \text{IoU} = \frac{|DR \cap GT|}{|DR \cup GT|} $$

Mean average precision summarizes detection performance across classes:

$$ \text{mAP} = \frac{1}{n}\sum_{j=1}^{n} AP_j $$

Frames per second measures inference speed:

$$ \text{FPS} = \frac{N_{\text{frames}}}{\Delta t} $$

I implemented the system on TensorFlow and used OpenCV for image processing. The hardware included an Intel Core i7-4700 CPU, an NVIDIA RTX 2070ti GPU, and 32 GB RAM. The software environment included Windows 10, Anaconda3, CUDA 9.1, and OpenCV 3.4. I conducted three groups of experiments. The first group tested YOLO for casting region detection. The second group tested the ASoftReLU parameter in the ResNet classifier. The third group tested the multi-channel convolutional neural network. I also compared my approach with traditional methods such as k-nearest neighbors and a PCA plus BP neural network.

In the first experiment, I used 850 automobile brake bracket samples. I selected 625 original images as the initial dataset. After sample deformation and randomization, each image was expanded into four images, giving 2500 samples. I used 2000 for training and 500 for testing. The training set was divided into 20 batches of 100 images. The test set was divided into 5 batches of 100 images. Each training step used 10 images. One epoch contained 20 batches. I trained for 100 epochs. The network converged quickly during the first 20 epochs and then became stable. The best test accuracy occurred at epoch 48, with 89.0 percent accuracy and an IoU score of 0.86. The detection speed remained around 34 frames per second, which meets real-time requirements.

Epoch Training accuracy Test accuracy IoU 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
52 93.5% 88.4% 0.85 34
54 94.2% 87.7% 0.86 34

The first experiment showed that YOLO is effective at finding casting regions. The test set contained six region classes with 500 targets each, for a total of 3000 targets. The model detected 2933 targets. Among them, 2611 were correct. The average precision was 89.0 percent, and the average recall was 87.0 percent. The overall detection rate was 97.76 percent, which means the network almost always found the region, even if it sometimes confused the exact region class. This is acceptable for the first stage because the main purpose is to obtain crop locations, not to make the final defect decision.

Region Total Detected Correct Precision Recall
Left platform 500 488 444 91.0% 88.8%
Left upper link 500 485 426 87.8% 85.2%
Left lower link 500 490 427 87.1% 85.4%
Right platform 500 492 453 92.1% 90.6%
Right upper link 500 487 429 88.1% 85.8%
Right lower link 500 491 432 88.0% 86.4%
Average 500 488.8 435.1 89.0% 87.0%

The second experiment focused on the classifier. I built a dataset of 1600 images, each resized to 256 by 256 pixels. It contained 203 dark holes, 185 shallow pits, 197 bulges, 212 depressions, 206 cracks, 197 notches, and 400 no-defect images. I expanded the dataset to 6400 images using augmentation. From these, I used 5400 images for training and 1000 images for testing. The test set contained 125 images for each of the six casting defect classes and 250 no-defect images. I tested ASoftReLU with parameter \(A\) equal to 0, 0.1, 0.3, 0.5, 0.7, and 0.9. When \(A=0\), the function is equivalent to ReLU, so this serves as the baseline.

Parameter A Best epoch Defect presence accuracy Defect category accuracy
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 showed that \(A=0.3\) gave the best overall performance. The defect presence accuracy reached 92.1 percent, and the defect category accuracy reached 86.2 percent. Compared with the ReLU baseline, the improvement was 0.8 percentage points for presence detection and 1.6 percentage points for category classification. More importantly, the improved network converged faster. I observed that ASoftReLU reduced the risk of dead neurons and allowed the network to continue learning from negative activation regions. This was especially useful for casting defects because some defects produce weak, low-contrast responses that can easily push a neuron into the negative region.

The third experiment evaluated the multi-channel convolutional neural network. I used the same dataset as the second experiment and tested channel counts of 1, 2, 4, 6, and 8. Because the number of channels changes the number of images processed per iteration, I measured training by iteration rather than by epoch. The results showed that all configurations reached convergence between approximately 340,000 and 350,000 steps. This indicates that adding channels did not greatly increase the number of training steps needed. However, the channel count did affect accuracy. The eight-channel network gave the best result: 94.3 percent defect presence accuracy and 88.2 percent defect category accuracy.

Channels Training steps Defect presence accuracy Defect category accuracy
1 340,000 93.3% 86.4%
2 344,000 93.5% 87.1%
4 348,000 93.8% 87.9%
6 345,000 94.1% 87.5%
8 347,000 94.3% 88.2%

I then examined the eight-channel network in detail. The test set contained 125 samples of each casting defect category and 250 no-defect samples. The network detected 711 defect images, of which 702 were correct. It also detected 289 no-defect images, of which 241 were correct. In other words, 48 defective images were incorrectly classified as no-defect, and 9 no-defect images were incorrectly classified as defective. The overall defect presence accuracy was 94.3 percent. For defect category classification, the results varied by class. Depressions had the highest category precision at 93.5 percent. Cracks had a precision of 92.0 percent. Shallow pits reached 91.7 percent. Bulges reached 91.5 percent. Dark holes reached 87.9 percent. Notches reached 85.2 percent. The no-defect class had the highest recall at 96.4 percent.

Class Actual count Detected Correct Precision Recall
Dark hole 125 124 109 87.9% 87.2%
Shallow pit 125 121 111 91.7% 88.8%
Crack 125 112 103 92.0% 82.4%
Notch 125 128 109 85.2% 87.2%
Bulge 125 118 108 91.5% 86.4%
Depression 125 108 101 93.5% 80.8%
No defect 250 289 241 83.4% 96.4%
Overall 1000 1000 882 88.2% 88.2%

The confusion pattern is informative. Notches were detected more often than their actual count, and depressions were detected less often. This suggests that some depressions were misclassified as notches. Both casting defects involve missing or recessed material near an edge, and their boundary shapes can be similar. Dark holes were sometimes confused with shallow pits because both appear as small dark spots. Cracks were sometimes missed because they can be thin and low-contrast. These confusions are expected in fine-grained casting defect classification. For many industrial applications, the most important decision is whether a casting defect exists at all. On that binary task, the eight-channel network achieved 94.3 percent accuracy, which is strong enough for practical screening.

I also compared my method with two traditional approaches: k-nearest neighbors and a PCA plus BP neural network. The k-nearest neighbor method used handcrafted features and a simple classifier. The PCA plus BP method used principal component analysis for dimensionality reduction and a backpropagation network for classification. Both were trained and tested on the same dataset. The results show that deep learning methods greatly outperform traditional methods on casting defects. ResNet-50 with ReLU reached 91.3 percent defect presence accuracy and 84.6 percent category accuracy. ASoftReLU improved this to 92.1 percent and 86.2 percent. The eight-channel network improved it further to 94.3 percent and 88.2 percent. The relative improvement from the baseline ResNet-50 to the final model was 3.0 percentage points for defect presence and 3.6 percentage points for defect category.

Method Defect presence accuracy Defect category accuracy
KNN 67.3% 55.2%
PCA plus BP 75.2% 69.9%
ResNet-50 baseline 91.3% 84.6%
ASoftReLU ResNet-50 92.1% 86.2%
Eight-channel improved network 94.3% 88.2%

From my experiments, I conclude that a two-stage deep-learning pipeline is effective for casting defects. The first stage solves the localization problem by finding casting regions at a moderate scale. The second stage solves the classification problem by inspecting each region at a higher effective resolution. This design avoids the pixel-compression problem. It also reduces interference from the background and the gripper. The YOLO stage is not perfect in region classification, but its detection rate is very high, and its crop coordinates are reliable enough for the next stage. The ResNet stage benefits from residual learning, data augmentation, normalization, exponential learning-rate decay, ASoftReLU, and multi-channel feature reinforcement. Each improvement contributes to the final accuracy on casting defects.

There are still limitations. First, the region detector performs better on flat platforms than on curved links. The curved links have complex geometry and similar local appearance, so region classification errors can occur. Second, the classifier sometimes confuses casting defects that look alike, such as depressions and notches. Third, the two-stage architecture increases inference time. YOLO alone is fast, and ResNet alone is fast, but running both stages in sequence reduces throughput. In my tests, the YOLO stage ran at about 34 frames per second, but the full pipeline was slower. It remained close to real-time, but further optimization is needed. Fourth, the dataset is still limited. Although I used augmentation, the number of real casting defects is small compared with large-scale image datasets. More samples would improve generalization.

For future work, I would expand the system in several directions. I would collect more casting defects from different production batches, lighting conditions, and camera angles. I would explore lightweight backbone networks such as MobileNet or EfficientNet to reduce computation. I would also investigate attention modules that can focus on small casting defects while suppressing normal surface texture. Another direction is to combine the two stages into a single multi-task network that predicts both region coordinates and defect categories. This could reduce inference time. I would also study semi-supervised learning, because labeled casting defects are expensive to obtain. Finally, I would integrate the model with a robotic sorting system so that defective castings can be removed automatically.

In summary, my research shows that casting defects can be detected with high accuracy using deep learning. The proposed method begins with YOLO-based region detection and continues with an improved ResNet-50 classifier. The classifier uses normalization, augmentation, exponential learning-rate decay, ASoftReLU, and a multi-channel convolutional structure. The final model reached 94.3 percent accuracy in deciding whether a casting defect exists and 88.2 percent accuracy in identifying the defect category. These results confirm that deep learning is a practical and effective approach for casting defect detection. The method reduces manual dependence, preserves fine defect detail, and provides a foundation for automated industrial inspection of casting defects.

Scroll to Top