A steel marking area detection model based on improved YOLOv7 and a training method thereof
By improving the structure of the YOLOv7 model, replacing the CBS module with the MCBS module, and introducing the AXA and MLCA modules, the problems of high computational complexity and poor robustness of YOLOv7 were solved, and efficient steel marking area detection was achieved on edge computing devices.
Patent Information
- Application Number
- CN202511327070.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-17
- Publication Date
- 2025-12-16
- Estimated Expiration
- 2045-09-17
AI Technical Summary
The existing YOLOv7 model has high computational complexity and strong dependence on computing resources, making it difficult to deploy directly in edge computing devices in industrial settings. Furthermore, it has poor robustness under changes in lighting and surface interference.
By improving the YOLOv7 model, replacing the CBS module with the MCBS module, and introducing the Axial Attention (AXA) module and the Hybrid Local Channel Attention (MLCA) module, the model structure is optimized, the computational complexity is reduced, and the ability to focus on key feature regions is enhanced.
It significantly reduces the computational load of the model, improves the target recognition performance of the model in complex scenes, enhances the robustness to changes in lighting and surface disturbances, and is suitable for edge computing devices.
Smart Images

Figure CN120833474B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of steel surface detection, and particularly relates to a steel marking area detection model based on an improved YOLOv7 and a training method thereof. BACKGROUND
[0002] In modern industrial manufacturing processes, steel is widely used as a basic raw material in various fields such as construction, transportation, and energy. In order to effectively manage and trace the steel products, marking processing such as code spraying, engraving, and laser marking is usually performed on the surface of the steel to identify key information such as production batch and specification. With the increasing automation of industry, there is a growing demand for real-time area detection of steel marking results to ensure the accuracy and integrity of the marking content. Computer vision technology, especially deep learning-based object detection methods, provides a new solution for this task. The YOLO (You Only Look Once) series of object detection algorithms have become a research hotspot in the field of industrial vision due to their compact structure, fast detection speed, and high accuracy. YOLOv7, as the latest improved version of this series, has shown excellent performance on public datasets such as COCO and has become a widely concerned detection framework in engineering practice. However, the original YOLOv7 model still has high computational complexity and strong dependence on computing resources, making it difficult to be directly deployed on edge computing devices in industrial sites, so lightweight improvement of YOLOv7 has become an important research direction.
[0003] Existing visual recognition technologies for steel marking area detection are mostly based on traditional image processing methods or general object detection frameworks. A common solution is to use morphological operations, gray threshold segmentation, edge detection, and other algorithms to locate and extract characters on the surface of the steel. This method has certain effect in standardized environments, but its robustness to changes in lighting and surface interference is poor. With the development of deep learning, some research has begun to introduce network models such as YOLOv5 and YOLOv7, combined with industrial datasets for transfer learning, to achieve automatic detection and classification of steel marking characters. For example, patent CN106650721B discloses an industrial character recognition method based on a convolutional neural network, which uses an integrated model of multiple convolutional neural networks for feature extraction and character content recognition through voting. In addition, the journal article "Improved YOLO Steel Surface Defect Detection Algorithm" (Modern Electronic Technology, No. 13, 2024) proposes using YOLOv5 to extract defect areas on the surface of steel plates and using swin transformer for classification and positioning. However, most of these solutions focus on recognition accuracy, and there is still a lack of optimization research on algorithm deployment efficiency and model size, especially in mobile terminals or embedded platforms. SUMMARY
[0004] The application aims to provide a steel marking area detection model based on improved YOLOv7 and a training method thereof, so as to solve the problems of high complexity and strong dependence on computing resources of the existing YOLOv7 model.
[0005] To achieve the above-mentioned purpose, the application adopts the following technical scheme: a steel marking area detection model based on improved YOLOv7, comprising a backbone network module and a detection head module, the backbone network module comprising four MCBS modules, four MELAN modules and three MP-1 modules, the four MCBS modules and one MELAN module being connected in sequence, and then three groups of MP-1 modules and MELAN modules being connected in sequence, the three groups of MP-1 modules and MELAN modules sequentially outputting feature maps of different sizes, denoted as C3, C4 and C5; the detection head module being composed of an AXA (axial attention) module, an MLCA (mixed channel attention) module, an SPPCSPC module, a MELAN module, an MCBS module, an up-sampling (Upsample) module, a REP module and a CBM module, C3, C4 and C5 output by the backbone network module being sequentially input into the MLCA module, the MLCA module and the AXA module, wherein C5 is input into the AXA module, and then sequentially connected with the SPPCSPC module, the MCBS module and the up-sampling module, and then fused with the output after C4 is input into the MLCA module, and then sequentially connected with the MELAN module, the MCBS module and the up-sampling module, and then fused with the output after C3 is input into the MLCA module, and then connected with the MELAN module and output P3, P3 being connected with the output of the MELAN module after C4 is input into the MLCA module and then stacked and connected with the MELAN module and output P4, P4 being connected with the output of the SPPCSPC module after C5 is input into the AXA module and then stacked and connected with the MELAN module and output P5, P3, P4 and P5 being sequentially connected with the REP module and the CBM module respectively and then outputting the steel marking category and the rectangular frame corresponding to the position of the steel marking.
[0006] The MCBS module in the backbone network module and the detection head module is composed of a convolution layer, a batch normalization layer and a RELU activation function layer.
[0007] Specifically, the MELAN module in the backbone network module and the detection head module uses the ELAN module of the original YOLOv7 and replaces the CBS module in the ELAN module with the MCBS module.
[0008] Specifically, the MLCA module in the detection head module is composed of a LAP layer, a GAP layer, a convolution layer and a UNAP layer; in the MLCA module, the LAP first applies a convolution layer to the input feature map to generate an attention weight map, the GAP layer obtains the global description of the image by performing average pooling operation on all positions of the feature map output by the LAP, and the UNAP layer has two, one of which integrates non-local information for the output of the GAP layer after the convolution layer, and the other integrates non-local information for the related output of the LAP layer and the GAP layer.
[0009] A training method of the steel marking area detection model based on the improved YOLOv7, comprising the following steps:
[0010] S1, constructing a steel marking area detection data set; the steel image collected by the camera device is labeled, and the labeling content contains the steel marking area to be detected, so as to obtain the steel marking area detection data set.
[0011] S2, the steel marking area detection data set obtained in step S1 is divided into a training set, a verification set and a test set.
[0012] S3, input the training set in step S2 into the steel marking area detection model based on YOLOv7, and continuously adjust the model parameters through the back propagation algorithm, and use the minimum loss function to improve the detection accuracy of the model.
[0013] S4, using the verification set of step S2 to adjust the hyperparameters of the model trained in step S3 and monitor the overfitting of the model.
[0014] S5, using the test set of step S2 to test the performance of the model adjusted in step S4, and finally completing the training of the model.
[0015] Specifically, in the process of training the model in step S3, part of the data in the training set is randomly cropped, rotated, flipped or color jittered to improve the robustness of the model to light changes and pattern distortion factors.
[0016] The beneficial effects of the present application are: by improving the existing YOLOv7 model, on the one hand, by optimizing and replacing the CBS module in the model, while retaining the effective feature extraction capability, significantly compressing the model operation amount and reducing the computational complexity of the model; on the other hand, introducing the axial attention (AXA) module and the mixed local channel attention module (MLCA), enhancing the attention ability of the model to the key feature area and improving the target recognition performance in complex scenes. BRIEF DESCRIPTION OF DRAWINGS
[0017] ATTACH Figure 1A structural block diagram of a steel marking area detection model based on an improved YOLOv7 in the embodiment;
[0018] Figure 2 is a structural block diagram of the MCBS module in the embodiment; Figure 2
[0019] Figure 3 is a structural block diagram of the MELAN module in the embodiment; Figure 3
[0020] Figure 4 is a structural block diagram of the MLCA module in the embodiment. Figure 4 DETAILED DESCRIPTION
[0021] Embodiment 1, refer to Figures 1-4 The application discloses a steel marking area detection model based on an improved YOLOv7, which comprises a backbone network module and a detection head module, wherein the backbone network module comprises four MCBS modules, four MELAN modules and three MP-1 modules, the four MCBS modules and one MELAN module are sequentially connected, and then three groups of MP-1 modules and MELAN modules are sequentially connected; the three groups of MP-1 modules and MELAN modules sequentially output feature maps of different sizes, which are denoted as C3, C4 and C5; before a to-be-detected picture is input into the backbone network module, the to-be-detected picture is uniformly adjusted to 640*640 in size through scaling; after the to-be-detected picture is input into the backbone network module, feature extraction is performed by the four MCBS modules, the four MCBS modules are four MCBS modules with different size convolution kernels (two MCBS modules with 1*1 size convolution kernels and two MCBS modules with 3*3 size convolution kernels can be adopted), then the feature maps are output after passing through one MELAN module, and then the feature maps are sequentially output after passing through three groups of MP-1 modules and MELAN modules. The detection head module is composed of an AXA module, an MLCA module, an SPPCSPC module, a MELAN module, an MCBS module, an up-sampling module, a REP module and a CBM module; C3, C4 and C5 output by the backbone network module are sequentially input into the MLCA module, the MLCA module and the AXA module; wherein after C5 is input into the AXA module, the C5 is sequentially connected with the SPPCSPC module, the MCBS module and the up-sampling module, then the C5 is fused with the output of the MLCA module after C4 is input into the MLCA module, then the C5 is sequentially connected with the MELAN module, the MCBS module and the up-sampling module, then the C5 is fused with the output of the MLCA module after C3 is input into the MLCA module, then the C5 is connected with the MELAN module and outputs P3, then P3 is connected with the output of the MELAN module after the MELAN module of the MLCA module after C4 is input into the MLCA module is stacked and then the MELAN module outputs P4, then P4 is connected with the output of the MELAN module after the MELAN module of the MLCA module after C5 is input into the AXA module is stacked and then the MELAN module outputs P5, and then P3, P4 and P5 are sequentially connected with the REP module and the CBM module and then the P3, P4 and P5 output the steel marking category and the rectangular frame corresponding to the position of the steel marking. After C3, C4 and C5 output by the backbone network module are input into the detection head module, C3 and C4 are input into the MLCA (mixed local channel attention) module, respectively, so as to further mine and enhance the key feature representation in the local spatial region and the channel dimension; C5 is decomposed into row and column components through the AXA (axial attention) module, and the attention mechanism is independently applied to each component, so that the receptive field of each target pixel is expanded to W or H pixels in the row or column of the target pixel, the dynamic attention combination in the row and column directions is realized, the range of the receptive field is effectively increased, and the model performance is optimized. Not only the attention degree of the model to important information in a specific region is improved, but also the adaptability and recognition accuracy of the model in a complex scene are significantly enhanced.
[0022] Specifically, the MCBS module in the backbone network module and the detection head module is composed of a convolution layer (Conv), a batch normalization layer (BN) and a RELU activation function layer; the MCBS module used in this embodiment is improved from the original YOLOv7 CBS module, and the SiLu activation function with high calculation complexity in the CBS module is replaced by the ReLU activation function with low calculation complexity. In addition, the MELAN module in the backbone network module and the detection head module uses the ELAN module of the original YOLOv7, and the CBS module in the ELAN module is replaced by the improved MCBS module described above; the MCBS module of this embodiment is designed based on the conclusion that "deeper networks can learn and converge more effectively by controlling the shortest and longest gradient paths", which realizes higher model parameter utilization efficiency, more stable model learning ability and more efficient model inference speed, and can realize higher precision without increasing additional complex architecture, and has stronger robustness.
[0023] Specifically, the MLCA module in the detection head module is composed of a LAP layer, a GAP layer, a convolution layer and a UNAP layer; in the MLCA module, the LAP first applies a convolution layer to the input feature map to generate an attention weight map, the GAP layer obtains the global description of the image by performing average pooling operation on all positions of the feature map output by the LAP, and the UNAP layer has two, one of which integrates non-local information of the output of the GAP layer through the convolution layer, and the other integrates non-local information of the related outputs of the LAP layer and the GAP layer. The MLCA module of this embodiment combines local spatial attention and channel attention mechanisms to perform multi-dimensional weighted fusion on input features, and the LAP layer, the GAP layer and the UNAP layer used by the MLCA module jointly process feature information in different ways, thereby improving the ability of the model to understand and analyze complex data; through this local-channel joint modeling method, the MLCA module can effectively improve the perception ability of the model to the detailed features of the target in a complex scene, and especially in the face of challenging conditions such as occlusion, light change or background interference, the MLCA module shows stronger robustness and discrimination ability, and the enhanced features output by the MLCA module provide high-precision target detection support for subsequent processing.
[0024] In addition, in the detection head module, the remaining modules are the same as the original YOLOv7 model except for the improved AXA module, the MLCA module, the MELAN module and the MCBS module.
[0025] For the above model, this embodiment further provides a training method of a steel marking area detection model based on an improved YOLOv7, including the following steps:
[0026] S1, a steel marking area detection data set is constructed; a steel image collected by a camera device is labeled, and the labeling content includes a steel marking area to be detected, so as to obtain the steel marking area detection data set.
[0027] S2, the steel marking area detection data set obtained in step S1 is divided into a training set, a verification set and a test set.
[0028] S3, the training set in step S2 is input into the steel marking area detection model based on YOLOv7, and the model parameters are continuously adjusted through a back propagation algorithm, and the detection accuracy of the model is improved using a minimum loss function. In the embodiment, an Adam optimizer is used for training, and a suitable learning rate strategy is set, specifically, a cosine annealing method is used to speed up the convergence speed and avoid overfitting.
[0029] S4, the model trained in step S3 is adjusted in parameters and the overfitting of the model is monitored using the verification set in step S2.
[0030] S5, the model adjusted in step S4 is tested in performance using the test set in step S2, and the training of the model is finally completed.
[0031] Specifically, in the process of training the model in step S3, part of the data in the training set is randomly cropped, rotated, flipped or color jittered, so as to improve the robustness of the model to light changes and pattern distortion factors.
[0032] Of course, the above is only a preferred embodiment of the present application, and does not limit the use range of the present application, therefore, any equivalent changes made on the principle of the present application should be included in the protection scope of the present application.
Claims
1. A training method of a steel marking area detection model based on improved YOLOv7, characterized in that, It comprises the following steps: S1, constructing a steel marking area detection dataset; labeling the steel image collected by the camera device, the labeling content including the steel marking area to be detected, so as to obtain the steel marking area detection dataset; S2, the steel marking area detection dataset obtained in step S1 is divided into a training set, a validation set and a test set; S3, inputting the training set in step S2 into the steel marking area detection model based on the improved YOLOv7, and continuously adjusting the model parameters through the back propagation algorithm, and using the minimum loss function to improve the detection accuracy of the model; S4, adjusting the hyperparameters of the model trained in step S3 and monitoring the overfitting of the model using the validation set in step S2; S5, performance testing of the model adjusted in step S4 using the test set in step S2, and finally completing the training of the model; The steel marking area detection model based on the improved YOLOv7 comprises a backbone network module and a detection head module, the backbone network module comprises four MCBS modules, four MELAN modules and three MP-1 modules, the four MCBS modules and one MELAN module are connected in sequence, and then three groups of MP-1 modules and MELAN modules are connected in sequence, and the three groups of MP-1 modules and MELAN modules output feature maps of different sizes in sequence, denoted as C3, C4 and C5; the detection head module is composed of AXA module, MLCA module, SPPCSPC module, MELAN module, MCBS module, up-sampling module, REP module and CBM module, C3, C4 and C5 output by the backbone network module are input into the MLCA module, MLCA module and AXA module in sequence, wherein C5 is input into the AXA module, then the SPPCSPC module, MCBS module and up-sampling module are connected in sequence, then the output after the C4 input into the MLCA module is fused, then the MELAN module, MCBS module and up-sampling module are connected in sequence, then the output after the C3 input into the MLCA module is fused, then the MELAN module is connected and P3 is output, P3 is down-sampled by the MP-2 module, then the output of the MELAN module connected after the C4 input into the MLCA module is superimposed, then the MELAN module is connected and P4 is output, P4 is down-sampled by the MP-2 module, then the output of the SPPCSPC module connected after the C5 input into the AXA module is superimposed, then the MELAN module is connected and P5 is output, P3, P4 and P5 are connected with the REP module and CBM module in sequence respectively, and then the steel marking class and the rectangular frame corresponding to the steel marking position are output.
2. The training method of the steel marking area detection model based on the improved YOLOv7 according to claim 1, characterized in that: In the process of training the model in step S3, part of the data in the training set is randomly cropped, rotated, flipped or color jittered to improve the robustness of the model to light changes and pattern distortion factors.
3. The training method of the steel marking area detection model based on the improved YOLOv7 according to claim 1, characterized in that: The MCBS module in the backbone network module and the detection head module is composed of a convolution layer, a batch normalization layer and a RELU activation function layer.
4. The training method of the steel marking area detection model based on the improved YOLOv7 according to claim 2, characterized in that: The MELAN module in the backbone network module and the detection head module uses an ELAN module of an original YOLOv7 and replaces a CBS module in the ELAN module with the MCBS module.
5. The training method of the steel marking area detection model based on the improved YOLOv7 according to claim 1, characterized in that: The MLCA module in the detection head module is composed of a LAP layer, a GAP layer, a convolution layer and a UNAP layer; in the MLCA module, the LAP first applies a convolution layer to input feature maps to generate an attention weight map, the GAP layer obtains a global description of an image by performing an average pooling operation on all positions of feature maps output by the LAP, and the UNAP layer has two, one of which integrates non-local information of an output of the GAP layer through the convolution layer, and the other integrates non-local information of related outputs of the LAP layer and the GAP layer.
Citation Information
Patent Citations
An Industrial Character Recognition Method Based on Convolutional Neural Networks
CN106650721B
Target detection method under view angle of unmanned aerial vehicle based on OSD-YOLO
CN120355894A