A method and device for detecting surface defects of cylindrical lithium batteries
By introducing attention mechanism and top-down and bottom-up feature aggregation paths in the detection of surface defects of cylindrical lithium batteries, the problem of low defect detection accuracy in the prior art is solved, and small and dense defects are achieved efficient detection.
Patent Information
- Application Number
- CN202410755003.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-12
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2044-06-12
AI Technical Summary
The existing deep learning methods have problems such as low accuracy in the detection of cylindrical lithium batteries and inaccurate detection of dense defects.
A cylindrical lithium battery surface defect detection method is designed, using feature extraction network, path feature aggregation network and detection head network, introducing an attention mechanism, through the feature extraction network, the CBS module and C3 module are combined with top-down and The bottom-up feature aggregation path improves the accuracy of defect detection.
It significantly improves the detection effect of smaller defects and dense defects, enhances the accuracy and robustness of detection, can better handle defect characteristics of different sizes and densities, and improves the accuracy of dense defect detection.
Smart Images

Figure CN118552512B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of industrial defect detection, and in particular relates to a method and device for detecting surface defects of a cylindrical lithium battery. Background Art
[0002] With the continuous advancement of industrial technology, people have higher and higher requirements for product quality. In the past, they paid more attention to product performance and safety, but now they have also put forward new requirements for product surface quality. With the rapid development of new energy lithium batteries, cylindrical lithium batteries are more widely used. In the production process of cylindrical lithium batteries, manual defect detection of cylindrical lithium batteries on the assembly line will have the problems of low defect detection efficiency and easy errors. Therefore, machine vision detection methods, especially machine vision detection methods based on deep learning, are more considered, providing more possibilities for realizing industrial automation detection.
[0003] However, the network models involved in existing deep learning have problems with low detection accuracy and missed detection when detecting smaller defects. At the same time, they are unable to accurately detect densely packed defects. Summary of the invention
[0004] In order to solve the above problems existing in the prior art, the present invention provides a method and device for detecting surface defects of cylindrical lithium batteries. The technical problem to be solved by the present invention is achieved through the following technical solutions:
[0005] In a first aspect, an embodiment of the present invention provides a method for detecting surface defects of a cylindrical lithium battery, the method comprising:
[0006] Acquire a surface defect image of a cylindrical lithium battery to be inspected;
[0007] Inputting the surface defect image into a pre-trained defect detection network to obtain a detection result;
[0008] Among them, the defect detection network includes a feature extraction network, a path feature aggregation network and a detection head network connected in sequence; the feature extraction network is used to extract low-level feature maps, middle-level feature maps and high-level feature maps, and the feature extraction network includes 5 CBS modules, 4 C3 modules with attention mechanism and 1 spatial pyramid pooling module. The output of the i+1th CBS module is used as the input of the i-th C3 module with attention mechanism, i=1~4, the input of the first CBS module is the surface defect image, the output of the first CBS module is used as the input of the second CBS module, and the output of the last C3 module with attention mechanism is used as the input of the spatial pyramid pooling module. The low-level feature map is extracted by the second C3 module with attention mechanism, and the high-level feature map is extracted by the third C3 module with attention mechanism. A middle-level feature map is obtained, and a high-level feature map is obtained by extracting it through a spatial pyramid pooling module; the path feature aggregation network is used to aggregate the low-level feature map, the middle-level feature map and the high-level feature map, and the path feature aggregation network includes two feature aggregation paths, a top-down path and a bottom-up path. The bottom-up path is used to realize feature aggregation of the high-level feature map with the middle-level feature map and the low-level feature map from bottom to top, and the top-down path is used to realize feature aggregation of the low-level feature map with the high-level feature map and the middle-level feature map from top to bottom. A low-level aggregated feature map, a middle-level aggregated feature map and a high-level aggregated feature map are obtained through the two feature aggregation paths; the detection head network is used to detect the low-level aggregated feature map, the middle-level aggregated feature map and the high-level aggregated feature map to obtain a detection result.
[0009] In one embodiment of the present invention, the first C3 module and the fourth C3 module in the feature extraction network have the same network structure, the first C3 module includes 3 CBS modules, 3 attention modules, and 1 connection module, wherein the first CBS module and the 3 attention modules and the 1 connection module are connected in sequence, the second CBS module is bridged to the input end of the first CBS module and the input end of the connection module, the input end of the third CBS module is connected to the output end of the connection module, and the output end of the third CBS module serves as the output end of the first C3 module;
[0010] The second C3 module in the feature extraction network includes 3 CBS modules, 6 attention modules, and 1 connection module, wherein the first CBS module is connected to the 6 attention modules and the 1 connection module in sequence, the second CBS module is bridged to the input end of the first CBS module and the input end of the connection module, the input end of the third CBS module is connected to the output end of the connection module, and the output end of the third CBS module serves as the output end of the second C3 module;
[0011] The third C3 module in the feature extraction network includes 3 CBS modules, 9 attention modules, and 1 connection module, wherein the first CBS module and the 9 attention modules and the 1 connection module are connected in sequence, the second CBS module is bridged to the input end of the first CBS module and the input end of the connection module, the input end of the third CBS module is connected to the output end of the connection module, and the output end of the third CBS module serves as the output end of the first C3 module.
[0012] In one embodiment of the present invention, the network structures of all attention modules in the feature extraction network are the same; each attention module includes a flattening layer, a position encoder, a multi-head autonomous attention layer, a normalization layer, a fully connected layer, and a pooling layer; wherein,
[0013] The input of the flattening layer serves as the data input of the attention module. The output of the flattening layer and the output of the position encoder are connected to the input of the multi-head autonomous attention layer through the first adder. The output of the multi-head autonomous attention layer and the input of the multi-head autonomous attention layer are connected to the input of the normalization layer through the second adder. The output of the normalization layer is connected to the input of the fully connected layer. The input of the normalization layer and the output of the fully connected layer are connected to the input of the pooling layer through the third adder. The output of the pooling layer serves as the data output of the attention module.
[0014] In one embodiment of the present invention, the bottom-up feature aggregation path in the path feature aggregation network includes 1 C3 module that introduces an attention mechanism, 2 upsampling modules, 2 splicing modules and 2 CBS modules, wherein the output of the j-th CBS module is used as the input of the j-th upsampling module, the output of the j-th upsampling module is used as the input of the j-splitting modules, j=1-2, the input end of the first CBS module is connected to the output end of the spatial pyramid pooling module, the input of the first splicing module is also connected to the output end of the third C3 module that introduces the attention mechanism in the feature extraction network, and the input of the second splicing module is also connected to the output end of the second C3 module that introduces the attention mechanism in the feature extraction network;
[0015] The top-down feature aggregation path in the path feature aggregation network includes 3 C3 modules that introduce an attention mechanism, 2 splicing modules and 2 CBS modules, wherein the output of the kth C3 module that introduces an attention mechanism is used as the input of the kth CBS module, and the output of the kth CBS module is used as the input of k+1 C3 modules that introduce an attention mechanism, k=1~2, the input end of the first C3 module that introduces an attention mechanism is connected to the output end of the second splicing module in the bottom-up feature aggregation path, the input end of the first splicing module is also connected to the output end of the second CBS module in the bottom-up feature aggregation path and the output end of the third C3 module that introduces an attention mechanism in the feature extraction network, the input end of the first splicing module is also connected to the output end of the first CBS module in the bottom-up feature aggregation path, the first C3 module that introduces an attention mechanism outputs a low-level aggregation feature map, the second C3 module that introduces an attention mechanism outputs a middle-level aggregation feature map, and the third C3 module that introduces an attention mechanism outputs a high-level aggregation feature map.
[0016] In one embodiment of the present invention, all C3 modules that introduce the attention mechanism in the path feature aggregation network have the same network structure as the first C3 module in the feature extraction network.
[0017] In one embodiment of the present invention, obtaining a surface defect image of a cylindrical lithium battery to be inspected includes:
[0018] A defect acquisition device is used to obtain a surface defect image of a cylindrical lithium battery to be inspected; wherein the defect acquisition device includes a conveying device, a photoelectric sensor, a controller, a light source device, and an industrial camera, wherein the photoelectric sensor and the controller are installed at the bottom of the conveying device, and the light source device and the industrial camera are installed on the same side of the conveying device and keep a certain distance; wherein,
[0019] The conveying device is used to convey the cylindrical lithium battery to be tested;
[0020] The photoelectric sensor is used to detect the motion state of the conveying device to generate an electrical signal and send it to the controller;
[0021] The controller is used to generate a first control signal and a second control signal according to the electrical signal and send the first control signal to the industrial camera;
[0022] The light source device is used to provide supplementary light for the cylindrical lithium batteries to be detected that are transmitted to the designated area according to the first control signal;
[0023] The industrial camera is used to photograph the cylindrical lithium battery to be inspected that is transmitted to the designated area according to the second control signal, so as to obtain a surface defect image of the cylindrical lithium battery to be inspected.
[0024] In one embodiment of the present invention, the conveying device is provided with a groove, and a self-rotating mechanism is provided in the groove;
[0025] The groove is used to place the cylindrical lithium battery to be detected, and when the cylindrical lithium battery to be detected is transferred to the designated area, the self-rotating mechanism starts to rotate so that the industrial camera can take a picture of the cylindrical lithium battery to be detected.
[0026] In one embodiment of the present invention, the defect collection device further includes a flap located at the end of the conveying device; and the corresponding method further includes:
[0027] A third control signal is generated according to the detection result to control the flip plate to perform a retaining or discharging action on the cylindrical lithium battery to be detected.
[0028] In a second aspect, an embodiment of the present invention provides a cylindrical lithium battery surface defect detection device, the device comprising:
[0029] An acquisition module, used to acquire a surface defect image of a cylindrical lithium battery to be inspected;
[0030] A detection module is used to input the surface defect image into a pre-trained defect detection network to obtain a detection result; wherein the defect detection network includes a feature extraction network, a path feature aggregation network and a detection head network connected in sequence; the feature extraction network is used to extract low-level feature maps, middle-level feature maps and high-level feature maps, and the feature extraction network includes 5 CBS modules, 4 C3 modules with an attention mechanism introduced, and 1 spatial pyramid pooling module. The output of the i+1th CBS module is used as the input of the i-th C3 module with an attention mechanism introduced, i=1-4, the input of the first CBS module is the surface defect image, the output of the first CBS module is used as the input of the second CBS module, and the output of the last C3 module with an attention mechanism introduced is used as the input of the spatial pyramid pooling module, and after the second C3 module with an attention mechanism introduced The low-level feature map is obtained by block extraction, and the middle-level feature map is obtained by the third C3 module which introduces the attention mechanism, and the high-level feature map is obtained by the spatial pyramid pooling module. The path feature aggregation network is used to aggregate the low-level feature map, the middle-level feature map and the high-level feature map. The path feature aggregation network includes two feature aggregation paths, top-down and bottom-up. The bottom-up feature aggregation path is used to realize the feature aggregation of the high-level feature map from bottom to top with the middle-level feature map and the low-level feature map. The top-down feature aggregation path is used to realize the feature aggregation of the low-level feature map from top to bottom with the high-level feature map and the middle-level feature map. The low-level aggregated feature map, the middle-level aggregated feature map and the high-level aggregated feature map are obtained through the two feature aggregation paths. The detection head network is used to detect the low-level aggregated feature map, the middle-level aggregated feature map and the high-level aggregated feature map to obtain the detection result.
[0031] In one embodiment of the present invention, the acquisition module includes a defect acquisition device; the defect acquisition device includes a conveying device, a photoelectric sensor, a controller, a light source device, and an industrial camera, the photoelectric sensor and the controller are installed at the bottom of the conveying device, and the light source device and the industrial camera are installed on the same side of the conveying device and keep a certain distance; wherein,
[0032] The conveying device is used to convey the cylindrical lithium battery to be tested;
[0033] The photoelectric sensor is used to detect the motion state of the conveying device to generate an electrical signal and send it to the controller;
[0034] The controller is used to generate a first control signal and a second control signal according to the electrical signal and send the first control signal to the industrial camera;
[0035] The light source device is used to provide supplementary light for the cylindrical lithium batteries to be detected that are transmitted to the designated area according to the first control signal;
[0036] The industrial camera is used to photograph the cylindrical lithium battery to be inspected that is transmitted to the designated area according to the second control signal, so as to obtain a surface defect image of the cylindrical lithium battery to be inspected.
[0037] Beneficial effects of the present invention:
[0038] The cylindrical lithium battery surface defect detection method proposed in the present invention has a good detection effect for smaller defects and dense defects, because the present invention designs a defect detection network: an attention mechanism is introduced in the feature extraction module of the defect detection network, so that in the process of extracting low-level feature maps, middle-level feature maps and high-level feature maps, the global perception ability of the attention mechanism is used to capture long-distance dependencies in the entire input sequence, which helps to better understand the contextual information of smaller defects and dense defects, and can more freely handle defect features of different sizes and densities, and can also better handle overlaps between defects, thereby enhancing the segmentation and positioning capabilities of dense defects and effectively improving dense The accuracy and robustness of defect detection; at the same time, the present invention adopts a top-down and bottom-up bidirectional feature aggregation mechanism, so that the low-level aggregation feature map, the middle-level aggregation feature map, and the high-level aggregation feature map all contain feature information of other levels. In particular, the present invention also introduces an attention mechanism on the top-down and bottom-up feature aggregation paths, which improves the information transmission and context fusion capabilities of the defect detection network, and helps to better capture defect features of different scales; further, the present invention directly introduces the middle-level feature map in the feature extraction network into the top-down feature aggregation path, thereby deepening the feature extraction, realizing more comprehensive and efficient feature information transmission, and realizing higher-precision detection.
[0039] The present invention will be further described in detail below with reference to the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 It is a schematic flow chart of a cylindrical lithium battery surface defect detection method provided by an embodiment of the present invention;
[0041] Figure 2 is a schematic structural diagram of a defect collection device provided by an embodiment of the present invention;
[0042] Figure 3 is a schematic diagram of the structure of a defect detection network provided by an embodiment of the present invention;
[0043] Figure 4 It is a schematic diagram of the structure of a feature extraction network in a defect detection network provided by an embodiment of the present invention;
[0044] Figure 5 It is a schematic diagram of the structure of the C3 module that introduces the attention mechanism in the feature extraction network provided by an embodiment of the present invention;
[0045] Figure 6 is a schematic diagram of the structure of the attention module in the C3 module introducing the attention mechanism provided in an embodiment of the present invention;
[0046] Figure 7 It is a schematic diagram of the structure of a path feature aggregation network in a defect detection network provided by an embodiment of the present invention;
[0047] Figure 8 It is a structural schematic diagram of a cylindrical lithium battery surface defect detection device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0048] The present invention is further described in detail below with reference to specific embodiments, but the embodiments of the present invention are not limited thereto.
[0049] See also Figure 1 The present invention provides a method for detecting surface defects of a cylindrical lithium battery, which specifically includes the following steps:
[0050] S10, obtaining a surface defect image of the cylindrical lithium battery to be inspected.
[0051] In the embodiment of the present invention, the surface defect image of the cylindrical lithium battery to be detected is obtained, including: using a defect acquisition device to obtain the surface defect image of the cylindrical lithium battery to be detected; wherein, see Figure 2 The defect collection device of the embodiment of the present invention includes a conveying device, a photoelectric sensor, a controller, a light source device, and an industrial camera. The photoelectric sensor and the controller are installed at the bottom of the conveying device, and the light source device and the industrial camera are installed on the same side of the conveying device and keep a certain distance; wherein the conveying device is used to convey the cylindrical lithium battery to be detected; the photoelectric sensor is used to detect the movement state of the conveying device to generate an electrical signal and send it to the controller; the controller is used to generate a first control signal and a second control signal according to the electrical signal and send them to the industrial camera; the light source device is used to fill light for the cylindrical lithium battery to be detected that is transmitted to the specified area according to the first control signal; the industrial camera is used to shoot the cylindrical lithium battery to be detected that is transmitted to the specified area according to the second control signal to obtain the surface defect image of the cylindrical lithium battery to be detected.
[0052] In the embodiment of the present invention, a groove is provided on the conveying device, and a self-rotating mechanism is provided in the groove; the groove is used to place the cylindrical lithium battery to be inspected, and when the cylindrical lithium battery to be inspected is conveyed to the designated area, the self-rotating mechanism starts to rotate, so that the industrial camera can take pictures of the cylindrical lithium battery to be inspected.
[0053] In the embodiment of the present invention, the defect collection device further includes a flap located at the end of the conveying device; the corresponding method further includes: generating a third control signal according to the detection result to control the flap to perform a retention or discharge action on the cylindrical lithium battery to be detected.
[0054] It can be seen that the defect collection device provided in the embodiment of the present invention is suitable for the on-site environment of the industrial production line. In the process of the conveying device conveying the cylindrical lithium battery to be inspected, the movement state of the conveying device is captured in real time according to the photoelectric sensor, so as to generate a control signal through the controller to drive the industrial camera to shoot the cylindrical lithium battery to be inspected; when the cylindrical lithium battery to be inspected to be photographed is about 10 cm away from the industrial camera lens, the focusing can be completed, and the industrial camera should be positioned directly opposite the area to be photographed to obtain the best field of view; at the same time, since the brightness of the light source device decays rapidly with increasing distance, it is necessary to ensure that the shooting distance is close, the light source device is about 5 cm away from the conveyor belt device and about 8 cm away from the cylindrical lithium battery to be inspected, so that the light source device does not affect the image captured by the industrial camera while providing good lighting conditions, assisting imaging, and improving imaging stability.
[0055] Surface defect images of cylindrical lithium batteries to be inspected at different angles are obtained through industrial cameras, and the surface defect images of cylindrical surfaces at different angles are spliced and fused to obtain a complete surface defect image of the cylindrical lithium batteries to be inspected. Here, how to splice and fuse the surface defect images of cylindrical surfaces at different angles can be referred to the existing technology and will not be repeated here.
[0056] S20. Input the surface defect image into a pre-trained defect detection network to obtain a detection result; wherein the defect detection network includes a feature extraction network, a path feature aggregation network and a detection head network connected in sequence; the feature extraction network is used to extract low-level feature maps, middle-level feature maps and high-level feature maps, and the feature extraction network includes 5 CBS modules, 4 C3 modules with an attention mechanism and 1 spatial pyramid pooling module. The output of the i+1th CBS module is used as the input of the i-th C3 module with an attention mechanism, i=1~4, the input of the first CBS module is the surface defect image, the output of the first CBS module is used as the input of the second CBS module, and the output of the last C3 module with an attention mechanism is used as the input of the spatial pyramid pooling module, and is extracted by the second C3 module with an attention mechanism. A low-level feature map is obtained, and a middle-level feature map is obtained by extracting it through the third C3 module that introduces the attention mechanism, and a high-level feature map is obtained by extracting it through the spatial pyramid pooling module; a path feature aggregation network is used to aggregate low-level feature maps, middle-level feature maps and high-level feature maps, and the path feature aggregation network includes two feature aggregation paths, top-down and bottom-up. The bottom-up feature aggregation path is used to realize feature aggregation of high-level feature maps with middle-level feature maps and low-level feature maps from bottom to top, and the top-down feature aggregation path is used to realize feature aggregation of low-level feature maps with high-level feature maps and middle-level feature maps from top to bottom. Through the two feature aggregation paths, low-level aggregated feature maps, middle-level aggregated feature maps and high-level aggregated feature maps are obtained; a detection head network is used to detect low-level aggregated feature maps, middle-level aggregated feature maps and high-level aggregated feature maps to obtain detection results.
[0057] In order to detect small surface defects and dense defects, the present invention designs a defect detection network. Figure 3 As shown, it is composed of a feature extraction network, a path feature aggregation network and a detection head network. For each part of the defect detection network, an embodiment of the present invention introduces an attention mechanism, because the attention mechanism can well capture the long-range dependencies in the input sequence, which helps to better understand the relationship between different regions in the image. The attention mechanism allows the network model to weight all positions of the input when generating outputs, so as to better integrate global information rather than just local information. The attention mechanism helps to improve the network model's perception of different regions. However, there is a lot of room for discussion on the introduction of the attention mechanism in the defect detection network and where the attention mechanism should be introduced. The introduction of the attention mechanism may increase the complexity of the network model, so it is necessary to weigh the performance improvement and the use of computing resources.
[0058] Based on the above analysis, the feature extraction network, path feature aggregation network and detection head network introduced with the attention mechanism proposed in the embodiment of the present invention are specifically:
[0059] See also Figure 4 , the network structure of the feature extraction network with the attention mechanism is given, where the structure of the C3 module with the attention mechanism is as follows Figure 5 As shown, Figure 5 Where N represents the number of attention modules. Figure 5 As shown in the figure, when N=3, it is the network structure of the first C3 module and the fourth C3 module in the feature extraction network. It can be seen that: when N=3, the first C3 module includes 3 CBS modules, 3 attention modules, and 1 connection module, wherein the first CBS module and the 3 attention modules and the 1 connection module are connected in sequence, the second CBS module is bridged between the input end of the first CBS module and the input end of the connection module, the input end of the third CBS module is connected to the output end of the connection module, and the output end of the third CBS module is used as the output end of the first C3 module;
[0060] like Figure 5 As shown in the figure, when N=6, it is the network structure of the second C3 module in the feature extraction network. It can be seen that when N=6, the second C3 module includes 3 CBS modules, 6 attention modules, and 1 connection module, wherein the first CBS module and the 6 attention modules and the 1 connection module are connected in sequence, the second CBS module is bridged between the input end of the first CBS module and the input end of the connection module, the input end of the third CBS module is connected to the output end of the connection module, and the output end of the third CBS module is used as the output end of the second C3 module;
[0061] like Figure 5 As shown in the figure, when N=9, it is the network structure of the third C3 module in the feature extraction network. It can be seen that: when N=9, the third C3 module includes 3 CBS modules, 9 attention modules, and 1 connection module, among which the first CBS module and the 9 attention modules and the 1 connection module are connected in sequence, the second CBS module is bridged between the input end of the first CBS module and the input end of the connection module, the input end of the third CBS module is connected to the output end of the connection module, and the output end of the third CBS module is used as the output end of the first C3 module.
[0062] It can be seen that the embodiment of the present invention introduces attention modules at 4 locations in the feature extraction network, and the number of attention modules introduced at each location is different, so that in the process of extracting low-level feature maps, middle-level feature maps and high-level feature maps, the global perception ability of the attention mechanism is utilized to capture long-distance dependencies in the entire input sequence, which helps to better understand the contextual information of smaller defects and dense defects. The attention mechanism can handle defect features of different sizes and densities more freely, and can also better handle overlaps between defects, enhance the ability to segment and locate dense defects, and effectively improve the accuracy and robustness of dense defect detection.
[0063] The network structures of all attention modules in the feature extraction network of the embodiment of the present invention are the same; in order to better apply the attention module to the feature extraction network, a network structure of the attention module is designed as follows Figure 6 As shown, each attention module includes a flattening layer, a position encoder, a multi-head autonomous attention layer, a normalization layer, a fully connected layer, and a pooling layer; wherein the input of the flattening layer is used as the data input of the attention module, the output of the flattening layer and the output of the position encoder are connected to the input of the multi-head autonomous attention layer through the first adder, the output of the multi-head autonomous attention layer and the input of the multi-head autonomous attention layer are connected to the input of the normalization layer through the second adder, the output of the normalization layer is connected to the input of the fully connected layer, the input of the normalization layer and the output of the fully connected layer are connected to the input of the pooling layer through the third adder, and the output of the pooling layer is used as the data output of the attention module. It can be seen that in the attention module:
[0064] First, the flattening layer flattens the input surface defect image into a one-dimensional vector for subsequent processing.
[0065] Then, the position encoder provides the position information of each pixel in the surface defect image. Since the attention module has no built-in position information, the position encoder helps the attention module learn the relative position relationship between elements by adding the position information in the one-dimensional vector output by the flattening layer.
[0066] Afterwards, the multi-head self-attention layer learns different relations in different representation spaces (attention heads), allowing the attention module to simultaneously focus on different parts of the first adder output data in multiple different representation spaces and better capture global information.
[0067] Afterwards, the normalization layer standardizes the output data of the second adder, which helps to accelerate training and improve the stability of the model; at the same time, it can reduce internal covariate shift, help train deep networks, and improve the convergence speed and stability of the attention module.
[0068] Afterwards, the fully connected layer performs a nonlinear transformation on the input data of the normalization layer at each position, so that the attention module can learn and perform more complex nonlinear mapping on the normalized input data at each position, increasing the expressive power of the attention module.
[0069] Finally, the pooling layer randomly discards the output of some neurons to reduce the overfitting of the model to the output data of the third adder. This pooling layer can prevent the attention module from being overly dependent on specific input features, making the attention module more generalizable to unseen data, reducing the coupling between neurons, and making the learning of the attention module more independent and robust.
[0070] For further information, see Figure 7 , the bottom-up feature aggregation path in the path feature aggregation network of the embodiment of the present invention includes 1 C3 module that introduces the attention mechanism, 2 upsampling modules, 2 splicing modules and 2 CBS modules, wherein the output of the j-th CBS module is used as the input of the j-th upsampling module, the output of the j-th upsampling module is used as the input of the j-splitting modules, j=1-2, the input end of the first CBS module is connected to the output end of the spatial pyramid pooling module, the input of the first splicing module is also connected to the output end of the third C3 module that introduces the attention mechanism in the feature extraction network, and the input of the second splicing module is also connected to the output end of the second C3 module that introduces the attention mechanism in the feature extraction network;
[0071] The top-down feature aggregation path in the path feature aggregation network includes 3 C3 modules with attention mechanism, 2 splicing modules and 2 CBS modules, among which the output of the kth C3 module with attention mechanism is used as the input of the kth CBS module, and the output of the kth CBS module is used as the input of k+1 C3 modules with attention mechanism, k=1~2, the input end of the first C3 module with attention mechanism is connected to the output end of the second splicing module in the bottom-up feature aggregation path, the input end of the first splicing module is also connected to the output end of the second CBS module in the bottom-up feature aggregation path and the output end of the third C3 module with attention mechanism in the feature extraction network, the input end of the first splicing module is also connected to the output end of the first CBS module in the bottom-up feature aggregation path, the first C3 module with attention mechanism outputs a low-level aggregated feature map, the second C3 module with attention mechanism outputs a middle-level aggregated feature map, and the third C3 module with attention mechanism outputs a high-level aggregated feature map.
[0072] All C3 modules that introduce the attention mechanism in the path feature aggregation network of the embodiment of the present invention have the same network structure as the first C3 module in the feature extraction network.
[0073] It can be seen that the embodiment of the present invention adopts a bidirectional feature aggregation mechanism, that is, there are connections from high-level feature maps to low-level feature maps and from low-level feature maps to high-level feature maps, so that low-level aggregated feature maps, middle-level aggregated feature maps, and high-level aggregated feature maps all contain feature information of other levels. In particular, the embodiment of the present invention also introduces an attention mechanism on the top-down and bottom-up feature aggregation paths, which improves the information transmission and context fusion capabilities of the defect detection network and helps to better capture defect features of different scales. Furthermore, on the top-down feature aggregation path, the embodiment of the present invention also considers the output features of the third C3 module in the feature extraction network that introduces the attention mechanism, thereby deepening the feature extraction and achieving more comprehensive and efficient feature information transmission.
[0074] Furthermore, in the embodiment of the present invention, the detection head network may adopt the anchor-free regression classification detection head network in the FCOS detection algorithm, and specifically use the three-branch anchor-free detector in the FCOS detection algorithm for detection. The corresponding detection process includes:
[0075] Firstly, an anchor-free detector based on single center point prediction is used to generate candidate boxes, and the quality of the target candidate boxes is predicted and constrained by adding a center prediction branch. Then, the regression branch is combined to predict the parameters of the detection box, and the classification branch is used to identify the target. Finally, through the non-maximum suppression technology, the product of the centerness and the classification probability is used as the confidence of the prediction box to screen out all possible target defects to complete defect detection.
[0076] It should be noted that the embodiment of the present invention does not provide a detailed description of how to train the defect detection network, because the defect detection network can be trained using existing training methods, by pre-collecting training data sets and verification data sets, and then training the defect detection network based on the training data sets and verification data sets.
[0077] In summary, the cylindrical lithium battery surface defect detection method provided by the embodiment of the present invention has a good detection effect for the detection of smaller defects and dense defects, because the present invention designs a defect detection network: an attention mechanism is introduced in the feature extraction module of the defect detection network, so that in the process of extracting low-level feature maps, middle-level feature maps and high-level feature maps, the global perception ability of the attention mechanism is utilized to capture long-distance dependencies in the entire input sequence, which helps to better understand the contextual information of smaller defects and dense defects, and can more freely handle defect features of different sizes and densities, and can also better handle overlaps between defects, thereby enhancing the segmentation and positioning capabilities of dense defects, and effectively improving the dense defect The accuracy and robustness of defect detection are improved; at the same time, the embodiment of the present invention adopts a top-down and bottom-up bidirectional feature aggregation mechanism, so that the low-level aggregation feature map, the middle-level aggregation feature map, and the high-level aggregation feature map all contain feature information of other levels. In particular, the embodiment of the present invention also introduces an attention mechanism on the two feature aggregation paths from top to bottom and bottom to top, which improves the information transmission and context fusion capabilities of the defect detection network and helps to better capture defect features of different scales; further, the embodiment of the present invention directly introduces the middle-level feature map in the feature extraction network into the top-down feature aggregation path, thereby deepening the feature extraction, realizing more comprehensive and efficient feature information transmission, and realizing higher-precision detection.
[0078] Second, see Figure 8 The embodiment of the present invention provides a cylindrical lithium battery surface defect detection device, the device comprising:
[0079] An acquisition module, used to acquire a surface defect image of a cylindrical lithium battery to be inspected;
[0080] A detection module is used to input the surface defect image into a pre-trained defect detection network to obtain the detection result; wherein the defect detection network includes a feature extraction network, a path feature aggregation network and a detection head network connected in sequence; the feature extraction network is used to extract low-level feature maps, middle-level feature maps and high-level feature maps, and the feature extraction network includes 5 CBS modules, 4 C3 modules with an attention mechanism and 1 spatial pyramid pooling module. The output of the i+1th CBS module is used as the input of the i-th C3 module with an attention mechanism, i=1~4, the input of the first CBS module is the surface defect image, the output of the first CBS module is used as the input of the second CBS module, and the output of the last C3 module with an attention mechanism is used as the input of the spatial pyramid pooling module. After being extracted by the second C3 module with an attention mechanism, The low-level feature map is obtained, and the middle-level feature map is extracted through the third C3 module which introduces the attention mechanism, and the high-level feature map is extracted through the spatial pyramid pooling module; the path feature aggregation network is used to aggregate the low-level feature map, the middle-level feature map and the high-level feature map, and the path feature aggregation network includes two feature aggregation paths, top-down and bottom-up. The bottom-up feature aggregation path is used to realize the feature aggregation of the high-level feature map from bottom to top with the middle-level feature map and the low-level feature map, and the top-down feature aggregation path is used to realize the feature aggregation of the low-level feature map from top to bottom with the high-level feature map and the middle-level feature map, and the low-level aggregated feature map, the middle-level aggregated feature map and the high-level aggregated feature map are obtained through the two feature aggregation paths; the detection head network is used to detect the low-level aggregated feature map, the middle-level aggregated feature map and the high-level aggregated feature map to obtain the detection result.
[0081] Furthermore, in the embodiment of the present invention, the acquisition module includes a defect acquisition device; the defect acquisition device includes a conveying device, a photoelectric sensor, a controller, a light source device, and an industrial camera, the photoelectric sensor and the controller are installed at the bottom of the conveying device, and the light source device and the industrial camera are installed on the same side of the conveying device and keep a certain distance; wherein,
[0082] A conveying device, used for conveying cylindrical lithium batteries to be tested;
[0083] A photoelectric sensor is used to detect the motion state of the conveyor to generate an electrical signal and send it to the controller;
[0084] A controller, used for generating a first control signal and a second control signal according to the electrical signal and sending the signals to the industrial camera;
[0085] A light source device, used for providing supplementary light for the cylindrical lithium batteries to be detected that are transmitted to the designated area according to the first control signal;
[0086] The industrial camera is used to photograph the cylindrical lithium battery to be inspected that is transmitted to the designated area according to the second control signal to obtain the surface defect image of the cylindrical lithium battery to be inspected.
[0087] As for the device embodiment of the second aspect, since it is basically similar to the method embodiment of the first aspect, the description is relatively simple, and the relevant parts may refer to the partial description of the method embodiment of the first aspect.
[0088] In the description of the present invention, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0089] Although the present invention is described herein in conjunction with various embodiments, in the process of implementing the claimed invention, those skilled in the art may understand and implement other variations of the disclosed embodiments by viewing the specification and its drawings. In the specification, the word "comprising" does not exclude other components or steps, and "a" or "one" does not exclude multiple situations. Certain measures are recorded in different embodiments, but this does not mean that these measures cannot be combined to produce good results.
[0090] The above contents are further detailed descriptions of the present invention in combination with specific preferred embodiments, and it cannot be determined that the specific implementation of the present invention is limited to these descriptions. For ordinary technicians in the technical field to which the present invention belongs, several simple deductions or substitutions can be made without departing from the concept of the present invention, which should be regarded as falling within the protection scope of the present invention.
Claims
1. A method for detecting surface defects of a cylindrical lithium battery, characterized in that: The method comprises: Acquire a surface defect image of a cylindrical lithium battery to be inspected; The surface defect image is input into a pre-trained defect detection network to obtain a detection result; wherein the defect detection network includes a feature extraction network, a path feature aggregation network and a detection head network connected in sequence; the feature extraction network is used to extract low-level feature maps, middle-level feature maps and high-level feature maps, and the feature extraction network includes 5 CBS modules, 4 C3 modules with an attention mechanism and 1 spatial pyramid pooling module. The output of the i+1th CBS module is used as the input of the i-th C3 module with an attention mechanism, i=1-4, the input of the first CBS module is the surface defect image, the output of the first CBS module is used as the input of the second CBS module, and the output of the last C3 module with an attention mechanism is used as the input of the spatial pyramid pooling module. The low-level feature map is extracted by the second C3 module with an attention mechanism, and the low-level feature map is extracted by the third C3 module with an attention mechanism. The C3 module with the attention mechanism is used to extract the middle-level feature map, and the high-level feature map is extracted through the spatial pyramid pooling module; the path feature aggregation network is used to aggregate the low-level feature map, the middle-level feature map and the high-level feature map, and the path feature aggregation network includes two feature aggregation paths from top to bottom and from bottom to top. The bottom-up feature aggregation path is used to realize the feature aggregation of the high-level feature map with the middle-level feature map and the low-level feature map from bottom to top, and the top-down feature aggregation path is used to realize the feature aggregation of the low-level feature map with the high-level feature map and the middle-level feature map from top to bottom. The low-level aggregation feature map, the middle-level aggregation feature map and the high-level aggregation feature map are obtained through the two feature aggregation paths; the detection head network is used to detect the low-level aggregation feature map, the middle-level aggregation feature map and the high-level aggregation feature map to obtain the detection result; wherein, Acquiring a surface defect image of a cylindrical lithium battery to be detected, comprising: acquiring a surface defect image of the cylindrical lithium battery to be detected by using a defect acquisition device; wherein the defect acquisition device comprises a conveying device, a photoelectric sensor, a controller, a light source device, and an industrial camera, wherein the photoelectric sensor and the controller are installed at the bottom of the conveying device, and the light source device and the industrial camera are installed on the same side of the conveying device and keep a certain distance; wherein the conveying device is used to convey the cylindrical lithium battery to be detected; the photoelectric sensor is used to detect the movement state of the conveying device to generate an electrical signal and send it to the controller; the controller is used to generate a first control signal and a second control signal according to the electrical signal and send them to the industrial camera; the light source device is used to fill light for the cylindrical lithium battery to be detected that is transmitted to the specified area according to the first control signal; the industrial camera is used to shoot the cylindrical lithium battery to be detected that is transmitted to the specified area according to the second control signal to obtain the surface defect image of the cylindrical lithium battery to be detected; The first C3 module and the fourth C3 module in the feature extraction network have the same network structure. The first C3 module includes 3 CBS modules, 3 attention modules, and 1 connection module, wherein the first CBS module is connected to the 3 attention modules and the 1 connection module in sequence, the second CBS module is bridged to the input end of the first CBS module and the input end of the connection module, the input end of the third CBS module is connected to the output end of the connection module, and the output end of the third CBS module is used as the output end of the first C3 module; the second C3 module in the feature extraction network includes 3 CBS modules, 6 attention modules, and 1 connection module, wherein the first CBS module is connected to the 6 attention modules and the 1 connection module in sequence. The modules are connected in sequence, the second CBS module is bridged to the input end of the first CBS module and the input end of the connection module, the input end of the third CBS module is connected to the output end of the connection module, and the output end of the third CBS module is used as the output end of the second C3 module; the third C3 module in the feature extraction network includes 3 CBS modules, 9 attention modules, and 1 connection module, wherein the first CBS module and the 9 attention modules and the 1 connection module are connected in sequence, the second CBS module is bridged to the input end of the first CBS module and the input end of the connection module, the input end of the third CBS module is connected to the output end of the connection module, and the output end of the third CBS module is used as the output end of the first C3 module; The network structures of all attention modules in the feature extraction network are the same; each attention module includes a flattening layer, a position encoder, a multi-head autonomous attention layer, a normalization layer, a fully connected layer, and a pooling layer; wherein the input of the flattening layer serves as the data input end of the attention module, the output end of the flattening layer and the output end of the position encoder are connected to the input end of the multi-head autonomous attention layer through a first adder, the output end of the multi-head autonomous attention layer and the input end of the multi-head autonomous attention layer are connected to the input end of the normalization layer through a second adder, the output end of the normalization layer is connected to the input end of the fully connected layer, the input end of the normalization layer and the output end of the fully connected layer are connected to the input end of the pooling layer through a third adder, and the output end of the pooling layer serves as the data output end of the attention module; The bottom-up feature aggregation path in the path feature aggregation network includes 1 C3 module that introduces an attention mechanism, 2 upsampling modules, 2 splicing modules and 2 CBS modules, wherein the output of the j-th CBS module is used as the input of the j-th upsampling module, and the output of the j-th upsampling module is used as the input of the j-splitting modules, j=1-2, the input end of the first CBS module is connected to the output end of the spatial pyramid pooling module, the input of the first splicing module is also connected to the output end of the third C3 module that introduces the attention mechanism in the feature extraction network, and the input of the second splicing module is also connected to the output end of the second C3 module that introduces the attention mechanism in the feature extraction network; the top-down feature aggregation path in the path feature aggregation network includes 3 C3 modules that introduce an attention mechanism, 2 splicing modules and 2 CBS modules, wherein the k-th CBS module introduces The output of the C3 module with the attention mechanism is used as the input of the kth CBS module, and the output of the kth CBS module is used as the input of k+1 C3 modules with the attention mechanism introduced, k=1~2, the input end of the first C3 module with the attention mechanism introduced is connected to the output end of the second splicing module in the bottom-up feature aggregation path, the input end of the first splicing module is also connected to the output end of the second CBS module in the bottom-up feature aggregation path and the output end of the third C3 module with the attention mechanism introduced in the feature extraction network, the input end of the first splicing module is also connected to the output end of the first CBS module in the bottom-up feature aggregation path, the first C3 module with the attention mechanism introduced outputs a low-level aggregated feature map, the second C3 module with the attention mechanism introduced outputs a middle-level aggregated feature map, and the third C3 module with the attention mechanism introduced outputs a high-level aggregated feature map.
2. The cylindrical lithium battery surface defect detection method according to claim 1, characterized in that: All C3 modules that introduce the attention mechanism in the path feature aggregation network have the same network structure as the first C3 module in the feature extraction network.
3. The cylindrical lithium battery surface defect detection method according to claim 1, characterized in that: The conveying device is provided with a groove, and a self-rotating mechanism is provided in the groove; The groove is used to place the cylindrical lithium battery to be detected, and when the cylindrical lithium battery to be detected is transferred to the designated area, the self-rotating mechanism starts to rotate so that the industrial camera can take a picture of the cylindrical lithium battery to be detected.
4. The cylindrical lithium battery surface defect detection method according to claim 1, characterized in that: The defect collection device also includes a flap located at the end of the conveying device; The corresponding method also includes: A third control signal is generated according to the detection result to control the flip plate to perform a retaining or discharging action on the cylindrical lithium battery to be detected.
5. A cylindrical lithium battery surface defect detection device, characterized in that: The device comprises: An acquisition module is used to acquire a surface defect image of a cylindrical lithium battery to be detected; wherein the acquisition module includes a defect acquisition device; the defect acquisition device includes a conveying device, a photoelectric sensor, a controller, a light source device, and an industrial camera, wherein the photoelectric sensor and the controller are installed at the bottom of the conveying device, and the light source device and the industrial camera are installed on the same side of the conveying device and maintain a certain distance; wherein the conveying device is used to convey the cylindrical lithium battery to be detected; the photoelectric sensor is used to detect the movement state of the conveying device to generate an electrical signal and send it to the controller; the controller is used to generate a first control signal and a second control signal according to the electrical signal and send them to the industrial camera; the light source device is used to fill light for the cylindrical lithium battery to be detected that is transmitted to the specified area according to the first control signal; the industrial camera is used to shoot the cylindrical lithium battery to be detected that is transmitted to the specified area according to the second control signal to obtain the surface defect image of the cylindrical lithium battery to be detected; A detection module is used to input the surface defect image into a pre-trained defect detection network to obtain a detection result; wherein the defect detection network includes a feature extraction network, a path feature aggregation network and a detection head network connected in sequence; the feature extraction network is used to extract low-level feature maps, middle-level feature maps and high-level feature maps, and the feature extraction network includes 5 CBS modules, 4 C3 modules with an attention mechanism and 1 spatial pyramid pooling module. The output of the i+1th CBS module is used as the input of the i-th C3 module with an attention mechanism, i=1-4, the input of the first CBS module is the surface defect image, the output of the first CBS module is used as the input of the second CBS module, and the output of the last C3 module with an attention mechanism is used as the input of the spatial pyramid pooling module. The low-level feature map is extracted by the second C3 module with an attention mechanism, and the low-level feature map is extracted by the second C3 module with an attention mechanism. The third C3 module that introduces the attention mechanism extracts the middle-level feature map, and extracts the high-level feature map through the spatial pyramid pooling module; the path feature aggregation network is used to aggregate the low-level feature map, the middle-level feature map and the high-level feature map, and the path feature aggregation network includes two feature aggregation paths from top to bottom and from bottom to top. The bottom-up feature aggregation path is used to realize the feature aggregation of the high-level feature map with the middle-level feature map and the low-level feature map from bottom to top, and the top-down feature aggregation path is used to realize the feature aggregation of the low-level feature map with the high-level feature map and the middle-level feature map from top to bottom. The low-level aggregated feature map, the middle-level aggregated feature map and the high-level aggregated feature map are obtained through the two feature aggregation paths; the detection head network is used to detect the low-level aggregated feature map, the middle-level aggregated feature map and the high-level aggregated feature map to obtain the detection result; wherein, The first C3 module and the fourth C3 module in the feature extraction network have the same network structure. The first C3 module includes 3 CBS modules, 3 attention modules, and 1 connection module, wherein the first CBS module is connected to the 3 attention modules and the 1 connection module in sequence, the second CBS module is bridged to the input end of the first CBS module and the input end of the connection module, the input end of the third CBS module is connected to the output end of the connection module, and the output end of the third CBS module is used as the output end of the first C3 module; the second C3 module in the feature extraction network includes 3 CBS modules, 6 attention modules, and 1 connection module, wherein the first CBS module is connected to the 6 attention modules and the 1 connection module in sequence. The modules are connected in sequence, the second CBS module is bridged to the input end of the first CBS module and the input end of the connection module, the input end of the third CBS module is connected to the output end of the connection module, and the output end of the third CBS module is used as the output end of the second C3 module; the third C3 module in the feature extraction network includes 3 CBS modules, 9 attention modules, and 1 connection module, wherein the first CBS module and the 9 attention modules and the 1 connection module are connected in sequence, the second CBS module is bridged to the input end of the first CBS module and the input end of the connection module, the input end of the third CBS module is connected to the output end of the connection module, and the output end of the third CBS module is used as the output end of the first C3 module; The network structures of all attention modules in the feature extraction network are the same; each attention module includes a flattening layer, a position encoder, a multi-head autonomous attention layer, a normalization layer, a fully connected layer, and a pooling layer; wherein the input of the flattening layer serves as the data input end of the attention module, the output end of the flattening layer and the output end of the position encoder are connected to the input end of the multi-head autonomous attention layer through a first adder, the output end of the multi-head autonomous attention layer and the input end of the multi-head autonomous attention layer are connected to the input end of the normalization layer through a second adder, the output end of the normalization layer is connected to the input end of the fully connected layer, the input end of the normalization layer and the output end of the fully connected layer are connected to the input end of the pooling layer through a third adder, and the output end of the pooling layer serves as the data output end of the attention module; The bottom-up feature aggregation path in the path feature aggregation network includes 1 C3 module that introduces an attention mechanism, 2 upsampling modules, 2 splicing modules and 2 CBS modules, wherein the output of the j-th CBS module is used as the input of the j-th upsampling module, and the output of the j-th upsampling module is used as the input of the j-splitting modules, j=1-2, the input end of the first CBS module is connected to the output end of the spatial pyramid pooling module, the input of the first splicing module is also connected to the output end of the third C3 module that introduces the attention mechanism in the feature extraction network, and the input of the second splicing module is also connected to the output end of the second C3 module that introduces the attention mechanism in the feature extraction network; the top-down feature aggregation path in the path feature aggregation network includes 3 C3 modules that introduce an attention mechanism, 2 splicing modules and 2 CBS modules, wherein the k-th CBS module introduces The output of the C3 module with the attention mechanism is used as the input of the kth CBS module, and the output of the kth CBS module is used as the input of k+1 C3 modules with the attention mechanism introduced, k=1~2, the input end of the first C3 module with the attention mechanism introduced is connected to the output end of the second splicing module in the bottom-up feature aggregation path, the input end of the first splicing module is also connected to the output end of the second CBS module in the bottom-up feature aggregation path and the output end of the third C3 module with the attention mechanism introduced in the feature extraction network, the input end of the first splicing module is also connected to the output end of the first CBS module in the bottom-up feature aggregation path, the first C3 module with the attention mechanism introduced outputs a low-level aggregated feature map, the second C3 module with the attention mechanism introduced outputs a middle-level aggregated feature map, and the third C3 module with the attention mechanism introduced outputs a high-level aggregated feature map.
