Detecting surface defects on steel poses a significant challenge attributed to factors such as poor contrast, diverse defect types, complex background clutter, and noise interference present in images of steel surface defects. Current detection techniques face challenges in quickly and accurately identifying defects within complex backgrounds. To address the deployment of high-precision detection models on edge devices with limited resources, particularly for identifying steel surface defects, this study introduces a Multi-Scale Adaptive Fusion (MSAF) YOLOv8n defect detection algorithm designed for complex backgrounds. This algorithm effectively balances detection speed and accuracy. Firstly, a Multi-Scale Adaptive Fusion Block (MS-AFB) is proposed for the extraction of multi-scale features. Secondly, a Dynamic Coordinate Attention Ghostconv Space Pooling Pyramid-fast Cross-stage Partial Convolutional (DCA-GSPPFCSPC) is devised to significantly improve detection accuracy. Furthermore, the detection head has been redesigned utilizing Lightweight Multi-scale Convolutional (LMSC) approach, and an Adaptive Pyramid Receptive Field Block (AP-RFB) has been introduced to improve the receptive field efficiently. Meanwhile, Normalized Weighted Distance (NWD) and Weighted Intersection over Union (WIoU) are employed as the boundary box loss functions, serving as substitutes for Complete Intersection over Union (CIoU) loss function with a ratio of 2:8. The experimental results obtained from the improved Northeastern University Defect Dataset (NEU-DET) dataset demonstrate that MSAF-YOLOv8n model, despite having 40.4 % of the parameters and 28.8 % of Floating Point Operations (FLOPs) of YOLOv8s, achieves a mAP@.5 that is 0.9 % higher than that of YOLOv8s. Additionally, MSAF-YOLOv8n demonstrates robust generalization capabilities in Pascal VOC2007, self-constructed datasets, and various other datasets. Subsequently, the model is implemented on embedded systems, namely Jeston TX2 NX and Orange Pi 5+, both of which demonstrate real-time detection capabilities.