Vehicle image enhancement method and system based on CNN and Transformer

By integrating the features of CNN and Transformer in vehicle image enhancement, and using high-frequency enhanced residual block, rectangular window attention block and hybrid fusion block, the problem of poor quality of vehicle images in complex environments is solved and better Image representation and recognition effects.

CN118097321BActive Publication Date: 2024-09-27UNIV OF JINAN
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410524655.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-29
Publication Date
2024-09-27
Estimated Expiration
2044-04-29

AI Technical Summary

Technical Problem

When processing vehicle images, the existing technology is difficult to effectively improve the image quality, especially at night, rainy days or under complex light conditions, resulting in blurred or unclear image details, which affects the accuracy of vehicle identification and analysis.

Method used

Using a vehicle image enhancement method based on CNN and Transformer, by building a feature modulation Transformer module, integrating high-frequency enhancement residual blocks, rectangular window attention blocks and hybrid fusion blocks, capturing high-frequency information and long-distance dependencies, and optimizing the output to improve Image representation quality.

Benefits of technology

Significantly improves the quality of vehicle images under different environmental conditions, ensures that vehicle details are clearly visible, and improves the accuracy of vehicle identification and analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118097321B
    Figure CN118097321B
Patent Text Reader

Abstract

The present invention proposes a vehicle image enhancement method and system based on CNN and Transformer, and relates to the field of computer vision. The present invention proposes a feature modulation Transformer module, which is composed of L cross-refining fusion blocks, each of which is composed of a high-frequency enhancement residual block, a rectangular window attention block, and a hybrid fusion block. Among them, the high-frequency enhancement residual block is used to extract high-frequency features from input features, and the rectangular window attention block is used to capture the long-distance dependency of the input features. Then, the outputs of the high-frequency enhancement residual block and the rectangular window attention block are integrated through the hybrid fusion block. Finally, the global features are cross-refined to obtain the best effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to computer vision, and in particular to a vehicle image enhancement method and system based on CNN and Transformer. Background Art

[0002] Vehicle image enhancement is aimed at improving the quality and visualization of vehicle images. With the development and popularization of vehicle visual recognition technology, the demand for vehicle image enhancement has become increasingly prominent, and vehicle images need to have good recognition capabilities under different environmental conditions. For example, vehicle images taken at night, in the rain, or under complex lighting conditions may be affected by insufficient lighting, raindrops, or fog, resulting in blurred or unclear image details. Therefore, vehicle image enhancement needs to solve the problem of improving image quality under various lighting and climatic conditions to ensure that the vehicle details in the image can be clearly seen, which is conducive to accurate identification and analysis.

[0003] In recent years, deep learning has experienced significant growth and has achieved success in enhancing image resolution. Previous research works introduced residuals and dense connections to facilitate the stacking of deep convolutional neural networks (CNNs). There are also research works that use attention mechanisms to improve performance. It is worth noting that the emergence of the Transformer architecture has demonstrated its effectiveness in capturing long-distance dependencies and achieving state-of-the-art performance. These works mainly focus on designing Transformer blocks to obtain global information, while ignoring the possibility of further improving performance, especially high-frequency priors. Compared with CNN, Transformer shows limited ability in building high-frequency representations. To address this problem, a feature modulation Transformer module is proposed, which integrates the advantages of the two structures to capture high-frequency information, extract long-distance dependencies, and optimize the output for better representation. Summary of the invention

[0004] The present invention provides a vehicle image enhancement method and system based on CNN and Transformer, aiming to integrate the advantages of CNN and Transformer to capture high-frequency information, extract long-distance dependencies and optimize output to obtain better representation.

[0005] The present invention integrates the advantages of CNN and Transformer, and provides a vehicle image enhancement method based on CNN and Transformer, comprising the following steps:

[0006] S1. Obtain the video from the vehicle monitoring camera, extract frames from the camera every second, and obtain the image of the vehicle to be detected;

[0007] S2. Construct a feature modulation Transformer module and input image features into the module. The image features learn deep features through L cross-refinement fusion blocks. The cross-refinement fusion block consists of a high-frequency enhancement residual block that extracts high-frequency information, a rectangular window attention block that captures global information, and a hybrid fusion block that refines the global representation. After the last cross-refinement fusion block, a 3×3 convolutional layer is used to aggregate features, and a residual connection is established between its output and the image features to facilitate training of image features and output;

[0008] S3. Build a vehicle image enhancement model, which consists of a shallow feature extraction module, a feature modulation Transformer module, and a reconstruction module;

[0009] S4. Input the vehicle image into the vehicle image enhancement model to obtain a super-resolution vehicle image.

[0010] Preferably:

[0011] S21, high-frequency enhancement residual block consists of local feature extraction branch and high-frequency enhancement branch. If the input image feature is ,Will Divide into two parts , and then processed by two branches respectively. For the local feature extraction branch, a 3×3 convolution layer and GELU activation function are used to extract local high-frequency features , represents a 3×3 convolutional layer, Represents the GELU activation function. For the high-frequency enhancement branch, the maximum pooling layer is used to extract the input features. The high-frequency information is extracted from the kernel, and then a 1×1 layer and GELU activation function are used to enhance the high-frequency features. , MaxPooling() represents the maximum pooling layer, and then the outputs of the two branches are connected. The connected result is completely integrated through the 1×1 convolution layer. At the same time, in order to enable the network to benefit from multi-scale information and maintain the stability of training, residual connections are introduced. , Concat() represents the connection operation;

[0012] S22. For the rectangular window attention block, given an input , which is divided into A rectangular window, where rh and rw refer to the height and width of the rectangular window. In order to capture information in different axes, two types of rectangular windows are used: horizontal window and vertical window. Divide Two parts, and calculate the self-attention value respectively, then connect the two results and use multi-layer perceptron for feature conversion. The whole process can be expressed as , V -Rwin and H-Rwin represent vertical and horizontal rectangular window attention, and MLP represents multi-layer perception operation;

[0013] S23, hybrid fusion block In order to better integrate the advantages of high-frequency enhancement residual block and rectangular window attention block, the output of high-frequency enhancement residual block First, a 1×1 convolutional layer is used to reduce the number of channels of the feature map, and then a 3×3 deep convolutional layer is used to generate high-frequency queries. For the output of the rectangular window attention block First, the features are normalized through the batch normalization layer, and then the Key and Value are obtained using the same operation as the Query. The self-attention calculation is performed on the Query, Key, and Value, and the calculation results are compared with Perform residual connection and get output The whole process can be described as , Inter-Atten represents self-attention calculation, The deep features are learned as the input of the next cross-refine fusion block. After the last cross-refine fusion block, a 3×3 convolutional layer is used to aggregate the features and a residual connection is established between its output and the image features.

[0014] The present invention also provides a vehicle image enhancement system based on CNN and Transformer, which is characterized in that it includes a vehicle image data acquisition module and a vehicle image enhancement module. The vehicle image to be detected is collected through the vehicle image data acquisition module. The vehicle image enhancement module has a built-in vehicle image enhancement model, and the model is composed of a shallow feature extraction module, a feature modulation Transformer module, and a reconstruction module. For the feature modulation Transformer module, image features are input to the module, and the image features learn deep image features through L cross-refined fusion blocks. The cross-refined fusion block is composed of three types of blocks: a high-frequency enhanced residual block, a rectangular window attention block, and a mixed fusion block. After the last cross-refined fusion block, a 3×3 convolutional layer is used to aggregate features, and a residual connection is established between its output and the shallow features, so as to facilitate the training of image features and output the features.

[0015] Compared with the prior art, the present invention has the following beneficial effects:

[0016] The technical solution provided by the present invention first uses a high-frequency enhancement residual block to extract high-frequency features from the input features, uses a rectangular window attention block to capture the long-distance dependencies of the input features, and then integrates the outputs of the high-frequency enhancement residual block and the rectangular window attention block through a hybrid fusion block, and finally cross-refines the global features to obtain the best effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 is a flow chart of enhanced vehicle image provided by the present invention;

[0018] Figure 2 It is a structural diagram of the feature modulation Transformer provided by the present invention;

[0019] Figure 3 This is an example diagram of the high-frequency enhanced residual block, rectangular window attention block and hybrid fusion block provided by the present invention. DETAILED DESCRIPTION

[0020] The present invention aims to propose a vehicle image enhancement method and system based on CNN and Transformer. Firstly, a high-frequency enhancement residual block is used to extract high-frequency features from input features, and a rectangular window attention block is used to capture the long-distance dependencies of the input features. Then, the outputs of the high-frequency enhancement residual block and the rectangular window attention block are integrated through a hybrid fusion block. Finally, the global features are cross-refined to obtain the best effect.

[0021] See also Figure 1 As shown, the vehicle image enhancement method based on CNN and Transformer in the embodiment of the present application:

[0022] S1. Obtain the video from the vehicle monitoring camera, extract frames from the camera every second, and obtain the image of the vehicle to be detected;

[0023] S2. Construct a feature modulation Transformer module and input image features into the module. The image features learn deep features through L cross-refinement fusion blocks. The cross-refinement fusion block consists of a high-frequency enhancement residual block that extracts high-frequency information, a rectangular window attention block that captures global information, and a hybrid fusion block that refines the global representation. After the last cross-refinement fusion block, a 3×3 convolutional layer is used to aggregate features, and a residual connection is established between its output and the image features to facilitate training of image features and output;

[0024] S3. Build a vehicle image enhancement model, which consists of a shallow feature extraction module, a feature modulation Transformer module, and a reconstruction module;

[0025] S4. Input the vehicle image into the vehicle image enhancement model to obtain a super-resolution vehicle image.

[0026] Further, if Figure 2 As shown in the figure, after obtaining the vehicle image from the camera, the image is input into the shallow feature extraction module to obtain the shallow features of the image, and the image features are input into the feature modulation Transformer module. The feature modulation Transformer module sets 3 cross-refinement fusion blocks, each of which consists of 1 high-frequency enhanced residual block and 2 rectangular window attention blocks.

[0027] Further, if Figure 3 As shown, the image features are input into the high-frequency enhancement residual block and the rectangular window attention block respectively. In order to obtain two rectangular windows, we set the rectangular window size to [4,16] and [16,4] [rh,rw] respectively. The hybrid fusion block is based on the output of the high-frequency enhancement residual block. , first use a 1×1 convolution layer to reduce the dimension, and then use a 3×3 deep convolution layer to generate the query. For the output of the rectangular window attention block First, the features are normalized through the batch normalization layer, and then the Key and Value are obtained using the same operation as the Query. Then, the self-attention calculation is performed on the Query, Key, and Value, and the calculation results are compared with Residual connections are made to further train image features. The image features are passed through three cross-refinement fusion blocks to learn deep features. After the last cross-refinement fusion block, a 3×3 convolutional layer is used to aggregate features, and a residual connection is established between its output and the shallow features to facilitate the training of image features. The reconstruction module first uses a 3×3 convolutional layer to aggregate features, and then uses a shuffle layer to obtain the final super-resolution output image.

[0028] further,

[0029] S21, high-frequency enhancement residual block consists of local feature extraction branch and high-frequency enhancement branch. If the input image feature is ,Will Divide into two parts , and then processed by two branches respectively. For the local feature extraction branch, a 3×3 convolution layer and GELU activation function are used to extract local high-frequency features , represents a 3×3 convolutional layer, Represents the GELU activation function. For the high-frequency enhancement branch, the maximum pooling layer is used to extract the input features. The high-frequency information is extracted from the kernel, and then a 1×1 layer and GELU activation function are used to enhance the high-frequency features. , MaxPooling() represents the maximum pooling layer, and then the outputs of the two branches are connected. The connected result is completely integrated through the 1×1 convolution layer. At the same time, in order to enable the network to benefit from multi-scale information and maintain the stability of training, residual connections are introduced. , Concat() represents the connection operation;

[0030] S22. For the rectangular window attention block, given an input , which is divided into A rectangular window, where rh and rw refer to the height and width of the rectangular window. In order to capture information in different axes, two types of rectangular windows are used: horizontal window and vertical window. Divide Two parts, and calculate the self-attention value respectively, then connect the two results and use multi-layer perceptron for feature conversion. The whole process can be expressed as , V -Rwin and H-Rwin represent vertical and horizontal rectangular window attention, and MLP represents multi-layer perception operation;

[0031] S23, hybrid fusion block In order to better integrate the advantages of high-frequency enhancement residual block and rectangular window attention block, the output of high-frequency enhancement residual block First, a 1×1 convolutional layer is used to reduce the number of channels of the feature map, and then a 3×3 deep convolutional layer is used to generate high-frequency queries. For the output of the rectangular window attention block First, the features are normalized through the batch normalization layer, and then the Key and Value are obtained using the same operation as the Query. The self-attention calculation is performed on the Query, Key, and Value, and the calculation results are compared with Perform residual connection and get output The whole process can be described as , Inter-Atten represents self-attention calculation, The deep features are learned as the input of the next cross-refine fusion block. After the last cross-refine fusion block, a 3×3 convolutional layer is used to aggregate the features and a residual connection is established between its output and the image features.

[0032] The present embodiment provides a vehicle image enhancement system based on CNN and Transformer, characterized in that it includes a vehicle image data acquisition module and a vehicle image enhancement module. The vehicle image to be detected is collected through the vehicle image data acquisition module. The vehicle image enhancement module has a built-in vehicle image enhancement model, and the model is composed of a shallow feature extraction module, a feature modulation Transformer module, and a reconstruction module. For the feature modulation Transformer module, image features are input to the module, and the image features learn deep image features through L cross-refinement fusion blocks. The cross-refinement fusion block is composed of three types of blocks: a high-frequency enhancement residual block, a rectangular window attention block, and a mixed fusion block. After the last cross-refinement fusion block, a 3×3 convolutional layer is used to aggregate features, and a residual connection is established between its output and the shallow features to facilitate the training of image features and output the features.

[0033] The above are only preferred embodiments of the present invention. It should be pointed out that a person skilled in the art can make several modifications and improvements without departing from the inventive concept of the present invention, and these all fall within the protection scope of the present invention.

Claims

1. The vehicle image enhancement method based on CNN and Transformer is characterized by: The following steps are involved: S1. Obtain the video from the vehicle monitoring camera, extract frames from the camera every second, and obtain the image of the vehicle to be detected; S2. Construct a feature modulation Transformer module and input image features into the module. The image features learn deep features through L cross-refinement fusion blocks. The cross-refinement fusion block consists of a high-frequency enhancement residual block that extracts high-frequency information, a rectangular window attention block that captures global information, and a hybrid fusion block that refines the global representation. After the last cross-refinement fusion block, a 3×3 convolutional layer is used to aggregate features, and a residual connection is established between its output and the image features to facilitate training of image features and output; S21, high-frequency enhancement residual block consists of local feature extraction branch and high-frequency enhancement branch. If the input image feature is F in , F in Divide into two parts Then it is processed by two branches separately. For the local feature extraction branch, a 3×3 convolution layer and GELU activation function are used to extract local high-frequency features. Conv 3×3 represents a 3×3 convolutional layer, f a () represents the GELU activation function. For the high-frequency enhancement branch, the maximum pooling layer is used to extract the input features. The high-frequency information is extracted from the network, and then a 1×1 convolutional layer and a GELU activation function are used to enhance the high-frequency features. MaxPooling() represents the maximum pooling layer. The outputs of the two branches are then connected. The connected result is completely integrated through a 1×1 convolutional layer. At the same time, in order to enable the network to benefit from multi-scale information and maintain the stability of training, a residual connection is introduced. Concat() represents the connection operation; S22. For the rectangular window attention block, given an input X in , which is divided into A rectangular window, where rh and rw refer to the height and width of the rectangular window. In order to capture information on different axes, two rectangular windows are used: horizontal window and vertical window. Therefore, X in Divide Two parts, and calculate the self-attention value respectively, then connect the two results and use multi-layer perceptron for feature conversion. The whole process can be expressed as V-Rwin and H-Rwin represent vertical and horizontal rectangular window attention, and MLP represents multi-layer perception operation; S23, hybrid fusion block In order to better integrate the advantages of the high-frequency enhancement residual block and the rectangular window attention block, the output X of the high-frequency enhancement residual block H First, a 1×1 convolutional layer is used to reduce the number of channels of the feature map, and then a 3×3 deep convolutional layer is used to generate a high-frequency query. For the output X of the rectangular window attention block S First, the features are normalized through the batch normalization layer, and then the Key and Value are obtained using the same operation as the Query. The self-attention calculation is performed on the Query, Key, and Value, and the calculation results are compared with X. S Perform residual connection to get output X HFB The whole process can be expressed as X HFB =Inter-Atten(Conv 3×3 (Conv 1×1 (LN(X S ))), Conv 3×3 (Conv 1×1 (X H )))+X S , Inter-Atten represents self-attention calculation, X HFB As the input of the next cross-refine fusion block, the deep features are learned. After the last cross-refine fusion block, a 3×3 convolutional layer is used to aggregate the features and a residual connection is established between its output and the image features. S3. Build a vehicle image enhancement model, which consists of a shallow feature extraction module, a feature modulation Transformer module, and a reconstruction module; S4. Input the vehicle image into the vehicle image enhancement model to obtain a super-resolution vehicle image.