Abstract:To address issues of high memory usage, computational complexity, and inadequate detection speed in defect detection algorithms for complex scenarios, this paper proposes a lightweight forged defect detection algorithm based on YOLOv8. First, magnetic particle inspection images from the production line of heavy truck steering knuckles were collected to construct a forged surface crack dataset. Then, a lightweight convolution module, GSConvns, was introduced to enhance feature interaction and reduce computational load. The Shape-IOU loss function was employed to optimize training performance. Finally, the LAMP pruning strategy was used to remove unnecessary weight parameters, reducing model size and increasing detection speed. Experimental results show that the model achieves a mAP of 83.8%, with parameter and computational reductions of 85.05% and 80.25%, respectively. Detection speed improved from 38.7 FPS to 65.6 FPS, significantly outperforming other mainstream algorithms, making it more suitable for real-time detection. The algorithm′s generalization capability was further verified on a public dataset, with the unpruned improved algorithm′s mAP value increasing by 2.0% compared to the baseline. In summary, this algorithm significantly enhances detection speed and resource efficiency without substantially compromising detection accuracy.