Misrecognition elimination method based on YOLO target detection algorithm and medium
Through the improved Mosaic data augmentation and transfer learning method, combined with IoU Loss and Focal Loss, the YOLO object detection algorithm is optimized, which solves the problem of the YOLO algorithm in complex scenarios, and improves the detection accuracy and stability.
Patent Information
- Application Number
- CN202411376882.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-30
- Publication Date
- 2024-12-20
AI Technical Summary
YOLO object detection algorithm is prone to misidentification in complex scenarios, resulting in a decrease in the reliability of detection results. Especially due to factors such as lighting changes, object occlusion and background interference, it is difficult for the prior art to effectively reduce the false detection situation.
The improved Mosaic data augmentation method and transfer learning method are adopted to participate in the data augmentation process and use pre-trained models for model training. Combining IoU Loss and Focal Loss loss functions, the model is gradually optimized to reduce misidentification situations.
It improves the accuracy and stability of object detection, enhances the applicability of the model in various scenarios, realizes the effective elimination of misidentification, and improves detection accuracy and system stability.
Smart Images

Figure CN119169275A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer image recognition, and in particular to a method and medium for eliminating misidentification based on a YOLO target detection algorithm. Background Art
[0002] In the field of image processing, object detection technology plays a vital role. The YOLO (You Only LookOnce) object detection algorithm has attracted much attention due to its high efficiency and real-time performance, and has been widely used in many application scenarios, such as autonomous driving, security monitoring, industrial detection, etc.
[0003] In practical applications, the YOLO target detection algorithm faces the challenge of misidentification. Due to the complexity and diversity of real-world scenes, including factors such as lighting changes, object occlusion, background interference, and the presence of similar objects, the YOLO algorithm may mistakenly identify some non-target objects as targets, or inaccurately identify target objects, resulting in reduced reliability of detection results.
[0004] Therefore, if there is a way to specifically reduce the false detection of the YOLO target detection algorithm, then the algorithm can be applied to more scenarios. Summary of the invention
[0005] The purpose of the present invention is to overcome the defects of the above-mentioned prior art and provide a method and medium for eliminating misidentification based on the YOLO target detection algorithm.
[0006] The purpose of the present invention can be achieved by the following technical solutions:
[0007] A method for eliminating misidentification based on the YOLO target detection algorithm includes the following steps:
[0008] S1: Obtain the image sample to be detected;
[0009] S2: Label the detection targets in the image samples to be detected, and divide the image samples to be detected into a training set, a validation set, and a test set;
[0010] S3: The images that do not contain the detection target in the image samples to be detected are taken as background samples, and after preprocessing, they are used as a negative sample set;
[0011] S4: Using the training set and validation set, based on the YOLO algorithm and combined with the improved Mosaic data enhancement method and transfer learning method, the negative sample set is added to the Mosaic data enhancement process to perform model training for target detection and obtain a trained network model;
[0012] S5: Use the trained network model to detect the test set images and save the misidentified images during the test;
[0013] S6: intercept the part of the misidentified image that does not contain the target to be detected and add it to the negative sample set;
[0014] S7: Repeat S4-S6 until the proportion of misidentified images during the test is lower than the threshold.
[0015] Furthermore, the improved Mosaic data enhancement method includes random direction transformation, size transformation, edge transformation, random cropping, and Mosaic splicing of the image to expand the number of samples.
[0016] Furthermore, the negative sample set is added to the process of Mosaic data enhancement. Specifically, in each Mosaic stitching process, a negative sample image is randomly replaced into the stitching process.
[0017] Furthermore, in step S5, the positive sample images to be detected are excluded from the misidentified images.
[0018] Furthermore, the images in the negative sample set are evenly distributed in the scene.
[0019] Furthermore, the transfer learning uses the pre-trained model and freezes the backbone of the pre-trained model. Each time step S4 is executed, training is performed based on the pre-trained model.
[0020] Furthermore, the to-be-detected image samples include all to-be-detected object patterns, and the number of samples of each to-be-detected object pattern is balanced.
[0021] Furthermore, in step S4, the sample frame parameters used by the network model during the training process include a labeling frame, a positive sample frame, a negative sample frame and a targeted negative sample frame. The labeling frame is a real sample labeling of the detection target in the image to be detected, the positive sample frame is a prediction frame of the network model for the detection target in the image to be detected, the negative sample frame is a prediction frame of the network model for the background in the image to be detected, and the targeted negative sample frame is a prediction frame of the network model for the image in the negative sample set.
[0022] Furthermore, in step S4, the network model uses a first loss function value and a second loss function value during the training process. The first loss function value is obtained by calculating the intersection and union ratio of the positive sample frame and the labeled frame; the second loss function value is obtained by calculating the classification accuracy of the positive sample frame, the negative sample frame and the targeted negative sample frame.
[0023] A second aspect of the present invention is a storage medium having a program stored thereon, which, when executed, implements any of the above methods for eliminating misidentification based on the YOLO target detection algorithm.
[0024] Compared with the prior art, the present invention has the following beneficial effects:
[0025] 1) The present invention utilizes Mosaic data enhancement technology to involve negative sample images in stitching, thereby increasing the degree of participation of negative samples in the training process. It adopts the method of transfer learning to flexibly and specifically eliminate misrecognition in various scenarios. By cropping and screening the misdetected images, a new set of negative samples is formed, and the training is continuously updated to achieve iterative optimization of training, gradually improve detection accuracy, and have better practicality.
[0026] 2) During model training, the present invention realizes the production and enhancement of data sets through data enhancement and transfer learning, completes model migration when the domain changes, and solves the problem of lack of data sets.
[0027] 3) The present invention can specifically eliminate the misidentification of the YOLO model in engineering applications and improve the stability of the system in engineering. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 It is a schematic diagram of the process of the present invention.
[0029] Figure 2 Schematic diagram of loss function calculation of the present invention.
[0030] Figure 3 It is a schematic diagram of Mosaic data enhancement of the present invention. DETAILED DESCRIPTION
[0031] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. This embodiment is implemented based on the technical solution of the present invention, and provides a detailed implementation method and specific operation process, but the protection scope of the present invention is not limited to the following embodiments.
[0032] Example 1
[0033] In this embodiment, surveillance camera images in a factory are used as a detection data set, and workers are used as targets to be detected to apply the present invention.
[0034] The present invention provides a method and medium for eliminating misidentification based on the YOLO target detection algorithm, and the method comprises the following steps:
[0035] S1: Obtain the image sample to be detected;
[0036] The system uses a camera above the factory to obtain real-time images of the production site, and transmits the obtained video to the backend through the server for storage. After that, the saved video should be framed to obtain images;
[0037] S2: Label the detection targets in the image samples to be detected, and divide the image samples to be detected into a training set, a validation set, and a test set;
[0038] Pictures of people to be tested are labeled as positive samples, and pictures of people without people to be tested are not labeled as negative samples. The uniform distribution of scene pictures should be ensured in the process of making the data set; the annotations are in the form of rectangular frames, and difficult-to-label samples that cannot be distinguished during annotation should be discarded, including difficult-to-label samples such as severe occlusion, missing, irregular distribution, etc.
[0039] S3: The images that do not contain the detection target in the image samples to be detected are taken as background samples, and after preprocessing, they are used as a negative sample set;
[0040] S4: Using the training set and validation set, based on the YOLO algorithm and combined with the improved Mosai c Data enhancement method and transfer learning method, and adding negative sample sets to Mosai c In the data enhancement process, the target detection model is trained to obtain a trained network model;
[0041] Data enhancement is achieved by randomly transforming the image in different directions, sizes, edges, random cropping, Mosai c Stitching is used to expand the number of samples. Among them, random direction transformation includes vertical and horizontal flipping and random angle rotation transformation; size transformation is size fine-tuning, edge transformation includes sharpening, blurring, and grayscale transformation; random cropping is cropping the random position of the image into a new sample image; Mosai c Stitching is to combine multiple images into one image in a specific way; transfer learning is to use the pre-trained model and freeze the backbone of the pre-trained model e Achieve the effect of fine-tuning the original model.
[0042] Put the prepared data set into the improved YOLO v 9 models are trained, such as Figure 3 As shown in the figure, after data enhancement, each picture is composed of four pictures, one of which is a negative sample image, and all of them have been pre-processed by processes such as rotation, scaling, and cropping;
[0043] like Figure 3As shown in the figure, the sample frame parameters used by the network model during the training process include the annotation frame, positive sample frame, negative sample frame and targeted negative sample frame. The annotation frame is the real sample annotation of the detection target in the image to be detected, the positive sample frame is the prediction frame of the network model for the detection target in the image to be detected, the negative sample frame is the prediction frame of the network model for the background in the image to be detected, and the targeted negative sample frame is the prediction frame of the network model for the image in the negative sample set.
[0044] like Figure 3 As shown, in step S4, the network model uses IoULoss as the first loss function during the training process. IoULoss calculates the intersection-over-union ratio between the positive sample prediction box and the true annotation box through the length, width and center point coordinates of the positive sample prediction box and the true annotation box to measure the accuracy of target detection and positioning. The closer the prediction box is to the true box, the smaller the IoU Loss. Since the prediction box position of the negative sample has no reference value, the calculation of IoU Loss only occurs between the positive sample box and the annotation box.
[0045] The second loss function used in the training process is Focal Loss. The second loss function value is obtained by calculating the classification accuracy through the positive sample frame, negative sample frame and targeted negative sample frame. The calculation expression is:
[0046] FL(p t )=-α t (1-p t ) γ log(p t )
[0047] In the formula, FL(p t ) is the second loss function value, p t is the model’s predicted probability for the true category, α t is a balancing factor, which is α for positive samples and 1-α for negative samples. The input of Focal Loss is the one-hot encoding representation of the category label and the category prediction result. For positive samples, if the category prediction result is closer to the corresponding category label, the smaller the Focal Loss value is; for negative samples, if the category prediction result is closer to the all-zero encoding, the smaller the Focal Loss value is.
[0048] S5: Use the trained network model to detect the test set images and save the misidentified images during the test;
[0049] The types and numbers of misidentification situations contained in the saved misidentification images should be balanced, and the misidentification images should not contain positive sample images to be detected.
[0050] S6: intercept the part of the misidentified image that does not contain the target to be detected and add it to the negative sample set;
[0051] Since the saved misidentified images may contain objects to be detected, in order to make them qualified negative sample images, it is necessary to crop and extract the styles that do not contain the objects to be detected as the final negative sample images. Moreover, due to the diversity of actual detection scenes, the final retained set of negative sample images should be evenly distributed in each scene.
[0052] S7: Repeat S4-S6 until the proportion of misidentified images during the test is lower than the threshold.
[0053] Preferably, when repeating training, a new round of training is performed on the basis of a pre-trained model rather than on the model completed in the previous round of training, so as to avoid the influence of misrecognition data generated in the previous round of training on the current round of training.
[0054] The medium for carrying the method of the present invention can be a machine-readable medium, and the machine-readable medium can be a tangible medium, which can contain or store a program for use by an instruction execution system, a device or an equipment or used in combination with an instruction execution system, a device or an equipment. The machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the above. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0055] The preferred specific embodiments of the present invention are described in detail above. It should be understood that a person skilled in the art can make many modifications and changes based on the concept of the present invention without creative work. Therefore, any technical solution that can be obtained by a person skilled in the art through logical analysis, reasoning or limited experiments based on the concept of the present invention on the basis of the prior art should be within the scope of protection determined by the claims.
Claims
1. A method for eliminating misidentification based on the YOLO target detection algorithm, characterized in that: The following steps are involved: S1: Obtain the image sample to be detected; S2: Label the detection targets in the image samples to be detected, and divide the image samples to be detected into a training set, a validation set, and a test set; S3: The images that do not contain the detection target in the image samples to be detected are taken as background samples, and after preprocessing, they are used as a negative sample set; S4: Using the training set and validation set, based on the YOLO algorithm and combined with the improved Mosaic data enhancement method and transfer learning method, the negative sample set is added to the Mosaic data enhancement process to perform model training for target detection and obtain a trained network model; S5: Use the trained network model to detect the test set images and save the misidentified images during the test; S6: intercept the part of the misidentified image that does not contain the target to be detected and add it to the negative sample set; S7: Repeat S4-S6 until the proportion of misidentified images during the test is lower than the threshold.
2. A method for eliminating misidentification based on the YOLO target detection algorithm according to claim 1, characterized in that: The improved Mosaic data enhancement method includes performing random direction transformation, size transformation, edge transformation, random cropping, and Mosaic splicing on the image to expand the number of samples.
3. A method for eliminating misidentification based on the YOLO target detection algorithm according to claim 1, characterized in that: The negative sample set is added to the process of Mosaic data enhancement, specifically: in each Mosaic splicing process, a negative sample image is randomly replaced into the splicing process.
4. A method for eliminating misidentification based on the YOLO target detection algorithm according to claim 1, characterized in that: In step S5, the positive sample images to be detected are excluded from the misidentified images.
5. A method for eliminating misidentification based on the YOLO target detection algorithm according to claim 1, characterized in that: The images in the negative sample set are evenly distributed in the scene.
6. A method for eliminating misidentification based on the YOLO target detection algorithm according to claim 1, characterized in that: The transfer learning uses a pre-trained model and freezes the backbone of the pre-trained model. Each time step S4 is executed, training is performed based on the pre-trained model.
7. A method for eliminating misidentification based on the YOLO target detection algorithm according to claim 1, characterized in that: The to-be-detected image samples include all to-be-detected object patterns, and the number of samples of each to-be-detected object pattern is balanced.
8. A method for eliminating misidentification based on the YOLO target detection algorithm according to claim 1, characterized in that: In step S4, the sample frame parameters used by the network model during the training process include a labeling frame, a positive sample frame, a negative sample frame and a targeted negative sample frame, wherein the labeling frame is a real sample labeling of the detection target in the image to be detected, the positive sample frame is a prediction frame of the network model for the detection target in the image to be detected, the negative sample frame is a prediction frame of the network model for the background in the image to be detected, and the targeted negative sample frame is a prediction frame of the network model for the image in the negative sample set.
9. A method for eliminating misidentification based on the YOLO target detection algorithm according to claim 8, characterized in that: In step S4, the network model uses a first loss function value and a second loss function value during training. The first loss function value is obtained by calculating the intersection-over-union ratio through the positive sample frame and the labeled frame; the second loss function value is obtained by calculating the classification accuracy through the positive sample frame, the negative sample frame and the targeted negative sample frame.
10. A storage medium having a program stored thereon, characterized in that: When the program is executed, a misidentification elimination method based on the YOLO target detection algorithm as described in any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Object detection method and system based on dynamic sample selection and loss consistency
CN111914944A
Dense pedestrian target detection method and system based on YOLOv5 model
CN115797970A
Exposed garbage detection and stacking monitoring method based on improved yov8
CN116189099A
Bamboo cane surface defect detection method based on improved YOLOX
CN117078614A
Object detection model generation method and electronic device and computer readable storage medium using the same
US20220044438A1
