Surface defect detection method, device, storage medium and electronic terminal
Through the combination of yolov8 model and non-maximum suppression algorithm, the automation of surface defect detection of energy storage product boxes is realized, which solves the problems of low detection efficiency and strong subjectivity in the existing technology, and improves the accuracy and efficiency of detection. .
Patent Information
- Application Number
- CN202410790646.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-19
- Publication Date
- 2024-10-08
- Estimated Expiration
- 2044-06-19
AI Technical Summary
The existing technology has problems such as high subjectivity, low efficiency, and difficulty in detecting minor defects in the surface defect detection of user energy storage product boxes, which affects the safety and reliability of the energy storage system.
The yolov8 model is used to process the initial image of the energy storage product box surface, and the defect detection frame is screened out through grayscale, sharpening and non-maximum suppression algorithms to achieve automated detection.
It realizes the automation of surface defect detection of energy storage product boxes, improves the accuracy and efficiency of detection, reduces the consumption of human resources, and improves the reliability of the production process.
Smart Images

Figure CN118365643B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of target detection technology, and in particular to a surface defect detection method, device, storage medium and electronic terminal. Background Art
[0002] With the widespread application of renewable energy and the growing demand for power storage, the quality and performance of user energy storage product boxes, as a key component of power storage, have an increasingly prominent impact on the entire energy storage system. During the manufacturing and use of user energy storage product boxes, due to the influence of various factors, various defects may appear on the surface of the box, such as physical damage such as bumps, scratches, unevenness, and chemical corrosion problems such as coating omissions, mechanical damage, mottled, rust, etc. These defects will not only affect the appearance quality of the energy storage product box, but more importantly, they may reduce the sealing performance, corrosion resistance and overall strength of the box, thereby affecting the safety and reliability of the energy storage system.
[0003] Traditional inspection methods usually rely on manual visual inspection. Although this method is simple and easy to use, it has problems such as strong subjectivity, low efficiency, and difficulty in detecting tiny defects.
[0004] Therefore, how to solve the deficiencies and shortcomings of existing technologies through effective defect detection methods has become an important issue that researchers in this field need to solve urgently. Summary of the invention
[0005] The purpose of the present invention is to provide a surface defect detection method, device, storage medium and electronic terminal in order to solve the above problems.
[0006] The technical solution of the present invention is: a defect detection method for the surface of an energy storage product box, comprising the following steps: obtaining an initial image of the surface of the energy storage product box that meets preset requirements, and cutting the initial image into a plurality of image blocks. Create a yolov8 model, use the yolov8 model to process each image block, and obtain a plurality of feature maps and a plurality of defect candidate frames corresponding to each image block, as well as information of each defect candidate frame. Perform the following processing on each image block: use a non-maximum suppression algorithm to screen the plurality of defect candidate frames, thereby obtaining a plurality of defect detection frames, and mark each defect detection frame in the initial image.
[0007] As an improvement of an embodiment of the present invention, the “obtaining an initial image of the surface of the energy storage product case that meets preset requirements” specifically includes: obtaining an initial image of the surface of the energy storage product case, graying the initial image, sharpening the grayed initial image using a Laplace algorithm, and calculating an average value and a standard deviation of the sharpened initial image; when the standard deviation is ≥ a first preset threshold, the initial image meets the preset requirements; when the standard deviation is < the first preset threshold, extracting edge information in the horizontal and vertical directions of the sharpened initial image using a Sobel operator, and fusing the information to obtain a fused image, denoising the fused image, and sharpening the denoised fused image using a Laplace algorithm; if the standard deviation of the sharpened fused image is ≥ the first preset threshold, the sharpened fused image is an initial image that meets the preset requirements.
[0008] As an improvement of the embodiment of the present invention, the “cutting the initial image into a plurality of image blocks” specifically includes: cutting the initial image into a plurality of image blocks with a width of , Gao Wei The image block is cut by ;
[0009] The first operation is to calculate the scaling factor for each image block: , scaling the width of the image block to , height scaled to , where the width of the input image of the yolov8 model is , Gao Wei ;like or , then the image block is filled with a constant pad, and the filling size of the image block in width is , the padding size of the image block in height is , where 0 <pad<255。
[0010] As an improvement of an embodiment of the present invention, the "using the yolov8 model to process each image block, and obtain several feature maps and several defect candidate boxes corresponding to each image block, and information of each defect candidate box" specifically includes: performing the following second operation on each image block: inputting the image block into the yolov8 model, controlling the CBS module, C2F module and SPPF module of the main structure in the yolov8 model to extract several feature maps of the image block; then, controlling the Neck network structure in the yolov8 model to perform deep extraction on the several feature maps to obtain several feature maps; and then inputting the several feature maps into the Detect network structure in the yolov8 model, so as to obtain several defect candidate boxes corresponding to the image block, and information of each defect candidate box.
[0011] As an improvement of an embodiment of the present invention, the “using a non-maximum suppression algorithm to screen the plurality of defect candidate frames, thereby obtaining a plurality of defect detection frames” specifically includes: the information of the defect candidate frame includes: the coordinates of the center point of the defect candidate frame ,Width ,high and a number of defects and the confidence level corresponding to each defect;
[0012] The following third operation is performed on each defect candidate frame: the maximum confidence Con is selected from the several confidences of the defect candidate frame as the confidence of the defect candidate frame, and the defect corresponding to the confidence Con is used as the label tag of the defect candidate frame; the coordinates of the center point of the defect candidate frame are used to determine the confidence Con of the defect candidate frame. ,Width ,high Calculate the coordinates of the upper left corner of the defect candidate box , the coordinates of the lower right corner ,in, , ; The third operation is completed;
[0013] For any two defect candidate frames frame1 and frame2 with the same label tag, the non-maximum suppression algorithm is used to calculate the value value1 of the intersection and union ratio of the defect candidate frames frame1 and frame2, and the value value1 is compared with the second preset threshold. If the value value1> the second preset threshold, the defect candidate frame with a larger confidence level between the defect candidate frames frame1 and frame2 is taken as a defect detection frame.
[0014] As an improvement of the embodiment of the present invention, the “marking each defect detection frame in the initial image” specifically includes: performing the following fourth operation on each defect detection frame: calculating the coordinates of the upper left corner of the defect detection frame ,Width ,high ,in, , , , , the fourth operation is completed; for any two defect detection frames frame3 and frame4 with the same tag tag, the intersection and union ratio value value2 of the defect detection frames frame3 and frame4 is calculated, and the value value2 is compared with the second preset threshold. If the value value2> the second preset threshold, the defect detection frames frame3 and frame4 are merged to obtain the merged defect detection frame frame5. The upper left corner coordinate of the defect detection frame frame5 is ,in, ; ; Select the larger confidence of the defect candidate frames frame3 and frame4 as the confidence of the defect detection frame frame5; mark the defect detection frame frame5 in the initial image.
[0015] As an improvement of the embodiment of the present invention, it specifically includes: .
[0016] To achieve one of the above-mentioned purposes of the invention, an embodiment of the present invention provides a defect detection device for the surface of a user energy storage product box, comprising the following modules: an information acquisition module, used to acquire an initial image of the surface of the energy storage product box that meets preset requirements, and cut the initial image into a plurality of image blocks;
[0017] A defect detection module is used to create a yolov8 model, use the yolov8 model to process each image block, and obtain a number of feature maps and a number of defect candidate boxes corresponding to each image block, as well as information of each defect candidate box;
[0018] The processing module is used to perform the following processing on each image block: use a non-maximum suppression algorithm to screen the defect candidate frames to obtain a number of defect detection frames, and mark each defect detection frame in the initial image.
[0019] To achieve one of the above objects of the invention, an embodiment of the present invention provides a storage medium storing program instructions, wherein the program instructions, when executed, implement the defect detection method as described in any one of the above items.
[0020] To achieve one of the above-mentioned purposes of the invention, an embodiment of the present invention provides an electronic terminal, including a processor and a memory, wherein the memory stores program instructions, and the processor executes the program instructions to implement the defect detection method as described in any one of the above items.
[0021] The surface defect detection method, device, storage medium and electronic terminal provided by the embodiments of the present invention have the following advantages: the present invention can automatically complete the entire process of surface defect detection of the energy storage product box without manual intervention, thereby greatly reducing the consumption of human resources. At the same time, automated detection not only improves the accuracy and consistency of detection, but also significantly improves the detection efficiency, making the production process more efficient and reliable. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 It is a flow chart of the defect detection method on the surface of the box of the user energy storage product according to the present invention;
[0023] Figure 2 It is a schematic diagram of the main structure of the yolov8 model described in the present invention;
[0024] Figure 3 It is a schematic diagram of the Neck network structure of the yolov8 model of the present invention;
[0025] Figure 4 It is a schematic diagram of the Detect network structure of the yolov8 model described in the present invention. DETAILED DESCRIPTION
[0026] The present invention will be described in detail below in conjunction with the specific embodiments shown in the accompanying drawings. However, these embodiments do not limit the present invention, and any structural, methodological, or functional changes made by a person skilled in the art based on these embodiments are all within the scope of protection of the present invention.
[0027] If the present invention involves directions (for example, up, down, left, right, front, back, outside, inside, etc.) when describing, the directions involved need to be defined.
[0028] The scope of the embodiments herein includes the entire scope of the claims, and all available equivalents of the claims.Herein, the terms "first", "second", etc. are only used to distinguish one element from another, without requiring or implying any actual relationship or order between these elements.In fact, the first element can also be called the second element, and vice versa.Moreover, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that the structure, device or equipment including a series of elements not only include those elements, but also include other elements not clearly listed, or also include elements inherent to such structure, device or equipment.In the absence of more restrictions, the elements limited by the statement "include one..." do not exclude the existence of other identical elements in the structure, device or equipment including the elements.Each embodiment herein is described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same similar parts between each embodiment can be referred to each other.
[0029] The terms "longitudinal", "lateral", "upper", "lower", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc. in this document indicate the orientation or position relationship based on the orientation or position relationship shown in the drawings, and are only for the convenience of describing this document and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operate in a specific orientation, and therefore cannot be understood as a limitation on the present invention. In the description of this document, unless otherwise specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a mechanical connection or an electrical connection, it can also be the internal communication of two elements, it can be a direct connection, or it can be indirectly connected through an intermediate medium. For ordinary technicians in this field, the specific meanings of the above terms can be understood according to specific circumstances.
[0030] Embodiment 1 of the present invention provides a method for detecting defects on the surface of a box of an energy storage product, such as Figure 1 As shown, the following steps are included:
[0031] Step 101: obtaining an initial image of the surface of the energy storage product box that meets preset requirements, and cutting the initial image into a plurality of image blocks;
[0032] In practice, first place the energy storage product box within the camera acquisition range to ensure that the camera can clearly and completely capture the surface image of the box, and then shoot the surface of the energy storage product box with the camera to obtain its initial image. Optionally, the HiSilicon industrial camera and the Hikvision light source controller can be combined to achieve the acquisition of the initial image. The HiSilicon industrial camera has a pixel of 25 million, and the image size captured is 5120*5120. The Hikvision light source controller can fill in the light of the object according to different light conditions. It can be understood that the combination of the two can make the initial image clearer.
[0033] In order to adapt to the input conditions of the defect detection method for the surface of the energy storage product box, when the initial image of RGB arrangement is received from the camera interface, it needs to be converted into BGR arrangement. In order to facilitate the detection of brightness and fuzzy values, the image data of BGR arrangement needs to be converted into a grayscale image. Optionally, the image color space conversion function in the opencv image library can be used: cv::cvtColor() to convert the initial image of RGB arrangement into BGR arrangement image data, and convert the BGR arrangement image data into a grayscale image.
[0034] Step 102: Create a yolov8 model, use the yolov8 model to process each image block, and obtain a number of feature maps and a number of defect candidate boxes corresponding to each image block, as well as information of each defect candidate box;
[0035] Here, yolov8 is a target detection algorithm that can quickly and accurately locate and classify targets in an image. Before using the yolov8 model for defect detection, it is necessary to determine the width and height of the model input image, which usually depends on the pre-training parameters of the model and the specific application scenario. Preferably, the width and height of the yolov8 model input image in the defect detection method for the surface of the energy storage product box of the present invention are and the height of the input image of the yolov8 model Both are 1280.
[0036] like Figure 2The figure shows a schematic diagram of the main structure of the yolov8 model. The multi-scale features of the image are extracted through the CBS (ConvBatchNorm SiLU) module, C2F (Channel-to-Pixel Fusion) module and SPPF (Spatial PyramidPooling - Fast) module in its main structure. Optionally, a first feature map of 160*160*256 and a second feature map of 80*80*512 are extracted from the image block. Then, the first feature map and the second feature map are multi-scale downsampled using the SPPF module to further generate a third feature map of 40*40*1024 to capture finer-grained features. The first feature map, the second feature map and the third feature map are sent to the Neck network structure to obtain the corresponding feature maps. Finally, these feature maps are sent to the Detect network structure and output to obtain several defect candidate boxes corresponding to the image block, as well as the information of each defect candidate box.
[0037] Step 103: Perform the following processing on each image block: Use a non-maximum suppression algorithm to screen the plurality of defect candidate frames, thereby obtaining a plurality of defect detection frames, and mark each defect detection frame in the initial image.
[0038] Here, the non-maximum suppression algorithm is a commonly used target detection algorithm, which is used in computer vision to filter out the final detection frame from multiple target detection frames output, thereby improving the detection effect. Its basic principle is that for each detection frame, it is compared with other detection frames. If the overlap rate of two detection frames exceeds the specified threshold, the detection frame with lower confidence is suppressed, and finally only the detection frame with the highest confidence is retained.
[0039] In this embodiment, the “obtaining an initial image of the surface of the energy storage product case that meets the preset requirements” specifically includes: obtaining an initial image of the surface of the energy storage product case, graying the initial image, sharpening the grayed initial image using the Laplace algorithm, and calculating the average value and standard deviation of the sharpened initial image; when the standard deviation is ≥ a first preset threshold, the initial image meets the preset requirements; when the standard deviation is < the first preset threshold, extracting edge information in the horizontal and vertical directions of the sharpened initial image using the Sobel operator, and fusing them to obtain a fused image, denoising the fused image, and sharpening the denoised fused image using the Laplace algorithm; if the standard deviation of the sharpened fused image is ≥ the first preset threshold, the sharpened fused image is an initial image that meets the preset requirements.
[0040] Here, after graying the initial image, it is also necessary to detect whether the initial image meets the brightness requirement. First, the pixel value corresponding to each pixel point in the initial image after graying is counted and recorded as a set: ,in ,and is an integer; is the number of pixels in the initial image. Subtract a fixed value Get Collection , ,in , , then calculate The average value of all elements in ;
[0041] Defining a Collection ,in , Then calculate the average value of all elements in set Q ; Then calculate the brightness statistics R of the initial image after grayscale processing, where .like If the grayscale image is smaller than the preset mean threshold and the brightness statistic R of the grayscale image is smaller than the preset brightness threshold, the grayscale initial image is sharpened using the Laplace algorithm. Optionally, the mean preset threshold can range from -20 to 20, and the brightness preset threshold can range from -15 to 15.
[0042] Here, the Laplace algorithm is a differential algorithm. Its application can enhance the grayscale mutation area in the image, weaken the grayscale slow change area, enhance the edge and detail information in the image, and make the blurred area more obvious. The Sobel operator is a commonly used edge detection algorithm. In actual operation, the Sobel operator corresponds each pixel in the image to the three directions of -1, 0, and +1, and sums the grayscale values in these three directions and takes the absolute value. Finally, the relationship between this absolute value and the preset threshold is compared to obtain the edge information and fuse these edge information to remove noise.
[0043] In this embodiment, the “cutting the initial image into a plurality of image blocks” specifically includes: cutting the initial image into a plurality of image blocks with a width of , Gao Wei The image block is cut by ;
[0044] The first operation is to calculate the scaling factor for each image block: , scaling the width of the image block to , height scaled to , where the width of the input image of the yolov8 model is , Gao Wei ;like or , then the image block is filled with a constant pad, and the filling size of the image block in width is , the padding size of the image block in height is , where 0 <pad<255。
[0045] In this embodiment, the "using the yolov8 model to process each image block, and obtain a number of feature maps and a number of defect candidate boxes corresponding to each image block, and information of each defect candidate box" specifically includes: performing the following second operation on each image block: inputting the image block into the yolov8 model, controlling the CBS module, C2F module and SPPF module of the main structure in the yolov8 model to extract a number of feature maps of the image block; then, controlling the Neck network structure in the yolov8 model to perform deep extraction on the several feature maps to obtain a number of feature maps; and then inputting the several feature maps into the Detect network structure in the yolov8 model, so as to obtain a number of defect candidate boxes corresponding to the image block, and information of each defect candidate box.
[0046] In this embodiment, the “using a non-maximum suppression algorithm to screen the plurality of defect candidate frames, thereby obtaining a plurality of defect detection frames” specifically includes: the information of the defect candidate frames includes: the coordinates of the center point of the defect candidate frames ,Width ,high and a number of defects and the confidence level corresponding to each defect;
[0047] The following third operation is performed on each defect candidate frame: the maximum confidence Con is selected from the several confidences of the defect candidate frame as the confidence of the defect candidate frame, and the defect corresponding to the confidence Con is used as the label tag of the defect candidate frame; the coordinates of the center point of the defect candidate frame are used to determine the confidence Con of the defect candidate frame. ,Width ,high Calculate the coordinates of the upper left corner of the defect candidate box , the coordinates of the lower right corner ,in, , ; The third operation is completed; In practice, the tag of the defect candidate box can be a point, a line, or a surface.
[0048] For any two defect candidate frames frame1 and frame2 with the same label tag, the non-maximum suppression algorithm is used to calculate the value value1 of the intersection and union ratio of the defect candidate frames frame1 and frame2, and the value value1 is compared with the second preset threshold. If the value value1> the second preset threshold, the defect candidate frame with a larger confidence level between the defect candidate frames frame1 and frame2 is taken as a defect detection frame.
[0049] In this embodiment, the “marking each defect detection frame in the initial image” specifically includes: performing the following fourth operation on each defect detection frame: calculating the coordinates of the upper left corner of the defect detection frame ,Width ,high ,in, , , , , the fourth operation is completed; for any two defect detection frames frame3 and frame4 with the same tag tag, the intersection and union ratio value value2 of the defect detection frames frame3 and frame4 is calculated, and the value value2 is compared with the second preset threshold. If the value value2> the second preset threshold, the defect detection frames frame3 and frame4 are merged to obtain the merged defect detection frame frame5. The upper left corner coordinate of the defect detection frame frame5 is ,in, ; ; Select the larger confidence of the defect candidate frames frame3 and frame4 as the confidence of the defect detection frame frame5; mark the defect detection frame frame5 in the initial image.
[0050] In this embodiment, it specifically includes: .
[0051] Embodiment 2 of the present invention provides a defect detection device for the surface of a user energy storage product box, comprising the following modules: an information acquisition module, used to acquire an initial image of the surface of the energy storage product box that meets preset requirements, and cut the initial image into a plurality of image blocks;
[0052] A defect detection module is used to create a yolov8 model, use the yolov8 model to process each image block, and obtain a number of feature maps and a number of defect candidate boxes corresponding to each image block, as well as information of each defect candidate box;
[0053] The processing module is used to perform the following processing on each image block: use a non-maximum suppression algorithm to screen the defect candidate frames to obtain a number of defect detection frames, and mark each defect detection frame in the initial image.
[0054] A third embodiment of the present invention provides a storage medium storing program instructions, wherein the program instructions, when executed, implement the defect detection method as described in any one of the above items.
[0055] A fourth embodiment of the present invention provides an electronic terminal, including a processor and a memory, wherein the memory stores program instructions, and the processor executes the program instructions to implement any of the above defect detection methods.
[0056] It should be understood that although this specification is described according to implementation modes, not every implementation mode contains only one independent technical solution. This description of the specification is only for the sake of clarity. Those skilled in the art should regard the specification as a whole. The technical solutions in each implementation mode may also be appropriately combined to form other implementation modes that can be understood by those skilled in the art.
[0057] The series of detailed descriptions listed above are only specific descriptions of feasible implementation methods of the present invention. They are not intended to limit the scope of protection of the present invention. Any equivalent implementation methods or changes that do not deviate from the technical spirit of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for detecting defects on the surface of an energy storage product box, characterized in that: The following steps are involved: Obtain an initial image of the surface of the energy storage product box that meets the preset requirements, and cut the initial image into pieces with a width of , Gao Wei The image block is cut by ; The following first operation is performed on each image block: Calculate the scaling ratio , scaling the width of the image block to , height scaled to , where the width of the input image of the yolov8 model is , Gao Wei ;like or , then the image block is filled with a constant pad, and the filling size of the image block in width is , the padding size of the image block in height is , where 0 <pad<255, ; Create a yolov8 model, and perform the following second operation on each image block: input the image block into the yolov8 model, control the CBS module, C2F module and SPPF module of the main structure of the yolov8 model to extract several feature maps of the image block; then control the Neck network structure in the yolov8 model to perform deep extraction on the several feature maps to obtain several feature maps; then input the several feature maps into the Detect network structure in the yolov8 model, so as to obtain several defect candidate boxes corresponding to the image block, and the information of each defect candidate box; The following processing is performed on each image block: the information of the defect candidate frame includes: the coordinates of the center point of the defect candidate frame ,Width ,high and several defects and the confidence corresponding to each defect; the following third operation is performed on each defect candidate frame: the maximum confidence Con is selected from the several confidences of the defect candidate frame as the confidence of the defect candidate frame, and the defect corresponding to the confidence Con is used as the label tag of the defect candidate frame; the coordinates of the center point of the defect candidate frame are used to identify the defect candidate frame. ,Width ,high Calculate the coordinates of the upper left corner of the defect candidate box , the coordinates of the lower right corner ,in, , ; The third operation is completed; for any two defect candidate frames frame1 and frame2 with the same label tag, the non-maximum suppression algorithm is used to calculate the value value1 of the intersection and union ratio of the defect candidate frames frame1 and frame2, and the value value1 is compared with the second preset threshold. If the value value1> the second preset threshold, the defect candidate frame with a larger confidence level among the defect candidate frames frame1 and frame2 is taken as a defect detection frame, and each defect detection frame is marked in the initial image.
2. The defect detection method according to claim 1, characterized in that: The “obtaining an initial image of the surface of the energy storage product case that meets preset requirements” specifically includes: obtaining an initial image of the surface of the energy storage product case, graying the initial image, sharpening the grayed initial image using the Laplace algorithm, and calculating the average value and standard deviation of the sharpened initial image; When the standard deviation is ≥ the first preset threshold, the initial image meets the preset requirements; When the standard deviation is less than the first preset threshold, the Sobel operator is used to extract the edge information in the horizontal and vertical directions of the sharpened initial image, and the edges are fused to obtain a fused image. The fused image is denoised, and the denoised fused image is sharpened using the Laplace algorithm. If the standard deviation of the sharpened fused image is ≥ the first preset threshold, the sharpened fused image is an initial image that meets the preset requirements.
3. The defect detection method according to claim 1, characterized in that: The “marking each defect detection frame into the initial image” specifically includes: The following fourth operation is performed for each defect detection frame: the coordinates of the upper left corner of the defect detection frame are calculated. ,Width ,high ,in, , , , , the fourth operation is completed; For any two defect detection frames frame3 and frame4 with the same tag tag, the intersection and union ratio value value2 of the defect detection frames frame3 and frame4 is calculated, and the value value2 is compared with the second preset threshold. If the value value2> the second preset threshold, the defect detection frames frame3 and frame4 are merged to obtain the merged defect detection frame frame5. The coordinates of the upper left corner of the defect detection frame frame5 are ,in, ; ; Select the larger confidence of the defect candidate frames frame3 and frame4 as the confidence of the defect detection frame frame5; mark the defect detection frame frame5 in the initial image.
4. A defect detection device for the surface of a user energy storage product box, characterized in that: Includes the following modules: The information acquisition module is used to obtain an initial image of the surface of the energy storage product box that meets the preset requirements, and cut the initial image into pieces with a width of , Gao Wei The image block is cut by ; The following first operation is performed on each image block: Calculate the scaling ratio , scaling the width of the image block to , height scaled to , where the width of the input image of the yolov8 model is , Gao Wei ;like or , then the image block is filled with a constant pad, and the filling size of the image block in width is , the padding size of the image block in height is , where 0 <pad<255, ; The defect detection module is used to create a yolov8 model, and performs the following second operation on each image block: input the image block into the yolov8 model, and control the CBS module, C2F module and SPPF module of the main structure in the yolov8 model to extract several feature maps of the image block; then, control the Neck network structure in the yolov8 model to perform deep extraction on the several feature maps to obtain several feature maps; then, input the several feature maps into the Detect network structure in the yolov8 model, so as to obtain several defect candidate boxes corresponding to the image block, and the information of each defect candidate box; The processing module is used to perform the following processing on each image block: the information of the defect candidate frame includes: the coordinates of the center point of the defect candidate frame ,Width ,high and several defects and the confidence corresponding to each defect; the following third operation is performed on each defect candidate frame: the maximum confidence Con is selected from the several confidences of the defect candidate frame as the confidence of the defect candidate frame, and the defect corresponding to the confidence Con is used as the label tag of the defect candidate frame; the coordinates of the center point of the defect candidate frame are used to identify the defect candidate frame. ,Width ,high Calculate the coordinates of the upper left corner of the defect candidate box , the coordinates of the lower right corner ,in, , ; The third operation is completed; for any two defect candidate frames frame1 and frame2 with the same label tag, the non-maximum suppression algorithm is used to calculate the value value1 of the intersection and union ratio of the defect candidate frames frame1 and frame2, and the value value1 is compared with the second preset threshold. If the value value1> the second preset threshold, the defect candidate frame with a larger confidence level among the defect candidate frames frame1 and frame2 is taken as a defect detection frame, and each defect detection frame is marked in the initial image.
5. A storage medium storing program instructions, characterized in that: When the program instructions are executed, the defect detection method according to any one of claims 1 to 3 is implemented.
6. An electronic terminal, characterized in that: The method comprises a processor and a memory, wherein the memory stores program instructions, and the processor executes the program instructions to implement the defect detection method according to any one of claims 1 to 3.
