An intelligent quantitative detection method for tool damage based on improved Swin-Transformer
Through the improved Swin-Transformer network architecture, combined with multiple loss functions and self-attention modules, high-precision quantitative detection of tool damage is achieved, which solves the problem of insufficient quantitative evaluation in existing technologies, improves detection accuracy and reliability, and is suitable for industrial applications of machine tool tools.
Patent Information
- Application Number
- CN202411028400.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-29
- Publication Date
- 2025-10-14
- Estimated Expiration
- 2044-07-29
AI Technical Summary
Existing tool damage detection methods are difficult to achieve high-precision quantitative assessment and cannot meet the accuracy and reliability requirements for damage degree in industrial applications.
An improved Swin-Transformer network architecture is adopted, combining the Patch Partition module, Linear Embedding layer, Patch Merging layer, global pooling layer and fully connected layer, and adding the SW-MSA shift window multi-head self-attention module. By moving the feature window and optimizing the loss function, the model's feature learning ability and detection accuracy are improved.
It significantly improves the accuracy and reliability of tool damage detection, enables high-precision quantitative damage assessment, reduces computing costs, and is suitable for machining status monitoring of machine tool tools.
Smart Images

Figure CN119091270B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of tool damage detection, and more particularly, relates to a tool damage intelligent quantitative detection method based on an improved Swin-Transformer. BACKGROUND
[0002] Tool damage detection is a core link of quality control and cost optimization in the manufacturing process, and has immeasurable value for ensuring product quality and reducing production cost. With the vigorous rise of artificial intelligence technology, deep learning driven visual detection technology opens up a new path for tool damage detection. In recent years, the research on the cross of deep learning and tool damage detection has been flourishing, and researchers have achieved significant breakthroughs in this field by deeply mining the internal patterns and characteristics of tool damage images. However, current methods are mostly limited to qualitative analysis of tool damage, and it is difficult to meet the urgent needs of the industry for precise quantification and high reliability of damage degree. Overcoming the difficulty of tool damage quantitative detection is a key step to promote the technology from the laboratory to the production line and realize industrialization, and its theoretical significance and application prospect cannot be ignored. Therefore, it is urgent to develop a new method that integrates tool visual detection and quantitative analysis, and lay a solid foundation for the industrial application of tool damage detection.
[0003] Chinese Patent Publication No. CN116309458A discloses an intelligent tool damage detection and warning method based on improved YOLOX, which can automatically identify whether the input image is damaged and make tool damage category and area judgments. At the same time, it can perform tool health warnings based on the damage type, and also provide new ideas for industrial deployment by replacing the lightweight backbone network. However, it is still unable to perform quantitative evaluation of tool wear, and its industrial applicability has great limitations; Chinese Patent Publication No. CN116993711A discloses an intelligent tool damage detection method based on self-distillation. This method abandons the traditional two-stage training strategy of knowledge distillation. By splitting the internal structure of the teacher-student network into different shallow parts, knowledge is squeezed out of the deep network and into the shallow network, and a single-stage end-to-end training is performed, while reducing the model complexity and model scale, providing an industrial application basis for production line machine tool tool detection. However, this method mainly performs model compression on larger network models, without considering the model's quantitative evaluation of tool wear, and is difficult to adapt to the needs of quantitative detection of tool damage; Chinese Patent Publication No. CN1 17197427A discloses a tool damage target detection method based on an improved RTMDet. This method can improve the network's feature reuse capability and improve the model's learning effect by improving the shortest gradient path. At the same time, it improves the perception ability of spatial channels, enhances the network model's suppression of redundant features, and thus improves detection accuracy. Finally, the model is optimized through the TensorRT framework and deployed on an embedded platform, which improves the model's detection speed for tool damage and solves the high latency problem of edge platform computing. This method can take into account the detection accuracy and processing speed of the target detection algorithm and is suitable for the real-time requirements of the tool damage detection system. However, this method ignores the need for quantitative evaluation of tool wear and is difficult to meet the accuracy and reliability requirements of tool damage in industrial applications.Chinese Patent Publication No. CN1 17733649A discloses a tool wear value monitoring method based on an improved Swin-Transformer. This method replaces the MLP structure in the original model with a residual block and reduces the number of layers of the model stacking block. This enables the tool to collect vibration, cutting force and other signals to effectively and accurately monitor the tool wear value under the same cutting parameters. However, this method can only monitor wear for one-dimensional sensor signals and requires preprocessing of the original signal, which increases the monitoring cost. At the same time, this method still remains in the qualitative monitoring stage of tool damage and is difficult to cope with the challenge of high-precision monitoring of damage in industrial applications; Chinese Patent Authorization No. CN1 10930405B discloses a tool damage detection method based on image region division. The tool damage region is divided into a worn region and a broken region. After extracting the two regions separately, the geometric features of the sum of the two regions are used as the criterion for judging the degree and type of tool damage. The worn region is extracted by pixel block segmentation and local threshold, while the broken region is extracted by data fitting and difference method. This method can diagnose the type and degree of tool damage, but the method mainly targets wear and breakage types, has a low degree of quantitative detection, and is based on manual parameter adjustment, resulting in low diagnostic accuracy. In addition, the model is difficult to adapt to the general task of tool damage detection. Chinese Patent Authorization No. CN1111225 87B discloses a tool damage detection method based on visual feature extraction. The method divides the tool damage area into a worn area and a broken area, extracts the two areas separately, and uses the geometric features of the sum of the two areas as the criterion for determining the degree and type of tool damage. The two areas are extracted separately through target fusion and differential methods, and the degree and type of damage are determined by geometric features. This method can determine the type and degree of tool damage, but the accuracy of the target fusion and differential methods alone is low, and it is difficult to cover damage in small areas. At the same time, the method adopted is based on artificial neural networks, which requires a lot of prior knowledge and manual parameter adjustment. The recognition speed and accuracy are insufficient, and it does not have good generalization performance, making it difficult to adapt to the needs of industrial implementation. In summary, the current tool damage detection method still has certain shortcomings. At the same time, the research on the quantitative evaluation of tool wear degree is not in-depth enough, which makes it difficult to adapt to the current industrial application status of tool wear detection with high precision and reliability. Therefore, there is an urgent need for a set of high-precision, high-efficiency, and high-reliability intelligent quantitative detection methods for tool damage to meet the needs of industrial implementation of tool wear detection and realize the processing status process monitoring of machine tool tools. Summary of the Invention
[0004] The purpose of this invention is to provide a Swin-Transformer-based intelligent quantitative detection method for tool damage, specifically for tool damage detection. This technology not only intelligently identifies the type of tool damage but also accurately quantifies the extent of the damage, significantly improving detection accuracy and reliability, thereby significantly reducing the industrial costs associated with tool damage.
[0005] The technical solution to achieve the purpose of the present invention is:
[0006] A Swin-Transformer-based intelligent quantitative detection method for tool damage includes the following steps: uniformly numbering and gray-scaling the acquired tool images, setting the tool damage type, which is defined as four types: chipping, chipping, cracking, and flank wear; then classifying and annotating the images according to the damage type, wherein the pixel annotation objects are: tool diameter, chipping damage width, and chipping damage width; and setting a scale between the actual diameter and the tool diameter pixel. After calculation, the width is added to the annotation file as a new loss function. The images and corresponding annotation files obtained in this way are randomly divided into training, validation, and test sets in a ratio of 7:1:2.
[0007] A Swin-Transformer-based intelligent quantitative detection model for tool damage is established. The model includes a PatchPartition partitioning module, a LinearEmbeding linear embedding layer, a PatchMerging merging layer, a LayerNorm layer, a global pooling layer, and a fully connected layer. Then, a SW-MSA shifted window multi-head self-attention module is added to the network. This module enhances the interaction between windows by introducing a displacement of the window position between consecutive layers. By allowing windows to overlap, the model can more effectively capture long-distance dependencies. At the same time, the attention calculation is limited to the local window to reduce the computational cost, making the model more efficient. Finally, the flow of contextual information between different spatial regions is promoted by moving the feature window, enabling the model to better understand the relationship between the object and its surrounding environment, thereby enhancing its performance. In addition, three loss functions are added, including the L2 loss of the average tool damage band width, the cross entropy function, and the masked binary cross entropy loss, to improve model performance.
[0008] Conduct model training and obtain the optimal detection model through measures such as hyperparameter adjustment and increasing the number of iterations.
[0009] Compared with the existing intelligent detection method for tool damage, this invention has the following significant advantages:
[0010] (1) The present invention mainly performs quantitative evaluation on the degree of tool wear. By training the average tool damage width and length, the network model can learn the characteristics of tool wear, thereby improving the accuracy of tool wear detection. Compared with similar methods, the quantitative degree information of tool damage type is added, which greatly improves the model detection accuracy.
[0011] (2) The present invention adopts a combination module of Patch Partition module, Linear Embedding layer and Patch Merging layer through network architecture setting, which expands the global receptive field and enhances the model's feature learning ability for tool loss types. Compared with similar model detection algorithms, the detection accuracy can be improved by more than 5%.
[0012] (3) This paper adds a SW-MSA shifted window multi-head self-attention module and introduces the displacement of window positions in consecutive layers to enhance the interaction between windows. By allowing windows to overlap, the model can more effectively capture long-distance dependencies. At the same time, the attention calculation is limited to the local window to reduce the computational cost, making the model more efficient. Finally, the flow of contextual information between different spatial regions is promoted by the movement of the feature window, enabling the model to better understand the relationship between the object and its surrounding environment, thereby enhancing its performance. Compared with other tool damage detection algorithms, this method improves accuracy while reducing computational costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] Figure 1 This is a flow chart of the intelligent quantitative detection method for tool damage based on the improved Swin-Transformer;
[0014] Figure 2 Figure 1 is an example diagram of tool damage types and annotations; Figure (a) is an example diagram of the tool circumscribed circle, Figure (b) is an example diagram of tool chipping and damage zone width, Figure (c) is an example diagram of tool breakage and damage zone width, Figure (d) is an example diagram of tool flank wear, and Figure (e) is an example diagram of tool cracks;
[0015] Figure 3 The network structure diagram of the intelligent quantitative detection method for tool damage based on the improved Swin-Transformer;
[0016] Figure 4 This is the network structure diagram of the SW-MSA shift window multi-head self-attention module; DETAILED DESCRIPTION
[0017] With reference to the accompanying drawings, the technical solutions in the embodiments of the present application will be described clearly and completely. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of the present application.
[0018] In order to realize intelligent quantitative detection of tool damage, the embodiment provides a tool damage intelligent quantitative detection model based on an improved Swin-Transformer, which specifically includes two parts of tool damage intelligent quantitative detection model establishment and model training.
[0019] The tool damage intelligent quantitative detection model establishment, as shown in Figure 3 , includes the following processes:
[0020] First, the training set is prepared, the image of the damaged tool is collected through the tool image acquisition system, then pixel-level labeling is performed, and L2 loss is used to calculate the damage bandwidth V AB , which is added to the labeling file as a new element, and the method is shown in formula 1, then the obtained original image is subjected to data enhancement, including: 1) horizontal + vertical flip; 2) 30°, 60°, 90° rotation; 3) adding mixed noise.
[0021] V AB = a || (A, B) || 2 (1)
[0022] Here, a represents the actual diameter to pixel scale, A and B represent the space vectors of the two endpoints of the line segment to be solved, respectively, wherein A (x1, y1), B (x2, y2), the distance of the space pixel point is calculated by the two norm, and the actual damage bandwidth is obtained by combining the scale.
[0023] Then the type of tool damage is determined, specifically as Figure 2As shown, the main definition is divided into four types: 1, chengbi: in the early process of cutting (cutting just started or after a short time cutting) after the tool is subjected to thermal shock and mechanical impact, small notches appear on the cutting edge; 2: broken: after a long time of cutting, the whole piece of the cutting edge is broken, and at this time the tool is probably difficult to continue cutting; 3: flank wear: during tool operation, the flank surface is worn by friction with the machined surface, and the wear surface is roughly parallel to the machined surface; 4: crack: after intermittent cutting of the hard alloy tool for a long time, cracks will be generated on the front and rear surfaces of the tool due to fatigue; The crack is divided into two types: one is mechanical fatigue crack, which is parallel to the cutting edge or in a network; The other is thermal crack, which is generally perpendicular or inclined to the cutting edge. Crack propagation usually causes damage to the cutting edge; according to the determined type, image labeling is carried out, and then according to the ratio of 7:2:1, it is randomly divided into training set, verification set and test set.
[0024] In order to adapt to the training model, all images are subjected to gray processing, and the input image size is uniformly set to 224x224.
[0025] Then the intelligent quantitative detection method network design of tool damage based on Swin-Transformer is carried out, as shown in Figure 3 As shown, specifically, the backbone network is divided into Patch Partition partition module, Linear Embeding linear embedding layer, Patch Merging merging layer, a Layer Norm layer, global pooling layer and full connection layer to obtain the final output, while SW-MSA shift window multi-head self-attention module is added after the continuous layer, which reduces the calculation complexity while increasing the feature learning; so as to ensure that the model learns more features while improving the detection accuracy; by increasing the loss function of different sources to control the learning efficiency of the model, the second is the classification cross entropy loss for tool wear type, as shown in formula 1:
[0026]
[0027] Here N is the number of samples, M is the number of tool wear categories, which is 4 here, y ic The symbol function (0 or 1) is represented, which is 1 if the real category of sample i is equal to c, otherwise 0; p icTo observe the prediction probability of sample i belonging to class c. The last loss function adopts a mask-based BCE (Binary Cross Entropy Loss) loss function, that is, a binary cross entropy loss function, which measures the difference between the predicted mask (generated by the model) and the ground truth mask (representing the actual mask required for segmentation). The goal is to minimize this difference to ensure that the predicted mask accurately reflects the true segmentation of the input image, as shown in equation 3, that is:
[0028]
[0029] where yi represents the groud truth mask, with a value of 1 indicating the presence of an object and a value of 0 indicating the absence of an object; represents the predicted mask, with a value between 0 and 1, indicating the probability of the presence of an object at each pixel. The sum is taken over all pixels in the mask. The goal is to minimize this loss value, which means that the model should generate a predicted mask that closely resembles the ground truth mask. The total loss is the sum of the above three losses, as shown in equation 4:
[0030]
[0031] The number of iterations is set to 6000, the training batch size is set to 4, the shift window size is set to 7x7, the channel depth is set to 128, the number of multi-head attention heads is set to 3, the learning rate is set to 0.1-0.0001, the momentum is set to 0.9, the weight decay is set to 0.0001, and the optimization algorithm is selected as the SGD algorithm. Model training is performed, and when the accuracy does not meet the expected requirements, fine-tuning is performed by increasing the number of iterations and adjusting the hyperparameters, and the expected model is finally obtained.
[0032] The above Swin-Transformer-based tool damage intelligent quantitative detection model has good performance and high training efficiency. Compared with similar detection networks, it can perform high-precision damage quantitative evaluation and is suitable for industrial application of machine tool detection. It also has detection capability for tool images with noise in actual machining environment.
[0033] The specific embodiments described above have detailed the technical solutions and beneficial effects of the present application. It should be understood that the above description is only the most preferred embodiment of the present application and is not intended to limit the present application. Any modifications, supplements, and equivalent replacements made within the principles of the present application should be included within the protection scope of the present application.
Claims
1. An intelligent quantitative detection method for tool damage based on Swin-Transformer, characterized in that: The following steps are involved: Step 1: Establish a tool damage image dataset based on Swin-Transformer; Step 1.1: Use an industrial camera to collect images of tool damage, perform data enhancement by flipping, rotating, and adding noise, and expand the number of data set samples; Step 1.2: Calculate the scale based on the actual diameter of the tool and the corresponding image pixel size; Step 1.3: Label the tool image samples, segment the tools with different damage types, and write the average damage band width as a new element into the labeling file; Step 1.3: Divide the labeled tool damage dataset into a training set, a validation set, and a test set; Step 2: Construct an intelligent quantitative detection network model for tool damage based on the improved Swin-Transformer; Step 2.1: Add a loss function based on the average width of the tool damage zone; Step 2.2: Divide the detection network model into the corresponding Patch Partition module, LinearEmbeding layer, Patch Merging layer and the corresponding prediction output layer; Step 2.3: Select the constructed dataset to test the network performance; Step 3: Construct the SW-MSA shift window multi-head self-attention module; Step 3.1: This module enhances the interaction between windows by introducing a shift in window positions between consecutive layers, allowing windows to overlap, thus enabling the model to capture long-range dependencies more effectively. Step 3.2: Reduce computational cost by limiting attention computation to a local window, making the model more efficient while maintaining its ability to capture relevant information. Step 3.3: Promote the flow of contextual information between different spatial regions by moving the feature window, so that the model can better understand the relationship between the object and its surrounding environment, thereby enhancing its performance; Step 4: Train the tool damage intelligent quantitative detection network model based on the improved Swin-Transformer in steps 2 and 3; Step 4.1: Set the number of training iterations and fine-tune hyperparameters; Step 4.2: Set the input image size and format to be uniform; Step 4.3: Set the input uniform moving window size, channel depth, and number of multi-head attention modules; Step 4.4: Add the corresponding loss function; Step 4.5: Use the instance segmentation network pre-trained weights for training; Step 5: Evaluate the model; Step 5.1: Evaluate the intelligent quantitative detection method for tool damage based on the improved Swin-Transformer trained in step 4 based on the following evaluation indicators: detection accuracy and mean damage band width error (mse); Step 5.2: Adjust the training parameters. If the highest detection accuracy is achieved, the optimal detection model is obtained; otherwise, repeat step 4.
1.
2. The intelligent quantitative detection method for tool damage based on the improved Swin-Transformer according to claim 1, characterized in that: In step 1.3, the number of tool damage types is set to i, i ≥ 2, i ∈ N, and the setting of i is based on the tool damage category.
3. The intelligent quantitative detection method for tool damage based on an improved Swin-Transformer according to claim 1, characterized in that: In step 2, the division of the network structure part should be carried out in the order of one Patch Partition module, one Linear Embeding layer, three Patch Merging layers, one Layer Norm layer, one global pooling layer, and a fully connected layer. The specific number of modules can be added or deleted according to the task requirements.
4. The intelligent quantitative detection method for tool damage based on an improved Swin-Transformer according to claim 1, characterized in that: In step 4.4, the loss functions are added, including the damage band width loss, cross-entropy loss, and masked binary cross-entropy loss. The loss functions are shown in Equation i: The total loss function is calculated by superimposing three loss functions; where α represents the actual diameter and pixel scale, A and B represent the spatial vectors of the two endpoints of the required line segment, N is the number of samples, M is the number of categories of tool wear, and y ic represents the symbolic function, p ic is the predicted probability that the observed sample i belongs to category c, y i represents the ground truth mask, Represents the prediction mask.
5. The intelligent quantitative detection method for tool damage based on improved Swin-Transformer according to claim 1, characterized in that: In step 4.1, train the tool damage segmentation model. The initial number of iterations is set to j, where 500 ≤ j ≤ 10000, j ∈ N, and it is selected according to the number of images in the training set, with no less than 500 images.
6. The intelligent quantitative detection method for tool damage based on improved Swin-Transformer according to claim 1, characterized in that: In step 4, for model training, the unified image format is set to a×a, and the image size is based on the processor memory, not less than 224×224.
7. The intelligent quantitative detection method for tool damage based on improved Swin-Transformer according to claim 1, characterized in that: In step 4, for model training, the training batch size is set to b, where 4 ≤ b < 256, b ∈ N; the value of b is based on the video card memory, and the larger the memory, the larger the value of b.
8. The intelligent quantitative detection method for tool damage based on improved Swin-Transformer according to claim 1, characterized in that: In step 4, for model training, the training window size is set to c, where |1 ≤ c < 16, c ∈ N; the value of c is based on the video card memory, and the larger the memory, the larger the value of c; the channel depth is set to d, where 96 < d < 1536, d ∈ N; the value of d is related to the number of network layers, and the more layers, the larger the value of d; the number of heads in the multi-head attention module is set to e, where 2 < e < 300, e ∈ N; the value of e is based on the target type, and the more types, the larger the value of e.
9. The intelligent quantitative detection method for tool damage based on improved Swin-Transformer according to claim 1, characterized in that: In step 4, for model training, the optimization algorithm used during training is set to the SGD algorithm.
Citation Information
Patent Citations
A Tool Damage Detection Method Based on Image Region Segmentation
CN110930405B
A tool damage detection method based on visual feature extraction
CN111122587B
Cutter damage intelligent detection and early warning method based on improved YOLOX
CN116309458A
Cutter damage intelligent detection method based on self-distillation
CN116993711A
Cutter damage target detection method based on improved RTMDet
CN117197427A