CN-122023247-A - YOLOv 11-based bearing surface defect detection
Abstract
The invention relates to the technical field of industrial image processing, in particular to a method for detecting surface defects of a bearing based on YOLOv < 11 >, which comprises the following steps of firstly obtaining an image dataset of an automobile bearing, preprocessing the obtained image dataset of the automobile bearing, secondly dividing the data into a training set, a verification set and a test set, carrying out data enhancement operation and creating a data configuration file by three-way horizontal overturning, vertical overturning and random cutting, training the training set through an optimized YOLOv < 11 > to obtain an optimal target detection model, and fifthly verifying and evaluating the model and predicting the image. The invention aims to realize rapid and automatic detection of the surface defects of the bearing surface, improve the detection precision and efficiency, reduce the labor cost and ensure the quality and the safety of an automobile engine.
Inventors
- LU YANXI
- LI CHENXUE
- XIONG YUXUAN
- ZHOU LINGYI
- WANG HAN
- TANG YUFAN
- FAN JUNYI
- Liu Baoci
Assignees
- 上海理工大学
Dates
- Publication Date
- 20260512
- Application Date
- 20251224
Claims (6)
- 1. A YOLOv-based bearing surface defect detection, comprising the steps of: firstly, acquiring an image dataset of an automobile bearing, and preprocessing the acquired image dataset of the automobile bearing; Dividing the data set into a training set, a verification set and a test set; step three, performing data enhancement operation and creating a data configuration file through horizontal overturning, vertical overturning and random cutting; Training a training set through an optimized YOLOv to obtain an optimal target detection model; Step five, verifying and evaluating the model; and step six, predicting the image.
- 2. The method for detecting the bearing surface defects based on YOLOv as defined in claim 1, wherein in the first step, the preprocessing of the acquired bearing image dataset of the automobile is performed, specifically, gaussian filtering denoising and a limited contrast adaptive histogram equalization algorithm are adopted to improve the image quality; The Gaussian filtering implementation process comprises the steps of obtaining a specific filtering kernel matrix through calculating two-dimensional Gaussian function discretization according to the size of a set filtering kernel and the value of standard deviation sigma, normalizing elements in the matrix to ensure that the sum of all the elements is 1 to obtain a filtering kernel, performing convolution operation, namely sliding the filtering kernel on an image, moving row by row from the upper left corner of the image until the whole image is covered, and carrying out weighted summation on the filtering kernel and pixel values of corresponding image areas at each position to finally obtain the processed image.
- 3. The YOLOv-based bearing surface defect detection method according to claim 1, wherein in the third step, the data_data_ yaml function is adopted to conveniently generate the data.yaml configuration file in the process of creating the data configuration file, so that the whole data preparation flow can be quickly adapted to the automobile bearing surface defect detection image data sets with different sources and scales, the subsequent training by using a YOLOv11 model is facilitated, and the complicated process of manually sorting the data and the configuration file is reduced.
- 4. The YOLOv-based bearing surface defect detection according to claim 1, wherein in step five, a sklearn. Metrics library is imported and the model is evaluated with macro average calculation accuracy, recall and F1 value; The macro average calculation formula is as follows: ; Wherein, the The number of categories is indicated and, A representation of each of the categories is made, The calculated evaluation index of each category is represented, and the calculated evaluation index comprises precision, recall rate and F1 value.
- 5. A YOLOv11 based bearing surface defect detection according to claim 1 wherein in step four YOLOv11 is optimised, in particular by modifying the loss function part of YOLOv11 to which the function EMASlideLoss is added; The function EMASlideLoss is an improved loss function based on SlideLoss and introducing exponential moving average, solves the problem of sample unbalance in target detection, and improves the attention of the model to difficult samples, thereby improving the performance and the robustness of the model; the loss function uses a Mean Square Error (MSE) based mask loss equation: ; where H and W represent the height and width of the mask (mask), respectively, i.e., the pixel dimensions of the mask image; is the pixel value of the prediction mask at position (i, j), Is the pixel value of the true mask at the same position, and the formula is mainly used for measuring the difference degree of the prediction mask and the true mask as a whole.
- 6. The YOLOv-based bearing surface defect detection as recited in claim 1 wherein in step 2, image prediction is performed by constructing a predicted image function incorporating multi-scale feature extraction, the implementation logic within the predicted image function being: Firstly defining different colors to form a color list, reading an image by using a cv2.imread function, converting an image color space from BGR to RGB by adopting the cv2.cvtColor function, and simultaneously acquiring the height and width of the image by a shape function; Then inputting the read image into a model to predict to obtain results, extracting normalized boundary frame coordinates (xywhn), confidence level (conf) and predicted category (cls) from the results, and defining a multi-scale list; Converting the normalized boundary frame coordinates into absolute coordinates under corresponding scales, multiplying the absolute coordinates by the width and the height of the image, converting the coordinates back to the original image coordinate size, and finally merging detection results under multiple scales by using np. Then traversing each prediction result, extracting the coordinate information of the boundary frame and converting the coordinate information into coordinate forms (x 1, y 1) and (x 2, y 2) of the upper left corner and the lower right corner for the prediction with the confidence degree larger than conf_threshold, selecting colors according to category indexes, and simply taking the remainder to ensure that the indexes are in a color list range; Finally, displaying the image with the prediction result drawn by using a cv2.imshowy function, waiting for a user key operation by using the cv2.waitkey function, closing an image display window by using the cv2.destroyAllWindows function, and storing the image under a designated save path by using the cv2.imwrite function after converting an image color space from BGR to RGB by using the cv2.cvtColor function; the predictive image function realizes drawing detection frames with different colors for different types of surface defects and can store predictive result images, which is convenient for manually and intuitively distinguishing different types of surface defects, is convenient for checking, analyzing and archiving detection results, is beneficial to actual quality detection and other business processes, and improves the overall use experience and working efficiency.
Description
YOLOv 11-based bearing surface defect detection Technical Field The invention relates to the technical field of industrial image processing, in particular to a YOLOv 11-based bearing surface defect detection method. Background In the automotive industry, the quality of the engine as a core component is directly related to the performance, reliability and safety of the whole vehicle. Traditional detection of automotive bearing surface defects relies mainly on manual visual detection and some simple measuring tools. The manual detection is not only low in efficiency, but also is easily influenced by subjective factors of detection personnel, such as fatigue, experience difference and the like, so that the detection omission rate and the false detection rate are high. With the development of industrial automation and intellectualization, detection technology based on machine vision is gradually rising. However, some existing surface defect detection algorithms have the problems of insufficient detection precision, low sensitivity to small surface defects, long model training time and the like when facing complex shapes and textures of automobile bearings and diversified surface defect types. For example, some conventional feature extraction-based algorithms have difficulty automatically learning feature-rich feature representations, and are poorly adapted when processing part images under different illumination, angles. Disclosure of Invention Aiming at the scene of detecting the surface defects of the bearing image of the automobile, the invention provides YOLOv-based detection of the surface defects of the bearing, which comprises the following steps: firstly, acquiring an image dataset of an automobile bearing, and preprocessing the acquired image dataset of the automobile bearing; Dividing the data set into a training set, a verification set and a test set; step three, performing data enhancement operation and creating a data configuration file through horizontal overturning, vertical overturning and random cutting; Training a training set through an optimized YOLOv to obtain an optimal target detection model; Step five, verifying and evaluating the model; and step six, predicting the image. In the first step, the preprocessing process is carried out on the obtained automobile bearing image dataset, specifically, gaussian filter denoising and a contrast-limiting self-adaptive histogram equalization algorithm are adopted to improve the image quality; The Gaussian filtering is realized by calculating a two-dimensional Gaussian function discretization to obtain a specific filtering kernel matrix according to the set size of the filtering kernel and the value of a standard deviation sigma, normalizing the elements in the matrix to ensure that the sum of all the elements is 1 to obtain the filtering kernel, performing convolution operation, namely sliding the filtering kernel on an image, moving row by row from the upper left corner of the image until the whole image is covered, weighting and summing the filtering kernel and the pixel value of a corresponding image area at each position, and finally obtaining the processed image. Furthermore, in the third step, the data_data_ yaml function is adopted in creating the data configuration file to conveniently generate the data.yaml configuration file, so that the whole data preparation flow can be quickly adapted to the automobile bearing surface defect detection image data sets with different sources and scales, the subsequent training by using the YOLOv model is facilitated, and the complicated process of manually arranging the data and the configuration file is reduced. Further, in the fifth step, a sklearn. Metrics library is imported and the model is evaluated by using the macro average calculation accuracy, recall and F1 value; the calculation formula of the macro average is as follows: ; Wherein, the The number of categories is indicated and,A representation of each of the categories is made,The calculated evaluation index of each category is represented, and the calculated evaluation index comprises precision, recall rate and F1 value. Further, in step four, YOLOv is optimized, specifically, the loss function portion in YOLOv is improved, and a function EMASlideLoss is added; The function EMASlideLoss is an improved loss function based on SlideLoss and introducing exponential moving average, solves the problem of sample imbalance in target detection, and improves the attention of the model to difficult samples, thereby improving the performance and the robustness of the model; the loss function uses a Mean Square Error (MSE) based mask loss equation: ; where H and W represent the height and width of the mask (mask), respectively, i.e., the pixel dimensions of the mask image; is the pixel value of the prediction mask at position (i, j), Is the pixel value of the true mask at the same position, and the formula is mainly used for measuring the difference deg