Improved YOLOv7-based steel marking area detection model and training method thereof
By improving the backbone network and detection head module of the YOLOv7 model, optimizing computational complexity, and enhancing the ability to focus on feature regions, the problems of deployment difficulties and insufficient robustness of the YOLOv7 model in industrial fields have been solved, and efficient detection of steel marking areas has been achieved.
Patent Information
- Application Number
- CN202511327070.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-17
- Publication Date
- 2025-10-24
- 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 directly deploy in edge computing devices at industrial sites. It also has poor robustness under lighting changes and surface interference.
An improved backbone network module and detection head module, including MCBS, MELAN, MP-1, AXA, MLCA, etc., are adopted. Through structural optimization and attention mechanism, the computational complexity is reduced and the model's ability to focus on key feature regions is enhanced.
It significantly reduces the computational load of the model, improves the target recognition performance and robustness of the model in complex scenarios, and is suitable for edge computing devices.
Smart Images

Figure CN120833474A_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: S1, constructing a steel marking area detection data set; labeling the steel image collected by the camera device, and the labeling content contains the steel marking area to be detected, so as to obtain the steel marking area detection data set.
[0010] S2, the steel marking area detection data set obtained in step S1 is divided into a training set, a validation set and a test set.
[0011] S3, inputting the training set in step S2 into the steel marking area detection model based on 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.
[0012] S4, using the validation set of step S2 to adjust the hyperparameters of the model trained in step S3 and monitor the overfitting of the model.
[0013] 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.
[0014] 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.
[0015] The beneficial effects of the present application are that: by improving the existing YOLOv7 model, on the one hand, the CBS module in the model is structurally optimized and replaced, the effective feature extraction capability is retained, the model operation amount is significantly compressed, and the calculation complexity of the model is reduced; on the other hand, the axial attention (AXA) module and the mixed local channel attention module (MLCA) are introduced, the attention ability of the model to the key feature area is enhanced, and the target recognition performance in complex scenes is improved. BRIEF DESCRIPTION OF DRAWINGS
[0016] ATTACHMENT Figure 1This is an overall structural block diagram of a steel marking area detection model based on improved YOLOv7 in an embodiment; Attachment Figure 2 This is a structural block diagram of the MCBS module in the embodiment; Attachment Figure 3 This is a structural block diagram of the MELAN module in the embodiment; Attachment Figure 4 2 is a structural block diagram of the MLCA module in the embodiment. DETAILED DESCRIPTION
[0017] Example 1, with reference to Figures 1-4The 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.
[0018] 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.
[0019] 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 the 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.
[0020] 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.
[0021] For the above model, the embodiment also provides a training method of a steel marking area detection model based on an improved YOLOv7, including the following steps: 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.
[0022] 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.
[0023] 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.
[0024] 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.
[0025] 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.
[0026] 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.
[0027] 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. An improved YOLOv7-based steel marking area detection model, characterized in that: 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, then three groups of MP-1 modules and MELAN modules are sequentially connected, and 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; the detection head module is composed of an AXA module, an MLCA module, an SPPCSPC module, a MELAN module, a 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 C5 is input into the AXA module, then the SPPCSPC module, the MCBS module and the up-sampling module are sequentially connected, then the output after C4 is input into the MLCA module is fused, then the MELAN module, the MCBS module and the up-sampling module are sequentially connected, then the output after C3 is input into the MLCA module is fused, then the MELAN module is connected and P3 is output, P3 is input into the MELAN module after being down-sampled by the MP-2 module and being superimposed with the output of the MELAN module connected after C4 is input into the MLCA module, then the MELAN module is connected and P4 is output, P4 is input into the MELAN module after being down-sampled by the MP-2 module and being superimposed with the output of the SPPCSPC module connected after C5 is input into the AXA module, then the MELAN module is connected and P5 is output, and P3, P4 and P5 are sequentially connected with the REP module and the CBM module respectively and then the steel mark category and the rectangular frame corresponding to the position of the steel mark are output.
2. The steel marking area detection model based on the improved YOLOv7 according to claim 1, wherein: 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.
3. 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 the ELAN module of the original YOLOv7 and replaces the CBS module in the ELAN module with the MCBS module.
4. 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 the input feature map to generate an attention weight map, the GAP layer obtains a global description of the image by performing an average pooling operation on all positions of the feature map output by the LAP, and the UNAP layer has two UNAP layers, one of which integrates non-local information of the output of the convolution layer of the GAP layer, and the other of which integrates non-local information of the related outputs of the LAP layer and the GAP layer.
5. A training method of a steel marking area detection model based on improved YOLOv7 according to any one of claims 1-4, characterized in that, The method comprises the following steps: S1, constructing a steel marking area detection data set; labeling the steel image collected by the camera device, the labeling content including the steel mark area to be detected, so as to obtain the steel marking area detection data set; 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; 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, use the minimum loss function to improve the detection accuracy of the model; S4, use the validation set of step S2 to adjust the hyperparameters of the model trained in step S3 and monitor the overfitting of the model; S5, use the test set of step S2 to test the performance of the model adjusted in step S4, and finally complete the training of the model.
6. The training method of the steel marking area detection model based on the improved YOLOv7 according to claim 5, 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 changes in light and pattern distortion factors.
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