Method for detecting display based on MYOLOv5s algorithm
Through the display detection method based on the MYOLOv5s algorithm, the problems of inefficiency and high labor cost of traditional testing methods are solved, and automated detection is realized, improving efficiency and accuracy.
Patent Information
- Application Number
- CN202411927120.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-25
- Publication Date
- 2025-04-18
AI Technical Summary
Traditional display testing methods require long-term manual observation and manual inspection, which is inefficient and takes up a lot of labor costs, making it difficult to achieve automated and efficient inspection.
Using the display detection method based on the MYOLOv5s algorithm, the MYOLOv5s network model is constructed, multi-scale training is performed, and the model is optimized using ZIoU loss function and Focal loss function to achieve automated detection.
It realizes the automation of display detection, improves detection efficiency and accuracy, reduces labor costs, and improves the potential for capacity improvement.
Smart Images

Figure CN119847842A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of display testing, and in particular relates to a method for display detection based on the MYOLOv5s algorithm. Background Art
[0002] Testing the display screen and various functions of the monitor is a necessary step before the product leaves the factory. The traditional testing method is to power on the newly produced or repaired monitor for a long time for verification, and an engineer needs to be arranged to observe it for a long time next to the test equipment.
[0003] Traditional testing methods require manual testing and filling out product work cards, which takes up a lot of labor costs, is inefficient, and limits the improvement of production capacity.
[0004] With the development of electronic computer hardware, especially the emergence of GPU, it has become a reality for computers to perform large-scale calculations on images. Computers can now replace humans to complete tasks such as target recognition, face recognition, and image recognition.
[0005] A display visual intelligent inspection method has been developed from the two aspects of appearance quality inspection and functional quality inspection. Based on the positioning of image detection area, efficient and intelligent image processing is achieved to realize automatic inspection. Summary of the invention
[0006] The object of the present invention is to provide a method for display detection based on the MYOLOv5s algorithm.
[0007] The technical solution to achieve the purpose of the present invention is: a method for display detection based on the MYOLOv5s algorithm, comprising the following steps:
[0008] Step (1): Prepare the dataset;
[0009] Step (2): Construct the MYOLOv5s network model: The MYOLOv5s network model includes a backbone network, a neck network, and a target detection output layer; the backbone network generates feature information of three different granularities, and the neck network uses an improved attention weighted feature pyramid fusion module CA-BiFPN;
[0010] Step (3): Perform multi-scale training on the network model constructed in step (2) to obtain the best model; the training loss function uses the ZIoU loss function as the bounding box regression loss, and the Focal loss function as the prediction confidence and category loss;
[0011] Step (4): Use the best model for testing, and optimize and adjust the best model obtained in step (3) according to the test results; use the optimized model to detect the display in real time to obtain the detection results.
[0012] Furthermore, step (1) is specifically as follows: acquiring display images, preprocessing the acquired images to adapt to the input requirements of the model; and dividing the preprocessed image data into a training set and a validation set in a ratio of 8:2.
[0013] Furthermore, the preprocessing in step (1) is image scaling or normalization.
[0014] Furthermore, step (2) specifically includes the following steps:
[0015] Step (21): adopt a multi-scale feature fusion strategy to fuse the low-level high-resolution and low-semantic information feature map with the high-level high-semantic information and low-resolution feature map; upsample the low-level feature map to the same resolution as the high-level feature map, and downsample the generated high-resolution feature map to generate feature maps of three different scales;
[0016] Step (22): Input the feature maps of three different scales into the improved attention weighted feature pyramid fusion module CA-BiFPN to interactively fuse shallow and deep detail information and high-level semantic information; finally, perform target detection and output the results.
[0017] Furthermore, the "ZIoU loss function" in step (3) takes the distance between the midpoints of the upper and lower boundaries as a factor, and takes the ratio of the sum of the distances between the midpoints of the upper and lower boundaries to the square of the diagonal length of the minimum bounding box as a new penalty term, thus obtaining the bounding box loss function ZIoU optimized for the data set, which is expressed as follows:
[0018]
[0019] In the formula, They are marked box b gt The Euclidean distance between the upper left corner and the lower right corner of the anchor box b, c, w c ,h c They represent the minimum diagonal length, width, and height of the minimum closure that can enclose the anchor box and the annotation box respectively; δ, β, γ are weighting coefficients, ranging from [-1, 1], and are initialized to 1.0.
[0020] Furthermore, the Focal loss function in step (3) is expressed as follows:
[0021] FL(p t )=-α t (1-p t ) γ log(p t )
[0022]
[0023] where α t represents the weight of positive and negative samples, and γ represents the weight of difficult and easy samples.
[0024] Furthermore, step (4) is specifically as follows: using the model obtained in step (3) to detect the image data in the test set, and evaluating the detection accuracy, speed and lightness of the detection results of the test set; the specific operations are as follows:
[0025] Use the trained MYOLOv5s model to detect the image data in the test set, record the detection results of each image, calculate the detection accuracy of the model based on the detection results of the test set, analyze the detection performance of the model in different categories and scenarios, find out the deficiencies of the model and optimize it; verify the effectiveness of the optimization process; use the optimized model to detect the real-time display and obtain the detection results.
[0026] Furthermore, the detection results include the detected target category, location, and confidence level; the detection accuracy includes precision, recall, and F1 score.
[0027] Compared with the prior art, the present invention has the following significant advantages:
[0028] The present invention applies MobileNetv3 to the feature extraction backbone network to reduce the number of network parameters and computational complexity; designs a multi-scale receptive field (RFB) module and embeds an attention mechanism ECA-Net module to improve the detection capability of landmarks of different scales; embeds an attention feature fusion module in the feature fusion layer to extend attention from same-layer fusion to cross-layer scenarios.
[0029] By studying the characteristics of the display screen dataset, the present invention finds that most of the display screens in the dataset will form two common intersections with the target box. The distance between the midpoints of the upper and lower boundaries is taken as a consideration, and the ratio of the sum of their distances to the square of the diagonal length of the minimum bounding box is used as a new penalty term. A bounding box loss function ZIoU optimized for the dataset is proposed.
[0030] The loss function of the present invention selects ZIoU loss as the bounding box regression loss and Focal loss as the prediction confidence and category loss, which speeds up the prediction box regression speed, reduces the interference of positive and negative sample imbalance on the model, and improves the detection accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 This is the MYOLOv5s network model structure of the present invention.
[0032] Figure 2 This is the CA-BiFPN module of the present invention. DETAILED DESCRIPTION
[0033] The present invention is further described in detail below in conjunction with the accompanying drawings.
[0034] The display detection steps based on the MYOLOv5s algorithm are as follows:
[0035] Step 1: Prepare the data set. Clean the previously collected display data set and remove duplicate, blurred, poor quality and other images that do not meet the requirements to improve the quality of the data set. Then preprocess the data set, such as image scaling and normalization, to meet the input requirements of the model. Divide the preprocessed data into a training set and a validation set in a ratio of 8:2.
[0036] Step 2: Construct a feature extraction network with high-resolution representation, and adopt a multi-scale feature fusion strategy to fuse the low-level feature maps with high resolution but less semantic information with the high-level feature maps with high semantic information but lower resolution. This is achieved by upsampling the low-level feature maps to the same resolution as the high-level feature maps and performing element-by-element addition or splicing. The fused feature maps contain rich semantic information while retaining high-resolution detail information. The final high-resolution feature maps are downsampled to generate feature maps of three different scales.
[0037] The MYOLOv5s network structure consists of three parts: Figure 1 ): Backbone network, neck network and target detection output. The backbone network extracts feature maps of different sizes from the input image through multiple convolutions and pooling; the neck network uses these feature maps of different sizes for fusion to obtain sufficient context information and reduce information omission; in the feature fusion process, the FPN and PAN feature pyramid structures are used to output the target feature map.
[0038] First, three feature channels with different granularity information are generated through the feature extraction network, with scales of 19×19, 38×38, and 76×76 respectively. First, the 76×76 feature map is convolved with a 3×3 convolution kernel and a step size of 1 to obtain a 38×38 feature map, which is then fused with the feature information of the original scale. Then, the fused 38×38 feature map is convolved in the same way to obtain a 19×19 feature map, which is fused again with the feature information of the original scale. Finally, the total fused information is upsampled by 2 and 4 times, respectively, and features of different scales are fused again.
[0039] Secondly, the feature information in these three multi-scale channels is input into the improved attention weighted feature pyramid fusion module (CA-BiFPN) to interactively fuse shallow and deep detail information and high-level semantic information. Finally, target detection is performed and the results are output. The CA-BiFPN module fuses the same-layer scene features with the cross-layer scene features according to the attention mechanism, including short-jump and long-jump connections, and even performs preliminary fusion within it to obtain high-resolution features of the target and improve the recognition accuracy of blurred targets.
[0040] Step 3: Use the model obtained in step 2 to train the image data in the training set. Use a smaller learning rate for preheating in the early stage, which helps the model converge more stably at the beginning of training. After the preheating stage, increase the learning rate to a preset higher level to accelerate the training speed of the model. The specific strategy of learning rate preheating can be adjusted according to the actual situation, such as using cosine decay, linear growth, etc. At the same time, in order to improve the detection accuracy of the algorithm for objects of different scales, a multi-scale training method is adopted. During the training process, the size of the input image is randomly adjusted so that the model can adapt to objects of different scales. This helps the model learn more robust feature representations and improves the detection ability of objects of different scales.
[0041] Secondly, select a suitable loss function and optimizer, such as formula (1), to optimize the model training process. Monitor indicators such as loss value and accuracy during the training process, and adjust the training parameters in time to optimize the model performance.
[0042] By studying the characteristics of the display screen dataset, it is found that most of the display screens in the dataset will form two common intersections with the target box. The present invention takes the distance between the midpoints of the upper and lower boundaries as a consideration, and takes the ratio of the sum of their distances to the square of the diagonal length of the minimum bounding box as a new penalty term, and proposes a bounding box loss function ZIoU optimized for the dataset.
[0043]
[0044] They are marked box b gt The Euclidean distance between the upper left corner and the lower right corner of the anchor box b. c, w c ,h c They represent the minimum diagonal length, width, and height of the minimum closure that can just enclose the anchor box and the annotation box. δ, β, and γ are weighting coefficients, ranging from [-1, 1] and initialized to 1.0.
[0045] In order to obtain more accurate classification accuracy, the present invention replaces the binary cross entropy loss function of confidence and classification with the Focal loss function. Focal loss is an improvement on the cross entropy loss, which is proposed to address the problem of uneven distribution of positive and negative samples in the classification process. Focal loss reduces the weight of simple background samples to allow the model to focus on the detection of foreground objects, avoiding the model's tendency to favor a larger number of background classes when predicting. The Focal loss function is shown in formula (2):
[0046] FL(p t )=-α t (1-p t ) γ log(p t ) (2)
[0047]
[0048] where α t represents the weight of positive and negative samples, and γ represents the weight of difficult and easy samples.
[0049] The loss function of the present invention selects ZIoU loss as the bounding box regression loss and Focal loss as the prediction confidence and category loss, which speeds up the prediction box regression speed, reduces the interference of positive and negative sample imbalance on the model, and improves the detection accuracy.
[0050] Step 4: Use the best model obtained from training for testing. Use the model obtained in step 3 to detect the image data in the test set, and evaluate the detection accuracy, speed, and lightweight of the test set. The specific operations are as follows: Use the trained MYOLOv5s model to detect the image data in the test set. Record the detection results of each image, including the detected target category, location, confidence, and other information. According to the detection results of the test set, calculate the detection accuracy of the model, such as accuracy, recall, F1 score, and other indicators. Analyze the detection performance of the model in different categories and scenarios to find out the advantages and disadvantages of the model. Measure the inference speed of the model on the test set, including the detection time of each image and the number of images that can be processed per second. Analyze the inference speed performance of the model under different hardware configurations and evaluate its real-time performance in practical applications. Evaluate the lightweight degree of the optimized MYOLOv5s model, including indicators such as model size, memory usage, and computational complexity. Compare the performance of the models before and after optimization in terms of detection accuracy, speed, and lightweight to verify the effectiveness of the optimization process. Finally, use the model to detect the real-time display and obtain the detection results.
Claims
1. A method for display detection based on MYOLOv5s algorithm, characterized in that: The steps include: Step (1): Prepare the dataset; Step (2): Construct the MYOLOv5s network model: The MYOLOv5s network model includes a backbone network, a neck network, and a target detection output layer; the backbone network generates feature information of three different granularities, and the neck network uses an improved attention weighted feature pyramid fusion module CA-BiFPN; Step (3): Perform multi-scale training on the network model constructed in step (2) to obtain the best model; the training loss function uses the ZIoU loss function as the bounding box regression loss, and the Focal loss function as the prediction confidence and category loss; Step (4): Use the best model for testing, and optimize and adjust the best model obtained in step (3) according to the test results; use the optimized model to detect the display in real time to obtain the detection results.
2. The method according to claim 1, characterized in that: Step (1) specifically includes: collecting display images, preprocessing the collected images to adapt to the input requirements of the model; and dividing the preprocessed image data into a training set and a validation set in a ratio of 8:
2.
3. The method according to claim 2, characterized in that The preprocessing in step (1) is image scaling or normalization.
4. The method according to claim 1, characterized in that: Step (2) specifically includes the following steps: Step (21): adopt a multi-scale feature fusion strategy to fuse the low-level high-resolution and low-semantic information feature map with the high-level high-semantic information and low-resolution feature map; upsample the low-level feature map to the same resolution as the high-level feature map, and downsample the generated high-resolution feature map to generate feature maps of three different scales; Step (22): Input the feature maps of three different scales into the improved attention weighted feature pyramid fusion module CA-BiFPN to interactively fuse shallow and deep detail information and high-level semantic information; finally, perform target detection and output the results.
5. The method according to claim 4, characterized in that The "ZIoU loss function" in step (3) takes the distance between the midpoints of the upper and lower boundaries as a factor, and takes the ratio of the sum of the distances between the midpoints of the upper and lower boundaries to the square of the diagonal length of the minimum bounding box as a new penalty term, resulting in a bounding box loss function ZIoU optimized for the dataset, expressed as follows: In the formula, They are marked box b gt The Euclidean distance between the upper left corner and the lower right corner of the anchor box b, c, w c ,h c They represent the minimum diagonal length, width, and height of the minimum closure that can enclose the anchor box and the annotation box respectively; δ, β, γ are weighting coefficients, ranging from [-1, 1], and are initialized to 1.
0.
6. The method according to claim 5, characterized in that The Focal loss function expression in step (3) is as follows: FL(p t )=-a t (1-p t ) γ log(p t ) where α t represents the weight of positive and negative samples, and γ represents the weight of difficult and easy samples.
7. The method according to claim 6, characterized in that Step (4) is specifically as follows: using the model obtained in step (3) to detect the image data in the test set, and evaluating the detection accuracy, speed and lightness of the detection results of the test set; the specific operations are as follows: Use the trained MYOLOv5s model to test the image data in the test set, record the test results of each image, calculate the detection accuracy of the model based on the test results of the test set, analyze the detection performance of the model in different categories and scenarios, find out the deficiencies of the model and optimize it; verify the effectiveness of the optimization process; Use the optimized model to detect the real-time display and obtain the detection results.
8. The method according to claim 7, characterized in that The detection results include the detected target category, location, and confidence level; the detection accuracy includes accuracy, recall rate, and F1 score.