Kettle defect semantic segmentation detection system and method based on UMamba
By introducing the state space model and Kalman filter neural network into the UMamba architecture, the problem of insufficient accuracy of CNN and Transformer in the detection of defects on the inner wall of the electric kettle is solved, and higher semantic segmentation accuracy is achieved.
Patent Information
- Application Number
- CN202410634118.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-21
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2044-05-21
AI Technical Summary
Existing CNN and Transformer architectures have limitations when dealing with large-scale or long-distance dependencies, resulting in semantic segmentation accuracy that cannot meet industrial requirements in the detection of defects on the inner wall of electric kettles.
A UMamba-based kettle defect semantic segmentation detection system is adopted, including an image preprocessing module, a Vision-Swin-UMamba encoder and a Vision-Swin-UMamba decoder. By introducing a state space model and a Kalman filter neural network into the visual Mamba block, along the The image patches are unfolded in the four scanning directions to create different sequences and processed through a state space model to form a complete 2D feature map.
The accuracy of semantic separation in electric kettle defect detection is improved by adaptive spatio-temporal graph structure generation and upgrading, which smoothly adapts to the context based on the state space model.
Smart Images

Figure CN118396973B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to a kettle defect semantic segmentation detection system and method based on UMamba. Background Art
[0002] In recent years, with the continuous development of deep learning technology, many innovative models and methods have emerged in the field of visual representation learning, bringing new possibilities for image processing tasks. In the exploration of this field, convolutional neural network (CNN) has always been the basic model, and has achieved breakthrough results in image classification, object detection and semantic segmentation. It successfully captures spatial correlation through local receptive field and parameter sharing mechanism. However, with the increase of task complexity and the increase of demand for global context understanding, CNN has revealed certain limitations when dealing with large-scale or long-distance dependencies.
[0003] To overcome these limitations, the Transformer architecture was born. The Transformer uses a multi-head attention mechanism, which is a problem of calculating attention based on a two-dimensional matrix. It takes up too much memory and has high time complexity. The Transformer assigns a position code to each part of the input vector, resulting in lower efficiency and lower accuracy as the sentence becomes longer.
[0004] In the industrial inspection of the inner wall of electric kettles, which have defects such as scratches and black lines, the accuracy of traditional semantic segmentation cannot meet industrial requirements well. Summary of the invention
[0005] In order to overcome the defects of the prior art, an object of the present invention is to provide a kettle defect semantic segmentation detection system based on UMamba to solve the above-mentioned problems.
[0006] In order to overcome the defects of the prior art, another object of the present invention is to provide a kettle defect semantic segmentation detection method based on UMamba to solve the above-mentioned problems.
[0007] The technical solution adopted by the present invention to solve the technical problem is: a kettle defect semantic segmentation detection system based on UMamba, including an image preprocessing module, a Vision-Swin-UMamba encoder and a Vision-Swin-UMamba decoder;
[0008] The image preprocessing module is used to obtain the images needed for the kettle liner defects and obtain image blocks after preprocessing;
[0009] The Vision-Swin-UMamba encoder is used to downsample the image block to obtain downsampled output features;
[0010] The Vision-Swin-UMamba decoder is used to upsample the downsampled output features;
[0011] The Vision-Swin-UMamba encoder and the Vision-Swin-UMamba decoder are obtained by introducing a state space model and a Kalman filter neural network in the vision Mamba block, so that the Vision-Swin-UMamba encoder expands the image blocks along four scanning directions and creates four different sequences, so that the Vision-Swin-UMamba decoder merges the downsampled output features to form a complete 2D feature map of the defect result picture.
[0012] Preferably, the Vision-Swin-UMamba encoder comprises five stage processors connected in sequence;
[0013] The first stage processor includes a convolutional layer for two downsampling and 2D instance normalization after the convolutional layer;
[0014] The second stage processor keeps the feature resolution of the image block at 1 through a block embedding layer with a block size of 2×2;
[0015] The number of visual state space blocks of the second stage processor to the fifth stage processor is 2.
[0016] Specifically, the core of the first stage processor is 7 / 7, the padding size is 3, and the stride is 2.
[0017] Optionally, the feature size of each stage processor output is twice the feature size of the previous stage processor output, so that the number of channels of the five stage processors are 48, 96, 192, 384 and 768 respectively.
[0018] It is worth noting that the formula used by the Vision-Swin-UMamba encoder to downsample the image block to obtain the downsampled output feature is: ,v), ;
[0019] in are four different scanning directions, expand is the image block expansion of the state space model, S6 is the selective scanning space state sequence model, is the input feature of the image block, is the down-sampled output feature.
[0020] Specifically, the formula used by the Vision-Swin-UMamba decoder to upsample the downsampled output features is: ;
[0021] in are four different scanning directions, merge is the image block merging of the state space model, 1, 2, 3 and 4 is the down-sampled output feature, is the upsampled output feature.
[0022] Preferably, the image preprocessing module is used to obtain images required for the defects of the inner liner of the kettle, and uniformly scale the image size and object frame to a fixed size and normalize the image to obtain an image block.
[0023] A kettle defect semantic segmentation detection method based on UMamba, comprising the following steps:
[0024] S1: Obtain the image needed for the inner liner defect of the kettle and obtain the image block after preprocessing;
[0025] S2: Use Vision-Swin-UMamba encoder to downsample the image block to obtain the downsampled output features;
[0026] S3: Upsample the downsampled output features using the Vision-Swin-UMamba decoder;
[0027] The Vision-Swin-UMamba encoder and the Vision-Swin-UMamba decoder are obtained by introducing the state space model and the Kalman filter neural network in the vision Mamba block, so that the Vision-Swin-UMamba encoder expands the image blocks along the four scanning directions to create four different sequences. Subsequently, each feature sequence will be processed by the state space model, and the Vision-Swin-UMamba decoder will merge the downsampled output features to form a complete 2D feature map of the defect result picture.
[0028] The beneficial effects of the present invention are as follows: in the UMamba-based kettle defect semantic segmentation detection system, the existing Vision-Transformer architecture is improved, and the Vision Mamba Block is used to make changes on the Swin-UMamba architecture. At the same time, a layer of Kalman filter neural network is introduced for adaptive spatiotemporal graph structure generation and upgrading, which smoothly adapts to the context based on the state space model, thereby improving the accuracy of semantic segmentation in electric kettle defect detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 It is a system block diagram of a kettle defect semantic segmentation detection system based on UMamba in one embodiment of the present invention;
[0030] Figure 2 A schematic diagram of a Vision-Swin-UMamba framework in one embodiment of the present invention;
[0031] Figure 3 is a schematic diagram of a visual mamba block in one embodiment of the present invention;
[0032] Figure 4 This is a flowchart of a kettle defect semantic segmentation detection method based on UMamba in one embodiment of the present invention. DETAILED DESCRIPTION
[0033] The specific embodiments of the present invention are further described below in conjunction with the accompanying drawings. It should be noted that the description of these embodiments is used to help understand the present invention, but does not constitute a limitation of the present invention. In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0034] like Figure 1-4 As shown, a kettle defect semantic segmentation detection system based on UMamba includes an image preprocessing module, a Vision-Swin-UMamba encoder and a Vision-Swin-UMamba decoder;
[0035] The image preprocessing module is used to obtain the images needed for the kettle liner defects and obtain image blocks after preprocessing;
[0036] The Vision-Swin-UMamba encoder is used to downsample the image block to obtain downsampled output features;
[0037] The Vision-Swin-UMamba decoder is used to upsample the downsampled output features;
[0038] The Vision-Swin-UMamba encoder and the Vision-Swin-UMamba decoder are obtained by introducing the state space model and the Kalman filter neural network in the vision Mamba block, so that the Vision-Swin-UMamba encoder expands the image blocks along the four scanning directions to create four different sequences. Subsequently, each feature sequence will be processed by the state space model so that the Vision-Swin-UMamba decoder merges the downsampled output features to form a complete 2D feature map of the defect result picture.
[0039] In the UMamba-based kettle defect semantic segmentation detection system, the existing Vision-Transformer architecture is improved, and the Vision Mamba Block is used to make changes on the Swin-UMamba architecture. At the same time, a layer of Kalman filter neural network is introduced for adaptive spatiotemporal graph structure generation and upgrading, which smoothly adapts to the context based on the state space model, thereby improving the accuracy of semantic segmentation in electric kettle defect detection.
[0040] The Vision-Swin-UMamba encoder is pre-trained based on ImageNet. Figure 3 As shown, in the visual Mamba block, each building block contains two consecutive residual blocks, and the residual block contains a normal convolution layer. After instance normalization (IN) and leaky RELU (RELU is an activation function), the image features with the shape of (B, C, H, W, D) are flattened and transposed to (B, L, C), where L = HWD, that is, L is obtained by the Hadamard product and convolution of the matrices of L, W and D. The image features enter the Mamba block containing two parallel branches. In the first branch, the image features are expanded to (B, 2L, C) through a linear layer, followed by a 1D convolution layer, a SILU activation function, and together with a state space model layer. In the second branch, the image features are expanded to (B, 2L, C), with a linear layer, followed by a SILU activation function. After that, the image features from the two branches are merged by Hadamard products. Finally, the image features are projected back to the original shape (B, L, C), and then reshaped and transposed to (B, C, H, W, D).
[0041] Take (B, C, D, H, W) as an example, it can be understood as shape dimension and data dimension. Generally speaking, B, H and W are all considered as shapes. Initially, it can be regarded as B pictures of H and W, and then the feature of each pixel of the picture is composed of a vector of length C*D. If this vector is divided into D parts, the length of each part is C. Because each pixel has D parts, the picture can be divided into D pictures, and the feature length of each pixel of each picture is C. Now it becomes B batches of data, each batch of D pictures, and the number of channels of the picture is C. At this time, the data is stored in the number of channels C, that is, each data is a vector of length C, and the dimension C becomes the data dimension, and the others are shape dimensions. If the previous division is changed to C vectors of length D, similarly, it becomes B batches of data, each batch of C pictures, and the number of channels of the picture is D. Note that the meaning of the channel here is far different from the original. All these operations are actually derived from the fact that data storage is continuous. These data are stored in continuous memory space, which is equivalent to an extremely long vector. The shape dimension is to iteratively segment the vector. Here, the entire data is first divided into B batches, then each batch is divided into H parts, and each part is further divided into W parts. After three iterative divisions, the data length obtained is C*D. If B, H and W are regarded as shapes, it is B H*W pictures with C*D channels.
[0042] This scheme follows the commonly used U-shaped architecture with dense skip connections to build the Vision-Swin-UMamba decoder. The U-shaped architecture uses skip connections to recover low-level details and adopts an encoder-decoder structure to extract high-level information. To enhance the native upsampling block in UMamba, two modifications are introduced: an additional convolutional block with a residual connection to handle skip connection features; and a segmentation head is added at each scale for deep supervision. Deep supervision is a technique that adds an auxiliary classifier to some intermediate hidden layers of a deep neural network as a network branch to supervise the backbone network, which is used to solve the problems of gradient vanishing and slow convergence in deep neural network training.
[0043] The structure of the Vision-Swin-UMamba decoder upsampling block is as follows Figure 2 As shown, the visual mamba block and image block expansion in the figure. Given the skip connection feature from stage l upsampling fast and features from the previous upsampling block , the output feature of the lth upsampling block and the segmentation map of stage l It can be expressed as follows:
[0044] , ( ))), ), = );
[0045] in, ) represents the feature concatenation operation, ) represents the transposed convolution at stage l, ) represents a segmentation head with a 1x1 convolution, which is used to project features from dimension d to the number of categories K. and They represent the height and width of the feature map of the lth stage respectively. ( )and ) are two convolutional blocks with residual connections in the first stage, each ( )and ) are composed of two convolutional layers with LeakyReLU activation. In addition to the skip connection between the encoding stage and the upsampling block, this scheme also adds an additional skip connection from the input, using Res( )-Cat( )-Res( ) operation. Finally, this scheme uses a 1x1 convolution to obtain the final segmented output.
[0046] It is worth noting that the Vision-Swin-UMamba encoder includes five stage processors connected in sequence;
[0047] The first stage processor is the STEM stage; the first stage processor includes a convolution layer for two downsampling and uses 2D instance normalization after the convolution layer;
[0048] The second stage processor keeps the feature resolution of the image block at 1 through a block embedding layer with a block size of 2×2;
[0049] The number of visual state space blocks of the second stage processor to the fifth stage processor is 2.
[0050] This strategy aims to preserve low-level details, which is very important for defect detection image segmentation. Each stage processor performs 2 downsampling. Each stage processor consists of an image patch merging layer for 2 downsampling and several visual Mamba blocks for high-level feature extraction. In this embodiment, the visual Mamba block and patch merging layer are initialized using weights from ImageNet pre-training.
[0051] Preferably, the core of the first stage processor is 7 / 7, the padding size is 3, and the step size is 2.
[0052] Optionally, the feature size of each stage processor output is twice the feature size of the previous stage processor output, so that the number of channels of the five stage processors is 48, 96, 192, 384 and 768 respectively. Figure 2 As shown, the input includes image height H, image width W and number of channels C.
[0053] Specifically, the formula used by the Vision-Swin-UMamba encoder to downsample the image block to obtain the downsampled output feature is: ,v), ;
[0054] in are four different scanning directions, expand is the image block expansion of the state space model, S6 is the selective scanning space state sequence model, is the input feature of the image block, is the down-sampled output feature.
[0055] The selective scan space state sequence model (S6) in the equation is the core state space model operator, which enables each element in a 1D array (e.g., a text sequence) to interact with any previously scanned sample through a compressed hidden state. The Kalman filter neural network is used for adaptive spatiotemporal graph structure generation and upgrading, which smoothly adapts to the Figure 3 The context of the state-space model shown in the figure ensures that the graph structure is updated synchronously with the current state of the space-time graph system. The space-time graph (STG) data is dynamic, heterogeneous and non-stationary. In order to use the Kalman filter neural network to generate the graph adjacency matrix at each time step , the modeling process includes the state equation calculation: let represents the graph adjacency matrix at time t, which indicates the current state of the space-time graph system. The state equation is defined as ,in is the state transition matrix, reflecting the graph adjacency matrix from t-1 to t, represents the graph adjacency matrix at time t-1, represents the noise of the Kalman filter switching process. By iteratively applying this state equation to the Kalman filter, the graph adjacency matrix can be dynamically estimated at each moment. , adaptively capturing the evolving dynamics of spatiotemporal graph networks. In practice, we adopt a neural network-based approach called a deep Kalman filter (DKF) to automatically learn the state transition matrix. Specifically, we adopt a gated recurrent unit (GRU) network as the structure of the deep Kalman filter. A deep Kalman filter based on a gated recurrent unit is used to learn nonlinear mappings for state transitions and observation generation. The state transition matrix is modeled by the internal process of the gated recurrent unit to capture the nonlinear relationship between states and predict the state at the next moment. This process enables the system to automatically learn the dynamics of state transitions and observation generation from data without manual settings.
[0056] It is worth noting that the formula used by the Vision-Swin-UMamba decoder to upsample the downsampled output features is: ;
[0057] in are four different scanning directions, merge is the image block merging of the state space model, 1, 2, 3 and 4 is the down-sampled output feature, It is the up-sampled output feature, that is, the defect result picture of the complete 2D feature map is formed.
[0058] Preferably, the image preprocessing module is used to obtain the images needed for the defects of the inner liner of the kettle, and uniformly scale the image size and object frame to a fixed size and normalize the image to obtain an image block. In addition, during the training stage, random horizontal flipping, random translation and other data enhancement methods are performed on the image with random probability to prevent overfitting during data training.
[0059] Specifically, Figure 4 As shown, a kettle defect semantic segmentation detection method based on UMamba includes the following steps:
[0060] S1: Obtain the image needed for the inner liner defect of the kettle and obtain the image block after preprocessing;
[0061] S2: Use Vision-Swin-UMamba encoder to downsample the image block to obtain the downsampled output features;
[0062] S3: Upsample the downsampled output features using the Vision-Swin-UMamba decoder;
[0063] The Vision-Swin-UMamba encoder and the Vision-Swin-UMamba decoder are obtained by introducing the state space model and the Kalman filter neural network in the vision Mamba block, so that the Vision-Swin-UMamba encoder expands the image blocks along the four scanning directions to create four different sequences. Subsequently, each feature sequence will be processed by the state space model, and the Vision-Swin-UMamba decoder will merge the downsampled output features to form a complete 2D feature map of the defect result picture.
[0064] This paper provides a multi-scale method for detecting defects in the inner liner of a kettle based on UMamba. The overall architecture of Vison-Swin-UMamba is composed of three parts: an encoder based on Mamba, which is pre-trained on a large-scale dataset (i.e., ImageNet) to extract features at different scales; a decoder with multiple upsampling blocks to predict segmentation results; and a skip connection to bridge the gap between low-level details and high-level semantics.
[0065] The embodiments of the present invention are described in detail above with reference to the accompanying drawings, but the present invention is not limited to the described embodiments. For those skilled in the art, various changes, modifications, substitutions and variations of these embodiments are made without departing from the principles and spirit of the present invention, and still fall within the scope of protection of the present invention.
Claims
1. A kettle defect semantic segmentation detection system based on UMamba, characterized by: Includes image preprocessing module, Vision-Swin-UMamba encoder and Vision-Swin-UMamba decoder; The image preprocessing module is used to obtain the images needed for the defects of the inner liner of the kettle, and uniformly scale the image size and object frame to a fixed size and perform normalization processing on the image to obtain an image block; The Vision-Swin-UMamba encoder is used to downsample the image block to obtain downsampled output features; The Vision-Swin-UMamba decoder is used to upsample the downsampled output features; The Vision-Swin-UMamba encoder and the Vision-Swin-UMamba decoder are obtained by introducing a state space model and a Kalman filter neural network in the vision Mamba block, so that the Vision-Swin-UMamba encoder expands the image blocks along four scanning directions and creates four different sequences, so that the Vision-Swin-UMamba decoder merges the downsampled output features to form a complete 2D feature map defect result picture; The Vision-Swin-UMamba decoder is constructed using a U-shaped architecture with dense skip connections, which uses skip connections to recover low-level details and adopts an encoder-decoder structure to extract high-level information; The Vision-Swin-UMamba decoder upsampling block is extended with the Vision Mamba block and the image block, given the skip connection features from the upsampling fast in stage l and features from the previous upsampling block , the output feature of the lth upsampling block and the segmentation map of stage l The expression is: , ( ))), ), = ); in, ) represents the feature concatenation operation, ) represents the transposed convolution at stage l, ) represents a segmentation head with a 1x1 convolution, which is used to project features from dimension d to the number of categories K; and Respectively represent the height and width of the feature map of the lth stage; ( )and ) are two convolutional blocks with residual connections in the first stage, each ( )and ) are composed of two convolutional layers with LeakyReLU activation; The Vision-Swin-UMamba encoder includes five stage processors connected in sequence; the first stage processor includes a convolution layer for two downsamplings, and 2D instance normalization is adopted after the convolution layer; the second stage processor maintains the feature resolution of the image block at 1 through a block embedding layer with a block size of 2×2; the number of visual state space blocks of the second stage processor to the fifth stage processor is 2; each stage processor performs two downsamplings, and each stage processor consists of an image block merging layer for two downsamplings and a plurality of visual Mamba blocks for high-level feature extraction, wherein the visual Mamba block and the patch merging layer are initialized by weights pre-trained by ImageNet; The first-stage processor has a core size of 7 / 7, a padding size of 3, and a stride of 2; The feature size of each stage processor output is twice the feature size of the previous stage processor output, so that the number of channels of the five stage processors are 48, 96, 192, 384 and 768 respectively; The formula used by the Vision-Swin-UMamba encoder to downsample the image block to obtain the downsampled output features is: ,v), ;in are four different scanning directions, expand is the image block expansion of the state space model, S6 is the selective scanning space state sequence model, is the input feature of the image block, is the down-sampled output feature; The formula used by the Vision-Swin-UMamba decoder to upsample the downsampled output features is: ;in are four different scanning directions, merge is the image block merging of the state space model, 1, 2, 3 and 4 is the down-sampled output feature, is the upsampled output feature.
2. A kettle defect semantic segmentation detection method based on UMamba, characterized in that: The following steps are involved: S1: Obtain the image needed for the inner liner defect of the kettle, and uniformly scale the image size and object frame to a fixed size and normalize the image to obtain an image block; S2: Use Vision-Swin-UMamba encoder to downsample the image block to obtain the downsampled output features; S3: Upsample the downsampled output features using the Vision-Swin-UMamba decoder; The Vision-Swin-UMamba encoder and the Vision-Swin-UMamba decoder are obtained by introducing the state space model and the Kalman filter neural network in the vision Mamba block, so that the Vision-Swin-UMamba encoder expands the image block along the four scanning directions to create four different sequences. Subsequently, each feature sequence will be processed by the state space model, and the Vision-Swin-UMamba decoder will merge the downsampled output features to form a complete 2D feature map defect result picture; The Vision-Swin-UMamba decoder is constructed using a U-shaped architecture with dense skip connections, which uses skip connections to recover low-level details and adopts an encoder-decoder structure to extract high-level information; The Vision-Swin-UMamba decoder upsampling block is extended with the Vision Mamba block and the image block, given the skip connection features from the upsampling fast in stage l and features from the previous upsampling block , the output feature of the lth upsampling block and the segmentation map of stage l The expression is: , ( ))), ), = ); in, ) represents the feature concatenation operation, ) represents the transposed convolution at stage l, ) represents a segmentation head with a 1x1 convolution, which is used to project features from dimension d to the number of categories K; and Respectively represent the height and width of the feature map of the lth stage; ( )and ) are two convolutional blocks with residual connections in the first stage, each ( )and ) are composed of two convolutional layers with LeakyReLU activation; The Vision-Swin-UMamba encoder includes five stage processors connected in sequence; the first stage processor includes a convolution layer for two downsamplings, and 2D instance normalization is adopted after the convolution layer; the second stage processor maintains the feature resolution of the image block at 1 through a block embedding layer with a block size of 2×2; the number of visual state space blocks of the second stage processor to the fifth stage processor is 2; each stage processor performs two downsamplings, and each stage processor consists of an image block merging layer for two downsamplings and a plurality of visual Mamba blocks for high-level feature extraction, wherein the visual Mamba block and the patch merging layer are initialized by weights pre-trained by ImageNet; The first-stage processor has a core size of 7 / 7, a padding size of 3, and a stride of 2; The feature size of each stage processor output is twice the feature size of the previous stage processor output, so that the number of channels of the five stage processors are 48, 96, 192, 384 and 768 respectively; The Vision-Swin-UMamba encoder downsamples the image block to obtain the downsampled output feature formula: ,v), ;in are four different scanning directions, expand is the image block expansion of the state space model, S6 is the selective scanning space state sequence model, is the input feature of the image block, is the down-sampled output feature; The formula for upsampling the downsampled output features by the Vision-Swin-UMamba decoder is: ;in are four different scanning directions, merge is the image block merging of the state space model, 1, 2, 3 and 4 is the down-sampled output feature, is the upsampled output feature.
