Casting defects are among the most critical factors affecting the service performance, fatigue life, and operational safety of industrial equipment. In my research, I focus on developing a lightweight yet high-precision surface defect detection method for industrial castings. Traditional visual inspection methods suffer from low efficiency, poor stability, and strong subjectivity, making them inadequate for modern industrial production that demands high precision and automation. Although deep learning has provided effective tools for intelligent detection of casting defects, existing models still face challenges such as insufficient recognition of small-scale defects, large parameter sizes, high computational costs, and difficulty in real-time deployment on resource-constrained embedded platforms. To address these issues, I propose a lightweight and high-precision surface defect detection method for casting defects, enabling the detection of multiple defect types and model deployment.
The main contributions of my work are threefold. First, I construct a multi-class casting surface defect dataset by collecting images of eight typical defect types using a stereo camera in industrial scenes. I apply perceptual hashing, Laplacian variance, fast Fourier transform, and a quick shift image segmentation algorithm to remove highly repetitive or blurred images, and I perform illumination correction on locally overexposed images. I then incorporate horizontal flipping, color jittering, and slight perspective transformation for data augmentation, providing reliable data support for subsequent object detection research. Second, I propose an improved detection model based on RT-DETR, named FSD-DETR. This model uses a lightweight StarNet as the backbone feature extraction network and embeds a frequency channel attention mechanism to reduce parameter scale while enhancing cross-channel feature representation. I design a feature aggregation module with geometric perception enhancement to improve multi-scale feature extraction and fusion. I also introduce a PIoU loss function to improve the localization accuracy of tiny casting defects. Third, to further meet embedded deployment requirements, I adopt the LAMP pruning strategy to compress the FSD-DETR model and combine channel-wise distillation to compensate for accuracy loss. After pruning and distillation, the model parameters are reduced from 13.1M to 7.4M, and the computational cost is reduced from 37.1 GFLOPs to 21.9 GFLOPs, while mAP@50 remains at 96.1% and the inference speed reaches 397 FPS. Finally, I build a software and hardware environment on an embedded platform and develop a visual casting defect detection system based on PyQt5, realizing functions such as image detection and real-time video detection, verifying the engineering practicability of the algorithm.
The detection of casting defects is essential because the surface quality of castings directly affects the mechanical properties, fatigue life, and safety of final products. Castings are widely used in automotive manufacturing, mechanical engineering, aerospace, energy equipment, and rail transportation. In actual casting production, various casting defects inevitably appear on the surface due to material properties, process control precision, environmental factors, and equipment performance. These casting defects differ significantly in appearance, formation mechanism, and impact on product performance, increasing the complexity and technical difficulty of detection tasks. Common surface casting defects can be categorized into eight types: incomplete, porosity, shrinkage depression, crack, blowhole, protrusion, scratch, and dross hole. Each type of casting defect has distinct morphological characteristics and affects the performance of castings in different ways. For example, incomplete casting defects refer to missing or incomplete contours caused by insufficient filling of molten metal, which significantly affects sealing performance, structural strength, and service life. Porosity casting defects are cavities formed by gas trapped in the metal during solidification, reducing the effective load-bearing cross-sectional area and increasing the risk of fracture. Shrinkage depression casting defects are depressions or holes caused by volume shrinkage during solidification, affecting load-bearing capacity and sealing performance. Crack casting defects are fractures formed by stress concentration or thermal stress, severely weakening structural strength and increasing the risk of fracture. Blowhole casting defects are essentially large porosity defects. Protrusion casting defects are abnormal elevations on the surface or inside the casting, affecting dimensional accuracy and durability. Scratch casting defects are linear damages formed during subsequent processing, affecting surface quality and appearance. Dross hole casting defects are holes formed by inclusions that fail to discharge during filling, reducing strength and durability. These eight types of casting defects form the basis of my dataset and detection task.

Traditional non-destructive testing techniques include penetrant testing, eddy current testing, and ultrasonic testing. Penetrant testing uses capillary action to reveal surface-breaking casting defects, but it is time-consuming and subjective. Eddy current testing detects changes in eddy current distribution to identify surface and near-surface casting defects, offering fast speed and high sensitivity, but it is limited to conductive materials. Ultrasonic testing uses high-frequency mechanical waves to detect internal casting defects, providing high precision and wide coverage, but it requires coupling agents and is difficult to automate. These traditional methods cannot fully satisfy the requirements of modern casting production for high-precision, large-scale, and real-time quality control. Traditional target detection methods based on handcrafted features and machine learning classifiers, such as threshold segmentation, edge detection, and morphological processing, depend on manually set parameters and have limited generalization ability in complex casting scenarios with illumination changes, surface noise, and structural differences. Deep learning has brought new solutions for industrial defect detection. With powerful feature learning capabilities, deep learning models can learn surface texture and geometric features from large-scale samples, offering stronger nonlinear expression and environmental adaptability. However, existing deep learning models for casting defect detection still suffer from insufficient recognition of small-scale casting defects, interference from complex surface textures, and insufficient lightweight design for real-time industrial requirements. Therefore, I aim to develop a casting defect detection model that combines high precision, high robustness, and high real-time performance.
To build a reliable dataset for casting defects, I collected images using a stereo camera in industrial sites, covering eight typical casting defect categories. I gathered over 15,000 raw images with a resolution of 1280×1280. I then performed data cleaning to remove blurred, redundant, or non-informative samples. I used perceptual hashing to detect duplicate images by calculating the Hamming distance between hash values. When the difference was less than a preset threshold of 5, I considered the images duplicate or highly similar and removed them. I also used Laplacian variance to quantify edge sharpness; a lower variance indicates a blurrier image. I combined this with fast Fourier transform to analyze frequency-domain features by masking low-frequency regions and calculating high-frequency energy means. When the Laplacian variance was below 60 or the FFT score was below 6, I classified the image as blurred and removed it. I further manually reviewed the dataset to eliminate images with unclear casting defects or damaged samples. For locally overexposed images, I applied illumination correction using a quick shift segmentation algorithm. I converted images to grayscale, detected reflective regions via brightness thresholds to generate initial masks, and refined mask edges using superpixel segmentation in color space. I then applied mean filtering to repair the regions, reducing reflection while preserving local structure integrity. After cleaning, I retained 4,000 high-quality images. To enhance dataset diversity and robustness, I applied three data augmentation methods: horizontal flipping, color jittering, and slight perspective transformation. Horizontal flipping generates samples with opposite orientations, improving generalization across different casting defect directions. Color jittering simulates different lighting conditions and color deviations by adjusting brightness, contrast, and saturation with factors of 0.3, 0.4, and 0.5, respectively, executed in random order with probability 1.0. Slight perspective transformation simulates camera angle changes, equipment tilt, and shooting angle deviations by randomly shifting the four corner points within horizontal and vertical ranges of [−0.1w, +0.1w] and [−0.1h, +0.1h] with a scale of 0.1. After augmentation, the dataset expanded to 4,168 images. I used LabelImg for annotation and chose the YOLO format. Each image corresponds to a text file with one line per target instance, containing the class index and normalized bounding box parameters: class index, center x, center y, width, height. The label distribution of casting defects is summarized in Table 1.
| Defect Type | Number of Labels |
|---|---|
| Incomplete | 1,535 |
| Porosity | 2,124 |
| Shrinkage | 659 |
| Crack | 873 |
| Blowhole | 501 |
| Protrusion | 746 |
| Scratch | 686 |
| Dross hole | 815 |
For the detection model, I propose FSD-DETR, an improved RT-DETR-based architecture for casting defect detection. The overall structure consists of a backbone, a hybrid encoder, and a decoder. I replace the original ResNet18 backbone with StarNet, a lightweight network designed for efficient feature extraction. StarNet uses element-wise multiplication to fuse features from different subspaces, achieving high-dimensional nonlinear mapping similar to polynomial kernel functions. This star operation enables the network to continuously enhance hidden feature complexity through stacked layers, achieving near-infinite-dimensional feature representation in a compact feature space. To further improve detection accuracy and robustness in complex industrial scenarios, I embed a frequency channel attention (FCA) mechanism into the feature extraction stage. The FCA mechanism applies discrete cosine transform (DCT) to map input feature maps from the spatial domain to the frequency domain. It divides the feature map along the channel dimension into multiple sub-feature maps, performs DCT on each, and selects representative frequency components. Frequency mapping normalization unifies different resolutions into consistent frequency representations. Then, global average pooling reduces the channel dimension to 1/r of the original, followed by a ReLU activation and a fully connected layer to restore the original channel number. A Sigmoid function generates channel-wise weights for adaptive adjustment. The weighted features are multiplied element-wise with the input feature map, enhancing global semantic information and suppressing redundant background noise. I name the improved module Fstar Block. Table 2 compares StarNet with other lightweight backbones.
| Network | Parameters (M) | mAP@50 (%) | mAP@50:95 (%) |
|---|---|---|---|
| ResNet18 | 19.9 | 94.4 | 65.3 |
| EfficientViT | 10.7 | 91.8 | 59.4 |
| MobileNet | 11.3 | 90.7 | 60.6 |
| RepViT | 13.3 | 91.8 | 61.7 |
| UniRepLKNet | 12.7 | 91.0 | 59.8 |
| StarNet | 12.0 | 95.0 | 65.7 |
In addition to the backbone improvement, I design a feature aggregation module called FRA (Feature-aware Relation Aggregation) with geometric perception enhancement. The FRA module contains two 1×1 convolution layers at the front and back ends to compress channel dimensions and fuse multi-level features, reducing computational complexity while preserving key information. Between the two 1×1 convolutions, I embed a DSConv module (Dynamic Snake Convolution) that uses adaptive distribution shifts to adjust the receptive field dynamically according to the geometric shape of the target. This dynamic receptive field adaptation enables the model to capture slender, curved, and complex casting defect shapes more effectively. The FRA module also uses residual connections to add input features to the module output, enhancing feature expression and ensuring continuous information flow, alleviating gradient vanishing during deep network training. DSConv decomposes standard convolution into a variable quantized kernel (VQK) and distribution shifts. The VQK has dimensions (cho, chi, k, k), quantized to variable-length integer values. Distribution shifts include kernel distribution shift (KDS) and channel distribution shift (CDS). KDS applies distribution shifts to each (1, BLK, 1, 1) slice of the VQK, where BLK is a hyperparameter determining the block size for permutation. CDS applies channel-level distribution shifts to each (1, chi, k, k) slice. The iterative adjustment of the convolution kernel ensures linear structural stability. For a convolution kernel K, each grid position produces an additive effect. Along the x-axis, the kernel from initial position Ki to Ki+c depends on the previous grid position with an additional offset Δ = {δ | δ ∈ [−1,1]}. The changes along the x-axis and y-axis are given by:
$$ K_{i \pm c} = \begin{cases} (x_{i+c}, y_{i+c}) = (x_i + c, y_i + \sum \Delta y_{i+c}^i) \\ (x_{i-c}, y_{i-c}) = (x_i – c, y_i + \sum \Delta y_i^{i-c}) \end{cases} $$
$$ K_{j \pm c} = \begin{cases} (x_{j+c}, y_{j+c}) = (x_j + \sum \Delta x_{j+c}^j, y_j + c) \\ (x_{j-c}, y_{j-c}) = (x_j + \sum \Delta x_j^{j-c}, y_j – c) \end{cases} $$
For the loss function, I replace the original GIoU with PIoU (Pixel-IoU) to improve localization accuracy for tiny casting defects. GIoU provides weak penalty when predicted and ground-truth boxes are completely disjoint or have minimal overlap, leading to insufficient gradient feedback. PIoU integrates angle information and IoU metrics to compute pixel-level overlap area, providing more comprehensive evaluation of differences between predicted and target boxes. It considers angle, area, and pixel differences, making it more sensitive to small overlapping regions. PIoU also suppresses false overlaps between background and target boxes, enhancing discrimination and reducing missed detections. For a oriented rectangle b with parameters (cx, cy, w, h, θ), where c is the center, w and h are width and height, and θ is the tilt angle, the pixel p_{i,j} projects a perpendicular to the center line to obtain intersection t_{i,j}. The triangle T has side lengths d_{i,j}^w, d_{i,j}^h, and d_{i,j}. A binary constraint determines whether a pixel is inside the oriented rectangle. Since the binary constraint is not continuously differentiable, I approximate it using the product of two kernel functions:
$$ F(p_{i,j} | b) = K(d_{i,j}^w, w) K(d_{i,j}^h, h) $$
$$ K(d, s) = 1 – \frac{1}{1 + e^{-k(d – s)}} $$
The intersection and union areas are computed as:
$$ S_{b \cap b’} \approx \sum_{p_{i,j} \in B_{b,b’}} F(p_{i,j} | b) F(p_{i,j} | b’) $$
$$ S_{b \cup b’} \approx w \times h + w’ \times h’ – S_{b \cap b’} $$
Then PIoU is defined as:
$$ \text{PIoU}(b, b’) = \frac{S_{b \cap b’}}{S_{b \cup b’}} $$
Let M denote the set of positive sample pairs and |M| the number of positive sample pairs. The PIoU loss is:
$$ L_{piou} = \frac{-\sum_{(b,b’) \in M} \ln \text{PIoU}(b,b’)}{|M|} $$
I conducted experiments on an Ubuntu 22.04 system with an Intel Xeon 8362 processor, 45 GB RAM, and an NVIDIA RTX 3090 GPU. I used CUDA 12.1 and PyTorch 2.3.0. No pretrained weights were loaded. Training ran for 120 epochs with batch size 8, and all input images were resized to 640×640. I evaluated detection accuracy using mAP@50 and mAP@50:95, and assessed lightweight design and real-time capability using Parameters, GFLOPs, and FPS. The precision, recall, AP, and mAP are defined as follows:
$$ \text{Precision} = \frac{TP}{TP + FP} $$
$$ \text{Recall} = \frac{TP}{TP + FN} $$
$$ AP = \int_{0}^{1} P(R) \, dR $$
$$ mAP = \frac{1}{N} \sum_{i=1}^{N} AP_i $$
I first evaluated different attention modules fused with StarNet. Table 3 shows the results. The FCA module achieved the best performance, improving mAP@50 and mAP@50:95 by 0.7% and 0.8%, respectively, without significantly affecting model lightweightness.
| Model | Parameters (M) | mAP@50 (%) | mAP@50:95 (%) |
|---|---|---|---|
| StarNet | 12.00 | 95.0 | 65.7 |
| +CA | 12.03 | 91.9 | 60.8 |
| +GC | 12.12 | 95.5 | 65.4 |
| +ECA | 12.00 | 95.8 | 65.8 |
| +FCA | 12.03 | 95.7 | 66.5 |
I also compared different IoU loss functions. Table 4 shows that PIoU achieved the best mAP@50:95 of 66.4% while maintaining mAP@50 at 95.2%, demonstrating its effectiveness in providing fine-grained gradient feedback for high-quality detection results.
| Model | IoU | mAP@50 (%) | mAP@50:95 (%) |
|---|---|---|---|
| RT-DETR | GIoU | 94.4 | 65.3 |
| RT-DETR | CIoU | 94.6 | 65.9 |
| RT-DETR | DIoU | 94.9 | 65.5 |
| RT-DETR | EIoU | 95.2 | 66.1 |
| RT-DETR | SIoU | 95.2 | 66.2 |
| RT-DETR | PIoU | 95.2 | 66.4 |
I performed hyperparameter experiments to determine the optimal batch size, learning rate, and number of epochs. Table 5 summarizes the results. The best configuration was batch size 8, learning rate 0.0001, and 120 epochs, achieving mAP@50 of 96.1% and mAP@50:95 of 67.4%.
| Group | Batch Size | Learning Rate | Epoch | Optimizer | Training Time (h) | mAP@50 (%) | mAP@50:95 (%) |
|---|---|---|---|---|---|---|---|
| 1 | 4 | 0.0001 | 120 | AdamW | 4.920 | 95.2 | 65.9 |
| 2 | 8 | 0.0001 | 120 | AdamW | 2.936 | 96.1 | 67.4 |
| 3 | 16 | 0.0001 | 120 | AdamW | 2.384 | 95.5 | 66.2 |
| 4 | 8 | 0.001 | 120 | AdamW | 3.021 | 93.0 | 61.3 |
| 5 | 8 | 0.0005 | 120 | AdamW | 2.918 | 94.7 | 65.1 |
| 6 | 8 | 0.00005 | 120 | AdamW | 3.120 | 95.6 | 65.5 |
| 7 | 8 | 0.0001 | 100 | AdamW | 2.392 | 95.6 | 66.3 |
| 8 | 8 | 0.0001 | 150 | AdamW | 3.614 | 95.9 | 67.0 |
I compared FSD-DETR with several mainstream models, including YOLOv5m, YOLOv8m, YOLOv10m, YOLO11m, and RT-DETR-L. Table 6 shows the comparison. FSD-DETR achieved 13.09M parameters and 37.1 GFLOPs, significantly lower than the compared models. It achieved 96.1% mAP@50, 67.4% mAP@50:95, and 92.3 FPS, demonstrating an excellent balance between accuracy and efficiency.
| Model | Parameters (M) | GFLOPs (G) | Precision (%) | Recall (%) | mAP@50 (%) | mAP@50:95 (%) | FPS |
|---|---|---|---|---|---|---|---|
| YOLOv5m | 25.05 | 64.0 | 91.7 | 85.8 | 91.9 | 61.8 | 103.5 |
| YOLOv8m | 25.84 | 78.7 | 93.4 | 87.3 | 92.7 | 63.2 | 87.2 |
| YOLOv10m | 16.46 | 63.5 | 89.3 | 80.7 | 89.3 | 61.6 | 87.6 |
| YOLO11m | 20.04 | 67.7 | 91.6 | 84.8 | 92.1 | 61.9 | 87.7 |
| RT-DETR-L | 32.00 | 103.5 | 93.4 | 89.7 | 94.0 | 64.7 | 53.5 |
| FSD-DETR (Ours) | 13.09 | 37.1 | 94.8 | 93.2 | 96.1 | 67.4 | 92.3 |
I also evaluated the detection performance for different casting defect types. Table 7 shows that FSD-DETR achieved superior results across most categories, with particularly strong performance on incomplete, shrinkage, crack, blowhole, protrusion, and scratch casting defects.
| Model | Incomplete (%) | Porosity (%) | Shrinkage (%) | Crack (%) | Blowhole (%) | Protrusion (%) | Scratch (%) | Dross hole (%) |
|---|---|---|---|---|---|---|---|---|
| YOLOv5m | 96.4 | 77.4 | 93.4 | 92.8 | 96.8 | 93.4 | 86.3 | 98.4 |
| YOLOv8m | 96.6 | 79.3 | 96.2 | 93.7 | 97.1 | 93.7 | 87.0 | 98.1 |
| YOLOv10m | 95.0 | 74.5 | 90.9 | 87.0 | 95.3 | 91.2 | 82.7 | 98.1 |
| YOLO11m | 97.3 | 78.0 | 91.9 | 94.2 | 96.9 | 94.6 | 85.1 | 99.0 |
| RT-DETR-L | 98.3 | 83.9 | 96.3 | 93.5 | 97.3 | 93.7 | 89.8 | 99.5 |
| FSD-DETR (Ours) | 98.7 | 86.5 | 98.5 | 97.6 | 97.3 | 95.9 | 95.0 | 99.4 |
I conducted ablation experiments to analyze the contribution of each improvement. Table 8 shows the results. H1 represents replacing ResNet18 with StarNet, H2 adds FCA to form Fstar Block, H3 incorporates the FRA module, and H4 replaces the loss function with PIoU. The final FSD-DETR model reduced parameters and GFLOPs by 34.2% and 34.9%, respectively, while improving mAP@50 and mAP@50:95 by 1.7% and 2.1%.
| Model | H1 | H2 | H3 | H4 | Parameters (M) | GFLOPs (G) | mAP@50 (%) | mAP@50:95 (%) |
|---|---|---|---|---|---|---|---|---|
| ResNet18 | 19.88 | 57.0 | 94.4 | 65.3 | ||||
| A | √ | 12.00 | 31.8 | 95.0 | 65.7 | |||
| B | √ | √ | 12.03 | 31.8 | 95.7 | 66.5 | ||
| C | √ | √ | 13.06 | 37.1 | 95.9 | 66.7 | ||
| D | √ | √ | 12.00 | 31.8 | 95.8 | 66.4 | ||
| E | √ | √ | √ | 13.09 | 37.1 | 96.2 | 66.7 | |
| FSD-DETR | √ | √ | √ | √ | 13.09 | 37.1 | 96.1 | 67.4 |
To evaluate generalization, I tested FSD-DETR on the public NEU-DET steel surface defect dataset. Table 9 shows that FSD-DETR achieved 74.6% mAP@50, outperforming YOLOv5, Faster R-CNN, RetinaNet, Multi-Scale YOLOv5, Fine-YOLO, NHD-YOLOx, and RT-DETR-r18. This demonstrates good cross-dataset generalization for casting defects and other industrial surface defects.
| Model | Crazing (%) | Patches (%) | Inclusion (%) | Pitted Surface (%) | Rolled-in Scale (%) | Scratches (%) | mAP@50 (%) |
|---|---|---|---|---|---|---|---|
| YOLOv5 | 47.0 | 92.2 | 78.2 | 77.1 | 44.9 | 71.0 | 65.7 |
| Faster R-CNN | 37.6 | 85.3 | 80.2 | 81.5 | 54.0 | 89.2 | 71.3 |
| RetinaNet | 45.9 | 91.1 | 84.2 | 74.7 | 43.5 | 81.6 | 70.2 |
| Multi-Scale YOLOv5 | 34.5 | 89.8 | 76.8 | 82.5 | 61.6 | 86.8 | 72.0 |
| Fine-YOLO | – | – | – | – | – | – | 73.1 |
| NHD-YOLOx | – | – | – | – | – | – | 74.3 |
| RT-DETR-r18 | 24.3 | 91.1 | 78.8 | 75.2 | 59.9 | 86.7 | 69.3 |
| FSD-DETR (Ours) | 51.5 | 84.9 | 81.7 | 76.7 | 61.8 | 91.1 | 74.6 |
To further compress the model for embedded deployment, I applied LAMP pruning. LAMP evaluates weight importance using a layer-adaptive magnitude-based score. The importance score for the u-th weight is:
$$ \text{score}(u,w) = \frac{w(u)^2}{\sum_{v \geq u} w(v)^2} $$
I compared L1 pruning, Group Hessian pruning, Group Taylor pruning, and LAMP pruning. Table 10 shows the results. The pruning factor P is defined as the ratio of post-pruning computational cost to pre-pruning computational cost. LAMP achieved the best balance. At P=1.4, parameters and GFLOPs were reduced to 8.3M and 25.8 GFLOPs, with mAP@50 remaining at 96.1% and FPS reaching 370.4. At P=1.6, parameters further decreased to 7.4M, GFLOPs to 21.9, and FPS to 400, with mAP@50 at 96.0%.
| Model | P | Parameters (M) | GFLOPs (G) | mAP@50 (%) | FPS |
|---|---|---|---|---|---|
| RT-DETR-r18 (original) | – | 19.9 | 57.0 | 94.4 | 90.1 |
| FSD-DETR (unpruned) | – | 13.1 | 37.1 | 96.1 | 92.3 |
| +L1 | 1.2 | 10.7 | 30.4 | 94.6 | 138.9 |
| +L1 | 1.4 | 9.1 | 26.0 | 92.7 | 333.3 |
| +L1 | 1.6 | 7.6 | 22.2 | 92.8 | 233.0 |
| +Group Hessian | 1.2 | 9.9 | 30.1 | 96.0 | 175.4 |
| +Group Hessian | 1.4 | 8.8 | 26.1 | 95.9 | 370.4 |
| +Group Hessian | 1.6 | 7.9 | 22.9 | 95.0 | 238.1 |
| +Group Taylor | 1.2 | 9.7 | 30.0 | 96.0 | 181.8 |
| +Group Taylor | 1.4 | 8.5 | 26.0 | 95.4 | 153.8 |
| +Group Taylor | 1.6 | 7.4 | 22.3 | 95.4 | 322.6 |
| +LAMP | 1.2 | 9.6 | 30.0 | 96.1 | 166.7 |
| +LAMP | 1.4 | 8.3 | 25.8 | 96.1 | 370.4 |
| +LAMP | 1.6 | 7.4 | 21.9 | 96.0 | 400.0 |
After pruning, I applied channel-wise distillation (CWD) to recover accuracy. CWD aligns feature distributions in the channel dimension between teacher and student models. I used the unpruned FSD-DETR as the teacher and the LAMP-1.6 pruned FSD-DETR as the student. I transformed student features using a 1×1 convolution to match teacher channel dimensions, applied Softmax normalization, and used KL divergence to measure channel-level feature distribution differences. Table 11 shows that after CWD, the student model maintained 7.4M parameters and 21.9 GFLOPs, while mAP@50 improved to 96.1% and FPS remained at 397. This confirms the effectiveness of the pruning-plus-distillation strategy for casting defect detection.
| Model | Parameters (M) | GFLOPs (G) | mAP@50 (%) | FPS |
|---|---|---|---|---|
| Teacher (FSD-DETR) | 13.1 | 37.1 | 96.1 | 92.3 |
| Student (FSD-DETR-LAMP) | 7.4 | 21.9 | 96.0 | 400 |
| FSD-DETR-LAMP-CWD | 7.4 | 21.9 | 96.1 | 397 |
For embedded deployment, I used an NVIDIA Jetson Nano platform. The Jetson Nano features a quad-core ARM Cortex-A57 CPU, a 128-core Maxwell GPU, 4GB LPDDR4 memory, and 16GB eMMC storage. It provides about 0.5 TFLOPs (FP16) computing capability. I configured the system with JetPack, CUDA, cuDNN, PyTorch, and OpenCV. I used an IMX219 camera with 8-megapixel resolution and MIPI CSI-2 interface for image acquisition. I also connected a 27-inch monitor for debugging and display. The deployment process included formatting an SD card, flashing the JetPack image, booting the system, and configuring the Python and deep learning environment. I developed a visual casting defect detection system based on PyQt5. The system includes login, parameter adjustment, model configuration, image detection, and real-time camera detection. The interface uses a dual-view comparison: the left side shows the original casting image, and the right side shows the detection result with bounding boxes, defect categories, and confidence scores. The system also supports saving detection results as images and structured data files for quality analysis and traceability. During operation, users can adjust confidence and IoU thresholds, load configuration files, and switch between image and video modes. The exit mechanism releases camera resources and database connections safely. Through actual testing, the system demonstrated stable performance, real-time detection, and high accuracy, verifying the engineering practicability of the proposed method for casting defect detection.
In summary, I have developed a lightweight and high-precision method for detecting casting defects. I constructed a multi-class casting surface defect dataset with eight typical defect types and applied comprehensive data cleaning and augmentation. I proposed the FSD-DETR model with a lightweight StarNet backbone, frequency channel attention, feature aggregation module, and PIoU loss, achieving significant improvements in both accuracy and efficiency. I further compressed the model using LAMP pruning and CWD distillation, reducing parameters by 62.8% and computational cost by 61.6% compared to the baseline, while maintaining mAP@50 at 96.1% and achieving 397 FPS. I deployed the model on an embedded platform and developed a visual detection system, demonstrating its practical value for industrial casting defect detection. Future work will focus on improving generalization to extreme conditions, exploring more efficient compression strategies, and integrating multimodal information such as acoustic emission, 3D point clouds, and process parameters to further enhance the detection of casting defects in complex industrial environments.
