Deep hash image retrieval method based on frequency domain decoupling and visual Mamba
Through frequency domain decoupling and visual Mamba's deep hash image retrieval method, the problem in the existing technology that the hash code cannot maintain the similar structure of the image's high-dimensional space is solved, and compact and highly differentiated hash code generation is achieved, improving improve learning efficiency and accuracy.
Patent Information
- Application Number
- CN202410809515.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-21
- Publication Date
- 2024-10-22
AI Technical Summary
The existing deep hashing image retrieval framework ignores the connection between shallow features and deep features, resulting in the hash code being unable to effectively maintain the similar structure of the original high-dimensional space of the image. The calculation and storage overhead is large, and the learning efficiency is low, making it difficult to Accurately distinguish objects in multi-class scenarios.
A deep hash image retrieval method based on frequency domain decoupling and visual Mamba is used to convert image features from the spatial domain to the frequency domain through the adaptive frequency domain decoupling enhancement module, enhance feature information at different levels, and introduce a hybrid state space module and Global similarity proxy loss to optimize hash functions using class label information.
The generated hash code is compact and highly distinguishable, can effectively maintain the high-dimensional spatial similarity structure of the image, improves the learning efficiency and accuracy of the hash function, and is suitable for multi-category complex application scenarios.
Smart Images

Figure CN118820508A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of deep hash image retrieval, and in particular to a deep hash image retrieval method based on frequency domain decoupling and visual Mamba. Background Art
[0002] At present, the existing deep hash image retrieval frameworks usually use the deep features of the image extracted by the backbone network directly as the input of the hash layer, or use additional adapters to optimize the deep features. They ignore the connection between the shallow features and the final output, which is not conducive to the network's comprehensive grasp of the global semantic information of the image, resulting in the final hash code being unable to effectively maintain the similar structure of the original high-dimensional space of the image; secondly, most of these adapters are constructed using self-attention modules, which increases the computational and storage overhead that cannot be ignored, and these attention modules are highly dependent on CNN or Transformer networks, so the performance of their transfer learning is not ideal; finally, previous work usually uses pairwise loss or triplet loss for similarity metric learning. Since they can only pull in or push away a group of positive and negative samples at a time, they can only capture the similarity of the data locally, and it takes repeated rounds of learning to obtain a suitable hash function, which results in low learning efficiency. In addition, due to their neglect of the inherent labels of image categories, in the face of complex application scenarios with multiple categories, they often cannot accurately distinguish which targets need to be paid attention to, resulting in the final generated image hash code being mistakenly inclined to a certain class. Summary of the invention
[0003] The purpose of the present invention is to solve the problems existing in the prior art and to provide a deep hash image retrieval method based on frequency domain decoupling and visual Mamba. The discrete cosine transform is used to convert image features from the spatial domain to the frequency domain, thereby realizing frequency domain decoupling of features and adaptively enhancing the frequency domain components that are lacking in feature information at different levels. The method can fully mine the underlying semantic information of the image and generate a more compact and highly discriminative hash code.
[0004] In order to achieve the above object, the present invention is implemented through the following technical solutions:
[0005] A deep hash image retrieval method based on frequency domain decoupling and visual Mamba includes the following steps:
[0006] S1. Divide the image dataset and its corresponding category label information into three parts: training set, test set and retrieval set. Each sample includes an image and its corresponding category label. The training set and test set have the same number of samples for each category, and the other images are used as retrieval sets.
[0007] S2. Construct a deep hash image retrieval architecture based on frequency domain decoupling and visual Mamba, which includes Swin Transformer feature extraction backbone, hierarchical feature fusion network, hash layer, class proxy hash layer and loss function; among which Swin Transformer feature extraction backbone and hierarchical feature fusion network are used to learn image features, hash layer is used to learn the construction of hash function and obtain the hash code of input image, class proxy hash layer is used to obtain class proxy hash code of each category of image, and loss function is used to guide the optimization direction of hash function;
[0008] The hierarchical feature fusion network consists of an adaptive frequency domain decoupling enhancement module, a hybrid state space module and a feature fusion operation; the hash layer includes a fully connected layer, a layer normalization layer and an activation function tanh(·); the proxy-like hash layer includes a fully connected layer and an activation function tanh(·); the loss function includes a global similarity proxy loss function and a quantization loss function;
[0009] S3. Using the training set, according to the deep hash image retrieval architecture based on frequency domain decoupling and visual Mamba, a deep hash image retrieval model based on frequency domain decoupling and visual Mamba is obtained through training;
[0010] S4, input the test set and retrieval set images into the trained deep hash image retrieval model based on frequency domain decoupling and visual Mamba, and obtain the hash codes of the test set and retrieval set respectively;
[0011] S5, taking a hash code of a test image, calculating the Hamming distance between the hash code and the hash code of the retrieval set, and obtaining a Hamming distance vector;
[0012] S6, sorting the values in the Hamming distance vector in ascending order, outputting the corresponding original images in order, and obtaining the retrieval result of the test image;
[0013] S7. Repeat S5 and S6 to obtain the retrieval results for each image in the test set, and calculate the average retrieval accuracy to evaluate the model performance.
[0014] Preferably, in step S2, the deep hash image retrieval architecture based on frequency domain decoupling and visual Mamba includes four feature extraction stages, each stage extracts features at different levels of the image, and an adaptive frequency domain decoupling enhancement module is set outside each stage, and each adaptive frequency domain decoupling enhancement module selects different discrete cosine transform filters to decouple the frequency domain components of the features to enhance weak frequency information.
[0015] Preferably, in step S2, the two-dimensional discrete cosine transform formula of the adaptive frequency domain decoupling enhancement module is:
[0016]
[0017] Among them, f i,j Represents the pixel value of point (i, j) on the image, D h,w ∈R H×W represents the DCT filter obtained after transformation, C(·) represents the normalized coefficient, represents the basis function of DCT;
[0018]
[0019] Preferably, in step S2, the filter is divided into m regions along the main diagonal with equal distance, and the value of m is equal to the number of stages of the feature extraction backbone network. First, m binary mask matrices M are set s ∈R H×W , where s = 1, 2, ..., m. For each stage, the area to be enhanced is bounded by the upper left corner vertex. As the number of stages increases, the lower bound gradually moves to the lower right corner. Each time the main diagonal line is moved The distance is set to 1, and the values of other areas are set to 0. The binary mask matrix is expressed as:
[0020]
[0021] Where n represents the stage number. Represents the mask matrix M s Binary code at position (i,j);
[0022] In the sth feature fusion module, the mask matrix M is used s Perform a dot multiplication operation with the frequency domain features of the s-1th stage to obtain a discrete cosine transform filter for regional differentiation; at the same time, add a learnable filter based on the original fixed value filter The enhanced features at different levels can be expressed as:
[0023]
[0024] in, Represents the frequency domain features of the s-1th stage.
[0025] Preferably, after the frequency domain enhancement processing is performed on the features of the previous stage, further downsampling and feature extraction are required, specifically:
[0026] First, two-dimensional convolution Conv2d is used for downsampling operation, and then convolution sequences with convolution kernels of different sizes are used to extract multi-scale feature information. For shallow features, the present invention uses a convolution sequence with a smaller convolution kernel, and for deep features, a convolution sequence with a larger convolution kernel is used. The setting follows the following rules:
[0027] U s =[Conv2d1(k=2s-1),Conv2d2(k=2s+1)];
[0028] Among them, U s Represents the convolution sequence in the sth fusion block, using U r s It represents the subcolumn consisting of the first r convolutional layers of the convolution sequence in the s-th fusion module, and r = 1, 2, k represents the convolution kernel size.
[0029] Preferably, in step S2, different spatial selection mechanisms are used to obtain different spatial attention maps, specifically:
[0030] First, for the frequency domain features after the convolution sequence operation Global average and global maximum pooling are applied simultaneously and concatenated to connect different spatial relationships, and then the convolutional layer A(·) is used to aggregate them to obtain the pooled features of r channels:
[0031]
[0032] On this basis, the sigmoid activation function σ(·) is used to transform the pooled features into an attention map:
[0033]
[0034] Then the features obtained by each convolution subsequence are weighted by their corresponding attention maps and fused through a convolutional layer A(·):
[0035]
[0036] The features of the current stage are involved in feature fusion through deep separable convolution and a series of residual operations:
[0037]
[0038] Among them, MixSSM only acts on the feature fusion part of the last fusion module.
[0039] Preferably, a parallel convolution branch is added outside the two-dimensional state space to form a hybrid selection state space module. The two-dimensional state space consists of a cross scanning operation, an S6 block, and a sequence merging operation. First, the image is scanned in parallel along four directions, and the four directions are: upper left to lower right, upper right to lower left, lower right to upper left, and lower left to upper right; each sequence in different direction order is simultaneously subjected to state space operation through the S6 block, and the operation process is formally described by a linear ordinary differential equation as follows:
[0040]
[0041] Where u(t)∈R U Represents a series of continuous input information, v(t)∈R V Represents the output information, g(t)∈R W is the intermediate hidden state, A∈R W×W represents the state transfer matrix, B∈R W×U represents the control input matrix, C∈R M×W Denotes the output matrix, D∈R M×U represents the feedforward matrix;
[0042] The discrete time parameters are constructed by using the time scale parameter Δ:
[0043]
[0044] in, and Obtained using classical discretization methods, such as Euler, bilinear, or zero-order hold;
[0045] By maintaining and updating these time parameters, image features are dynamically selected to simulate and predict the dynamic changes of image data. After being processed by the state-space model, each sequence is reshaped into a feature map shape, and then they are stacked and summed in the channel dimension to obtain the final output features.
[0046] Preferably, a convolution branch is added outside the state model branch, specifically:
[0047] First, the input features are divided into two parts of the same size f conv and f ssm , one part of which passes through the convolution branch and the other part passes through the state model branch;
[0048] In the convolution branch, the input f is again conv Divide into four parts f1, f2, f3 and f4, which are respectively subjected to square convolution and vertical and horizontal strip convolution and jump connection operations, and then concatenated:
[0049]
[0050] Among them, k represents the size of the convolution kernel, ξ is the scaling factor when dividing the branches, represents the convolution operation, Represents a splicing operation;
[0051] The obtained feature map is combined with the state space model branch output F ssm A SiLU(·) gating function is added before feature fusion;
[0052] Finally, the features of the two branches are concatenated and fused using a 1×1 convolution:
[0053]
[0054] Preferably, the loss function adopts global similarity proxy loss, which is expressed as:
[0055] L GP =L G +λL P ;
[0056]
[0057] Among them, λ is a hyperparameter, represents the class proxy real-valued hash code, μ is a hyperparameter, B represents the mini-batch, Represents the true label y i The normalized result, ε is the balance parameter, N c represents the number of categories, and T represents the transposition operation.
[0058] Preferably, in order to enable the network to perform normal back propagation and ensure that the parameters of the hash proxy layer are updated, continuous real-valued hash codes are used in the global similarity proxy loss, but binary hash codes are required in the image retrieval process. The optimization process of binary hash codes is regarded as a binary classification problem for each bit symbol of the continuous real-valued hash code. First, a Gaussian probability model is defined:
[0059]
[0060] And assign +1 and -1 to the target mean to get two estimators and Calculate the probability of belonging to +1 and -1 for each hash code element, where k = 1, 2, ..., N bits , they use the same standard deviation δ; then generate the corresponding binary label b + and b - , these labels reflect the expected binary state of the hash code elements:
[0061]
[0062] A binary cross entropy loss function is used to evaluate the consistency between the model output and these binary labels:
[0063]
[0064] sB b (u,v)=-ulogv+(1-u)log(1-v).
[0065] Compared with the prior art, the beneficial effects of the present invention are:
[0066] 1. The present invention proposes a deep hash image retrieval method based on frequency domain decoupling and visual Mamba. The adaptive frequency domain decoupling enhancement module (AFDE) decouples the features of different frequency bands at each level, enhances the weak frequency components through an adaptive discrete cosine transform (DCT) filter, and performs multi-scale feature fusion through a spatial selection mechanism to enhance the connection between the features of each level and the hash code, so that the hash code finally generated maintains the similar structure of the original high-dimensional space as much as possible. In order to fully mine the underlying semantic information of the image, the idea of Mamba is introduced to construct a mixed state space (Mix_SSM) module as a deep feature extractor for global and local modeling at the same time. In addition, a new global similarity proxy loss is proposed. By making full use of the category label information, the model's ability to capture the global similarity between samples is enhanced, thereby improving the learning efficiency and accuracy of the hash function.
[0067] 2. This paper proposes an adaptive frequency domain decoupling enhancement module (AFDE) to establish connections between features at different levels and enable the network to fully grasp the global semantic information of the image. It uses discrete cosine transform to convert image features from the spatial domain to the frequency domain, realizes the frequency domain decoupling of features, and adaptively enhances the frequency domain components that are lacking in feature information at different levels. The spatial selection mechanism captures the spatial relationship of shallow features and improves their abstraction level to better integrate with deep features.
[0068] 3. This paper introduces Mamba into the field of hash image retrieval and constructs a hybrid selection state space module (Mix_SSM), which aims to integrate the global perception ability of the two-dimensional state space (SS2D) and the local feature extraction ability of convolution at the cost of linear time complexity, and fully mine the underlying semantic information of the image. The important information is selected through the selection mechanism in S6 to generate a more compact and highly discriminative hash code.
[0069] 4. This invention adopts a new global similarity proxy loss, which pays attention to the label information carried by each category. A corresponding class proxy hash code is generated for each category to effectively shorten and distance the distance between the same and different samples, and the inter-class similarity between class proxies is supervised by the real label. Together, they enable the network to learn the global similarity between data. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] Figure 1 This is the architecture diagram of the deep hash image retrieval architecture based on frequency domain decoupling and visual Mamba;
[0071] Figure 2It is a schematic diagram of the progressive feature fusion process;
[0072] Figure 3 It is a schematic diagram of the mixed state space model (Mix_SSM). DETAILED DESCRIPTION
[0073] The present invention will be further described below in conjunction with specific embodiments. It should be understood that these embodiments are only used to illustrate the present invention and are not intended to limit the scope of the present invention. In addition, it should be understood that after reading the content taught by the present invention, those skilled in the art can make various changes or modifications to the present invention, and these equivalent forms fall within the scope limited by the application equally.
[0074] The rapid development of intelligent communication technology has provided a very convenient channel for the capture and dissemination of image data. Every moment, tens of thousands of image data are transmitted by users to various storage devices, which poses a great challenge to how to efficiently and accurately retrieve valuable information from massive data. Especially in large-scale image databases, the traditional method of accurately identifying and querying the most relevant samples of input will face the "dimensionality disaster" and huge time overhead. Therefore, approximate nearest neighbor search came into being, which allows approximate results to be returned within the error range instead of exact solutions. Among them, hash-based methods have become one of the most widely used methods. It maps high-dimensional feature vectors to low-dimensional binary hash codes through hash functions, and uses Hamming distance to calculate the similarity between vectors to maintain similar structures in the original space. The efficient XOR operation and compact binary encoding of the hash algorithm make it have the characteristics of high efficiency and low storage.
[0075] In recent years, the introduction of deep learning has further revolutionized the field of hash image retrieval. The powerful feature extraction and nonlinear mapping capabilities of deep neural networks (DNNs) have enabled deep hashing methods to not only improve the quality of hash code generation, but also optimize the semantic preservation of images. Among them, convolutional neural network (CNN) methods represented by Alexnet and Resnet occupy a dominant position. However, due to the overemphasis on local visual features by CNN, the generated hash codes lack the control of global information. The birth of Vision Transformer breaks this limitation. Its long-range dependency modeling capability enables it to obtain richer contextual information of images, attracting more and more researchers in the field of deep hashing. TransHash combines Vision Transformer with hash image retrieval for the first time, and designs two parallel transformation modules to simultaneously obtain the global and local features of the image, generating hash codes that can efficiently retain semantic similarity. TDH effectively combines global and local context information by fusing features of different scales through parallel transformation modules. SWTH uses Swin Transformer to hierarchically process the global and local features of the captured image, and captures the global context information of the image as much as possible by establishing the relationship between different blocks of the image. In addition, Swin Transformer adopts a hierarchical structure of layer-by-layer downsampling, which can obtain rich multi-scale feature information while extracting global information. After the feature extraction network, SWTH adds a hash layer for hash learning. By optimizing the combination of hash loss, classification loss and quantization loss, the feature representation and hash function of the image are learned. The present invention also uses Swin Transformer as the backbone network for extracting image features.
[0076] However, the lack of attention to local information in the Transformer architecture also brings too high a computational load to the network. Therefore, some scholars have proposed a method that combines CNN with attention to achieve global and local modeling at the same time. DAHP combines position attention and channel attention mechanisms to adaptively integrate local features and global dependencies. DICTH focuses on the internal correlation between the query matrix and the key matrix, and dynamically learns the self-attention matrix by cascading post-convolution. However, these methods usually use the deep features of the image extracted by the backbone network directly as the input of the hash layer, or use additional adapters to optimize the deep features. They ignore the connection between shallow features and the final output, which is not conducive to the network's comprehensive grasp of the global semantic information of the image, resulting in the final hash code being unable to effectively maintain the similar structure of the original high-dimensional space of the image. This is because the features at different levels have different expression capabilities. For example, shallow features lack the global information contained in deep features, and as the network goes deeper, deep features gradually lose the detailed information extracted by shallow features. Since the features of different levels are in different time domains, the algorithm cannot perform hierarchical analysis and processing on the features extracted at a certain stage of the network from the spatial domain. Therefore, in view of the above problems, the present invention introduces discrete cosine transform (DCT) from the perspective of frequency domain to construct an adaptive frequency domain decoupling enhancement module (AFDE). It fuses the feature information of the current stage and the previous stage of the feature encoder, and uses the fused features as the input of the next stage, so each fusion block builds a connection for three adjacent feature extraction stages. Considering the correspondence between the hierarchical features of the image and the frequency domain information (i.e., the shallow features mainly capture the high-frequency information of the image, and the deep features mainly capture the low-frequency information of the image), the characteristics of discrete cosine transform (DCT) are used to separate the low-frequency information and high-frequency information of the image, and a learnable discrete cosine transform (DCT) filter is constructed for features of different levels, which adaptively enhances the frequency domain components that are lacking in feature information at each stage. Then, the enhanced features are downsampled and multi-scale extracted, and the spatial relationship attention map is obtained through the spatial selection mechanism for feature recalibration, so as to better fuse with the features of the next stage.
[0077] In order to fully learn the underlying semantic information of the image, the present invention hopes to further process the final fusion features. Most of the previous work adds a self-attention module after the feature extraction network, but it also increases the computational and storage overhead that cannot be ignored. The Mamba network, which has been popular in various fields recently, has broken the quadratic time complexity of the Transformer self-attention mechanism. In view of its long-range dependency modeling ability at the cost of linear time complexity, the present invention introduces it to build an underlying semantic extractor to tap its potential in the field of hash image retrieval. Specifically, the present invention uses the setting of the two-dimensional state space (SS2D) of the VMamba core component to perform state space operations through S6 after cross-scanning the image. It is worth noting that the selection mechanism in S6 helps the module ignore the interference of irrelevant information and capture important target information to improve the effectiveness and efficiency of the generated hash code. In order to integrate the global perception ability of the two-dimensional state space (SS2D) and the local feature extraction ability of the convolution, a parallel convolution branch is added outside the two-dimensional state space (SS2D) to form a mixed selection state space module (Mix_SSM). The convolution branch not only maintains the spatial correlation of features through intersecting strip convolutions, but also provides an expansive local receptive field.
[0078] In order to maintain the similar structure of the original space and improve the retrieval performance, it is necessary not only to start from a single image, but more importantly to grasp the correlation between samples. Previous work usually uses pairwise loss or triplet loss to learn similarity metrics. Since they can only pull or push away a group of positive and negative samples at a time, they can only capture the similarity of data locally. It takes repeated rounds of learning to obtain a suitable hash function, and the learning efficiency is low. In addition, images in real application scenarios are often complex and contain multiple and multiple objects. If the model does not have enough semantic understanding of different categories, they still cannot accurately distinguish which targets need to be paid attention to, resulting in the final generated image hash code being mistakenly inclined to a certain class. Like the real labels of the images, they themselves have inherent labels, which can be used as supervisory information for the optimization of network models. In order to make full use of category information and capture the global similarity between samples, the present invention introduces the idea of a proxy, adds a class hashing layer to specifically generate corresponding class hash codes for each category, and uses image labels to construct a class association matrix, and designs a new global similarity proxy loss (LGP), which clearly expresses the semantic correlation between each class, so that the network can accurately focus on the correct target.
[0079] Example: As shown in the attached Figure 1 As shown, the present invention is a deep hash image retrieval method based on frequency domain decoupling and visual Mamba, which specifically includes:
[0080] Step 1: Divide the image dataset and its corresponding category label information into three parts: training set, test set and retrieval set. Each sample includes an image and its corresponding category label. The training set and test set have the same number of samples for each category, and the other images are used as retrieval sets.
[0081] Step 2: Construct a deep hash image retrieval architecture based on frequency domain decoupling and visual Mamba, which includes the Swin Transformer feature extraction backbone, the hierarchical feature fusion network (composed of an adaptive decoupling enhancement module, a hybrid state space module and a feature fusion operation), the hash layer (including a fully connected layer, a layer normalization layer and an activation function tanh(·)), the class proxy hash layer (including a fully connected layer and an activation function tanh(·)) and the loss function (including a global similarity proxy loss function and a quantization loss function,). The Swin Transformer feature extraction backbone and the hierarchical feature fusion network are used to learn image features, the hash layer is used to learn the construction of the hash function and obtain the hash code of the input image, the class proxy hash layer is used to obtain the class proxy hash code of each category of the image, and the loss function is used to guide the optimization direction of the hash function;
[0082] Step 3: Using the training set, according to the deep hash image retrieval architecture based on frequency domain decoupling and visual Mamba, a deep hash image retrieval model based on frequency domain decoupling and visual Mamba is obtained through training;
[0083] Step 4: Input the test set and retrieval set images into the trained deep hash image retrieval model based on frequency domain decoupling and visual Mamba to obtain the hash codes of the test set and retrieval set respectively;
[0084] Step 5: Take a hash code of a test image, calculate the Hamming distance between the hash code and the hash code of the retrieval set, and obtain the Hamming distance vector;
[0085] Step 6: Sort the values in the Hamming distance vector from small to large, output the corresponding original images in order, and obtain the retrieval result of the test image.
[0086] Next, the adaptive decoupling enhancement module, hybrid state space module, global similarity proxy loss function and quantization loss function mentioned in the above steps will be described in detail. First of all, the present invention, like most other methods, uses x n To represent the image sample, y n Indicates the corresponding label. Assuming that there are N samples in the data set, the present invention has an image set The tag set is in, It is One-Hot encoding, Z n ∈{0,1}C , represents the number of classifications of the label. After passing through the hash layer and function, the corresponding real-valued hash code is obtained, and the corresponding binary representation can be obtained through the symbolic function, which is the length of the hash code. The symbolic function is defined as follows:
[0087]
[0088] The deep hash image retrieval architecture based on frequency domain decoupling and visual Mamba in step 2 above is as follows Figure 1 As shown in the figure. Swin Transformer is used as the feature extraction network. It adopts the sliding window self-attention mechanism to replace the multi-head self-attention of the traditional visual Transformer, avoiding the huge time overhead caused by too long input sequences and achieving excellent performance in multiple visual tasks. It is divided into four feature extraction stages with an inverted pyramid structure. Each stage extracts features at different levels of the image, and an AFDE module is set outside each stage. Each AFDE module uses different discrete cosine transform (DCT) filters to decouple the frequency domain components of the features to enhance the weak frequency information. The enhanced shallow features are fused with the current layer features through the spatial selection mechanism and input into the next stage, so as to proceed layer by layer.
[0089] Figure 2 In the figure (a), the composition structure of the fusion module is shown, and the core part is the adaptive frequency domain decoupling enhancement (AFDE) module as shown in figure (b). First, the adaptive discrete cosine transform layer (ADCTL) is used to decouple and enhance the previous stage features (stagei-1) to obtain F q Figure (c) shows the change process of the discrete cosine transform (DCT) filter set by ADCTL for different stage features. Then downsampling and multi-scale feature extraction are performed through the convolution sequence, and the spatial relationship is obtained through the spatial selection mechanism, and finally fused with the next stage features to obtain F fus .
[0090] In the present invention, the above processes belong to a hierarchical feature fusion module, such as Figure 2As shown in (a). In order to fully explore the underlying semantic information of the image, a mixed state space is added to the feature fusion part of the last fusion block. Through the filtering and feature extraction process, the redundancy of the data is reduced and the high-level feature expression ability is enhanced. The fused features are obtained through pooling and classification layers to obtain classification features as the input of the hash layer. Following the general setting, the hash layer consists of a layer normalization layer and a fully connected layer, which maps high-dimensional classification features to low-dimensional hash codes. In order to better perform classification supervision, an additional class hash layer is added to map the class label information to the hash code dimension we need to calculate the global similarity proxy loss, aggregate intra-class features and construct inter-class correlations. It and the quantization loss jointly supervise the optimization direction of the network. The detailed description of each part is as follows:
[0091] In order to better introduce the adaptive frequency domain decoupling enhancement module (AFDE) in the above step 2, the discrete cosine transform is first introduced. Discrete cosine transform (DCT) is a technology widely used in the fields of signal processing and image processing, which converts images from the spatial domain to the frequency domain. Images are usually highly correlated in space, that is, adjacent pixels in the image often have similar values. The two-dimensional discrete cosine transform (DCT2D) can effectively extract this correlation and use orthogonal cosine basis functions to compress and extract energy from a large number of correlated pixels into fewer coefficients. Generally, for a given input image x with a height of H and a width of W, n , has its corresponding C channel feature map F = {f 1 , f 2 , …, f c}∈R H×W×C , where f c represents the feature map of the cth channel. The present invention uses f i,j Representing the pixel value of point (i, j) on the image, the overall two-dimensional discrete cosine transform (DCT2D) formula can be written as:
[0092]
[0093] Among them, D h,w ∈R H×W represents the DCT filter obtained after transformation, C(·) represents the normalized coefficient, Represents the basis function of DCT, and its specific expression is shown as follows:
[0094]
[0095] During the transformation process, most of the high energy coefficients (representing the main information of the image) will be concentrated in F h,wThe upper left corner of the filter is the low-frequency area, and the closer to the lower right corner, the lower the coefficient energy, indicating the high-frequency area. Therefore, the present invention divides the filter into m areas with equal distance along the main diagonal line, where m is equal to the number of stages of the feature extraction backbone network. According to the number of stages of SwinTransformer, the present invention sets m to 4. Figure 2 As shown in (c), first set m binary mask matrices M s ∈R H ×W , where s = 1, 2, ..., m. For each stage, the area to be enhanced is bounded by the upper left corner vertex. As the number of stages increases, the lower bound gradually moves to the lower right corner. Each time the main diagonal line is moved The distance is set to 1, and the element value in this area is set to 0. The binary mask matrix can be expressed as:
[0096]
[0097] Where n represents the stage number. Represents the mask matrix M s The binary code at position (i, j). In the s-th feature fusion module, the mask matrix M is used s The discrete cosine transform (DCT) filter for region differentiation is obtained by performing a dot multiplication operation with the frequency domain features of the s-1th stage. At the same time, the present invention adds a learnable filter on the basis of the original fixed value filter obtained. In this way, the frequency domain components of interest in and outside the enhanced area are learned. Therefore, the enhanced features at different levels can be expressed as:
[0098]
[0099] in, Represents the frequency domain features of the s-1th stage. After the above operations, the weak frequency area of the features of the previous stage in each fusion block is enhanced. The discrete cosine transform (DCT) filter of the shallower features pays more attention to the utilization of the low-frequency area in the upper left corner, while the filter of the deeper features will include more high-frequency areas to make up for the details lost by the deep features.
[0100] After the frequency domain enhancement processing of the previous stage features, it is necessary to further downsample and extract features in order to better integrate them with the current stage features. Figure 2 As shown in (b), firstly, a two-dimensional convolution Conv2d is used for downsampling operation, and then a convolution sequence of convolution kernels of different sizes is used to extract multi-scale feature information. For shallow features, the present invention uses a convolution sequence of a smaller convolution kernel, and for deep features, a convolution sequence of a larger convolution kernel is used. The setting of the present invention follows the following rules:
[0101] U s =[Conv2d1(k=2s-1),Conv2d2(k=2s+1)];
[0102] U s Represents the convolution sequence in the sth fusion block. The present invention uses U r s Represents the sub-column composed of the first r convolutional layers of the convolution sequence in the sth fusion module, and r = 1, 2, k represents the convolution kernel size. The receptive field of a convolution sequence of small convolution kernels connected in series is theoretically equivalent to a convolution operation with a larger convolution kernel. Under the same theoretical receptive field, they explicitly use receptive fields of different sizes to obtain richer contextual information, while deepening the abstract level of shallow features and enhancing their expressive power.
[0103] Discrete cosine transform (DCT) associates the frequency domain distribution of features to the spatial domain. In order to enhance the correlation between the frequency domain components, the present invention uses different spatial selection mechanisms to obtain different spatial attention maps. First, for the frequency domain features that have undergone convolution sequence operations, Global average and global maximum pooling (here represented as GAP(·) and GMP(·)) are applied simultaneously and concatenated to connect different spatial relationships (in this case, 2 channel features), and then they are aggregated using the convolutional layer A(·) to obtain the pooled features of r channels:
[0104]
[0105] On this basis, the sigmoid activation function σ(·) is used to transform the pooled features into an attention map:
[0106]
[0107] Then the features obtained by each convolution subsequence are weighted by their corresponding attention maps and fused through a convolutional layer A(·):
[0108]
[0109] As the output feature of the adaptive frequency domain decoupling enhancement module, After the frequency domain transformation, the weak frequency features are decoupled and enhanced. At the same time, the image spatial relationship is obtained through the spatial selection mechanism, so that the shallow features have a higher level of abstraction and contain more comprehensive image information. It and the current stage features participate in feature fusion through deep separable convolution (DWConv) and a series of residual operations:
[0110]
[0111] Among them, MixSSM only acts on the feature fusion part of the last fusion module.
[0112] The two-dimensional state space (SS2D) is the basic component of Mix_SSM, which consists of a cross-scan operation, an S6 block, and a sequence merging operation. It first scans the image in four directions in parallel, namely, from top left to bottom right, from top right to bottom left, from bottom right to top left, and from bottom left to top right. This cross-scanning strategy ensures that each element in the feature map can interact with information from different directions and positions. Each sequence of different direction orders is simultaneously processed through the S6 block for state space operations. The operation process can usually be formally described by a linear ordinary differential equation:
[0113]
[0114] Where u(t)∈R U Represents a series of continuous input information, v(t)∈R V Represents the output information, g(t)∈R W is the intermediate hidden state, A∈R W×W and B∈R W×U represents the state transfer matrix and control input matrix, C∈R M×W and D∈R M×U Represents the output matrix and the feedforward matrix. However, since deep learning algorithms usually use discrete data as input, such as image pixel values or labels. In various Mamba models, the continuous state space is discretized into discrete states, making the state space model more compatible with deep learning algorithms. Specifically, they construct discrete time parameters by using the time scale parameter Δ:
[0115]
[0116] in, and Using classical discretization methods, such as Euler, bilinear or zero-order hold, the present invention defines and By maintaining and updating these time parameters, image features are dynamically selected to simulate and predict the dynamic changes of image data. After being processed by the state space model, each sequence is reshaped into a feature map shape, and then they are stacked and summed in the channel dimension to obtain the final output feature.
[0117] Although the two-dimensional state space (SS2D) achieves the ability to model long-range dependencies at the cost of linear time complexity, in order to maintain sensitivity to local features at the same time, the present invention adds a convolution branch on its basis, such as Figure 3 As shown, the input features are first divided into two parts of the same size fconv and f ssm , one part of which passes through the convolution branch and the other part passes through the state model branch. In order not to lose the image spatial relationship obtained in the adaptive frequency domain decoupling enhancement module, in the convolution branch, the present invention again inputs f conv Divide into four parts f1, f2, f3 and f4, which are respectively subjected to square convolution and vertical and horizontal strip convolution and jump connection operations, and then concatenated:
[0118]
[0119] Each pixel value in the feature map thus obtained has a horizontal and vertical relationship network centered on itself. k represents the size of the convolution kernel, ξ is the scaling factor when dividing the branches, and the default value is 0.125. and In order to dynamically control the influence of the branch output feature on the final input feature, the present invention combines it with the state space model (SSM) branch output F ssm A SiLU(·) gating function is added before feature fusion. Finally, the features of the two branches are concatenated and fused using a 1×1 convolution:
[0120]
[0121] The effective combination of convolution and state-space model (SSM) not only obtains the long-range dependency information of deep features, but also obtains the extended local information; it not only fully mines the underlying semantic information of the image, but also injects spatial relationships into the final hash code.
[0122] The loss function is an important factor that enables hash codes to effectively reflect the similarity relationship between images. The global similarity proxy loss proposed in this paper solves the problem of long model iteration cycle and slow convergence speed in previous data-dependent large-scale hash image retrieval tasks due to the local correlation capture ability of the loss function. Specifically, firstly, the one-hot encoding I of each class is c The hash code of each class is obtained through the hash proxy layer, which is called the class proxy c=1,2,…,N c Next, calculate the image sample x i With each class agent P c The similarity between them is calculated, and the corresponding predicted label l is obtained through the softmax function. i :
[0123]
[0124] Among them, N cIndicates the number of categories, and T represents the transposition operation. In order to reduce the difference between the predicted label and the true label, the present invention uses cross entropy loss for optimization:
[0125]
[0126] Among them, B represents small batch, Represents the true label y i The normalized result, ε is the balance parameter, which is used to adjust the smoothness of the predicted label. In this process, the class agent continuously learns the similar structure between images in each small batch, so that the hash codes of the same class of images tend to the same class agent, and the hash codes of different classes of images tend to different class agents.
[0127] However, in a multi-label dataset, an image often has more than one label, which is also very common in complex real-world scenarios. For such images, each class is not completely independent of each other, and there is a certain semantic correlation between them. In order to enable the class agent to learn this correlation so that the generated image hash code is not extremely biased towards one of the classes, the present invention uses P c and P c The transpose of Each element represents the pairwise similarity between different classes. But obviously, using only such a similarity matrix is not enough. Therefore, the present invention introduces the real label of the image as supervision information. Similarly, a batch class similarity matrix is constructed using a small batch of real labels and their transposition. At the same time, sum and normalize by row to get the inter-class similarity weight mapping Each element represents the total impact of other classes on the current class:
[0128]
[0129] Among them, w ij Represents the element in the i-th row and j-th column of the batch similarity matrix W. Here w′ i As the weight of the ith class, it contains the correlation between the ith class and other classes. In other words, w′ i It represents the contribution of the i-th class to the entire inter-class similarity structure. In order to maintain structural consistency, the present invention also sums the inter-class similarity matrix M by row. Combined with the weight information, the class proxy similarity loss of the present invention can be written as:
[0130]
[0131] The max function is used, only positive correlation is considered, and negative correlation is ignored. The second term in the formula is the L2 regularization term of the proxy-like hash code, which makes the 1 and -1 distribution of the hash code more uniform, where P j (i) represents the i-th element of the j-th class proxy hash code, and η is a hyperparameter.
[0132] In addition, considering the non-differentiability and non-differentiability of the sign function sgn(·) at 0, and the property that the derivative of non-zero elements is always zero, in order to enable the network to perform normal backpropagation and ensure that the parameters of the hash proxy layer are updated, this study does not directly use binary hash codes, but obtains real-valued hash codes through the tanh(·) function, and adds quantization loss to make each element infinitely close to 1 or -1, so the similarity loss of the proxy is reconstructed as:
[0133]
[0134] in, represents the real-valued hash code of the class agent and μ is a hyperparameter.
[0135] In the above process, the class agent P c The distance between the same and different samples is shortened and pushed away. At the same time, the inter-class related information carried in the multi-label samples is also well reflected between the class agents. The class agent feeds back this related information to the sample hash code. Through back propagation, the network can learn the global similarity between the data. Finally, the global similarity proxy loss of the present invention can be expressed as:
[0136] L GP =L G +λL P ;
[0137] Among them, λ is a hyperparameter.
[0138] In addition, the quantization loss function mentioned in step 2 above uses the binary cross entropy loss based on the Gaussian classifier. Since binary hash codes are used in the retrieval process to ensure high efficiency and low storage, another expectation for the continuous real-valued hash code of the image is to reasonably approach its binary representation. This process can actually be regarded as a binary classification problem for each bit symbol of the continuous real-valued hash code (classified as +1 or -1), so first define a Gaussian probability model:
[0139]
[0140] And assign +1 and -1 to the target mean to get two estimators and Calculate the probability of +1 and -1 for each hash code element, where k = 1, 2, ..., N bits, they use the same standard deviation δ; then generate the corresponding binary label b + and b - , these labels reflect the expected binary state of the hash code elements:
[0141]
[0142] A binary cross entropy loss function is used to evaluate the consistency between the model output and these binary labels:
[0143]
[0144] Through minimization, the network learns to adjust its parameters so that the generated continuous hash code can retain the semantic similarity of the original data as much as possible when quantized into binary code, thereby reducing the quantization error. It and the global similarity proxy loss proposed in this invention jointly guide the optimization direction of the network through back propagation.
Claims
1. A deep hash image retrieval method based on frequency domain decoupling and visual Mamba, characterized in that: Includes steps: S1. Divide the image dataset and its corresponding category label information into three parts: training set, test set and retrieval set. Each sample includes an image and its corresponding category label. The training set and test set have the same number of samples for each category, and the other images are used as retrieval sets. S2. Construct a deep hash image retrieval architecture based on frequency domain decoupling and visual Mamba, which includes Swin Transformer feature extraction backbone, hierarchical feature fusion network, hash layer, class proxy hash layer and loss function; among which Swin Transformer feature extraction backbone and hierarchical feature fusion network are used to learn image features, hash layer is used to learn the construction of hash function and obtain the hash code of input image, class proxy hash layer is used to obtain class proxy hash code of each category of image, and loss function is used to guide the optimization direction of hash function; The hierarchical feature fusion network consists of an adaptive frequency domain decoupling enhancement module, a hybrid state space module and a feature fusion operation; the hash layer includes a fully connected layer, a layer normalization layer and an activation function tanh(·); the proxy-like hash layer includes a fully connected layer and an activation function tanh(·); the loss function includes a global similarity proxy loss function and a quantization loss function; S3. Using the training set, according to the deep hash image retrieval architecture based on frequency domain decoupling and visual Mamba, a deep hash image retrieval model based on frequency domain decoupling and visual Mamba is obtained through training; S4, input the test set and retrieval set images into the trained deep hash image retrieval model based on frequency domain decoupling and visual Mamba, and obtain the hash codes of the test set and retrieval set respectively; S5, taking a hash code of a test image, calculating the Hamming distance between the hash code and the hash code of the retrieval set, and obtaining a Hamming distance vector; S6, sorting the values in the Hamming distance vector in ascending order, outputting the corresponding original images in order, and obtaining the retrieval result of the test image; S7. Repeat S5 and S6 to obtain the retrieval results for each image in the test set, and calculate the average retrieval accuracy to evaluate the model performance.
2. According to claim 1, a deep hash image retrieval method based on frequency domain decoupling and visual Mamba is characterized in that: In step S2, the deep hash image retrieval architecture based on frequency domain decoupling and visual Mamba includes four feature extraction stages. Each stage extracts features at different levels of the image. An adaptive frequency domain decoupling enhancement module is set outside each stage. Each adaptive frequency domain decoupling enhancement module selects different discrete cosine transform filters to decouple the frequency domain components of the features to enhance the weak frequency information.
3. According to claim 2, a deep hash image retrieval method based on frequency domain decoupling and visual Mamba is characterized in that: In step S2, the two-dimensional discrete cosine transform formula of the adaptive frequency domain decoupling enhancement module is: Among them, f i,j Represents the pixel value of point (i, j) on the image, D h,w ∈R H×W represents the DCT filter obtained after transformation, C(·) represents the normalized coefficient, represents the basis function of DCT; 4. According to claim 3, a deep hash image retrieval method based on frequency domain decoupling and visual Mamba is characterized in that: In step S2, the filter is divided into m regions along the main diagonal with equal distances, where the value of m is equal to the number of stages of the feature extraction backbone network. First, m binary mask matrices M are set s ∈R H×W , where s = 1, 2, ..., m. For each stage, the area to be enhanced is bounded by the upper left corner vertex. As the number of stages increases, the lower bound gradually moves to the lower right corner. Each time the main diagonal line is moved The distance is set to 1, and the values of other areas are set to 0. The binary mask matrix is expressed as: Where n represents the stage number. Represents the mask matrix M s Binary code at position (i,j); In the sth feature fusion module, the mask matrix M is used s The discrete cosine transform filter with regional differentiation is obtained by performing a dot multiplication operation with the frequency domain features of the s-1th stage; at the same time, a learnable filter W is added to the original fixed value filter. s l ∈R H×W , the enhanced features at different levels can be expressed as: in, Represents the frequency domain features of the s-1th stage.
5. According to claim 4, a deep hash image retrieval method based on frequency domain decoupling and visual Mamba is characterized in that: After the frequency domain enhancement processing of the previous stage features, it is necessary to further downsample and extract features, specifically: First, two-dimensional convolution Conv2d is used for downsampling operation, and then convolution sequences with convolution kernels of different sizes are used to extract multi-scale feature information. For shallow features, the present invention uses a convolution sequence with a smaller convolution kernel, and for deep features, a convolution sequence with a larger convolution kernel is used. The setting follows the following rules: U s =[Conv2d1(k=2s-1),Conv2d2(k=2s+1)]; Among them, U s Represents the convolution sequence in the sth fusion block, using It represents the subcolumn consisting of the first r convolutional layers of the convolution sequence in the s-th fusion module, and r = 1, 2, k represents the convolution kernel size.
6. A deep hash image retrieval method based on frequency domain decoupling and visual Mamba according to claim 5, characterized in that: In step S2, different spatial selection mechanisms are used to obtain different spatial attention maps. Specifically: First, for the frequency domain features after the convolution sequence operation Global average and global maximum pooling are applied simultaneously and concatenated to connect different spatial relationships, and then the convolutional layer A(·) is used to aggregate them to obtain the pooled features of r channels: On this basis, the sigmoid activation function σ(·) is used to transform the pooled features into an attention map: Then the features obtained by each convolution subsequence are weighted by their corresponding attention maps and fused through a convolutional layer A(·): The features of the current stage are involved in feature fusion through deep separable convolution and a series of residual operations: Among them, MixSSM only acts on the feature fusion part of the last fusion module.
7. The deep hash image retrieval method based on frequency domain decoupling and visual Mamba according to claim 6 is characterized in that: A parallel convolution branch is added outside the two-dimensional state space to form a hybrid selection state space module. The two-dimensional state space consists of a cross scanning operation, an S6 block, and a sequence merging operation. First, the image is scanned in parallel along four directions: from top left to bottom right, from top right to bottom left, from bottom right to top left, and from bottom left to top right; each sequence in different directions is simultaneously subjected to state space operations through the S6 block. The operation process is formalized by a linear ordinary differential equation as follows: Where u(t)∈R U Represents a series of continuous input information, v(t)∈R V Represents the output information, g(t)∈R W is the intermediate hidden state, A∈R W×W represents the state transfer matrix, B∈R W×U represents the control input matrix, C∈R M×W Denotes the output matrix, D∈R M×U represents the feedforward matrix; The discrete time parameters are constructed by using the time scale parameter Δ: in, By maintaining and updating these time parameters, image features are dynamically selected to simulate and predict the dynamic changes of image data. After being processed by the state-space model, each sequence is reshaped into a feature map shape, and then they are stacked and summed in the channel dimension to obtain the final output features.
8. The deep hash image retrieval method based on frequency domain decoupling and visual Mamba according to claim 7 is characterized in that: Add a convolution branch based on the two-dimensional state space, specifically: First, the input features are divided into two parts of the same size f conv and f ssm , one part of which passes through the convolution branch and the other part passes through the state model branch; In the convolution branch, the input f is again conv Divide into four parts f1, f2, f3 and f4, which are respectively subjected to square convolution and vertical and horizontal strip convolution and jump connection operations, and then concatenated: Among them, k represents the size of the convolution kernel, ξ is the scaling factor when dividing the branches, represents the convolution operation, Represents a splicing operation; The obtained feature map is combined with the state space model branch output F ssm A SiLU(·) gating function is added before feature fusion; Finally, the features of the two branches are concatenated and fused using a 1×1 convolution:
9. The deep hash image retrieval method based on frequency domain decoupling and visual Mamba according to claim 8 is characterized in that: The loss function uses global similarity proxy loss, which is expressed as: THE GP =L G +λL P ; Among them, λ is a hyperparameter, represents the class proxy real-valued hash code, μ is a hyperparameter, B represents the mini-batch, Represents the true label y i The normalized result, ε is the balance parameter, N c represents the number of categories, and T represents the transposition operation.
10. A deep hash image retrieval method based on frequency domain decoupling and visual Mamba according to claim 9, characterized in that: The optimization process of binary hash codes is regarded as a binary classification problem for each bit symbol of continuous real-valued hash codes. First, a Gaussian probability model is defined: And assign +1 and -1 to the target mean to get two estimators and Calculate the probability of +1 and -1 for each hash code element, where k = 1, 2, ..., N bits , they use the same standard deviation δ; then generate the corresponding binary label b + and b - , these labels reflect the expected binary state of the hash code elements: A binary cross entropy loss function is used to evaluate the consistency between the model output and these binary labels:
Citation Information
Patent Citations
Video detection method and device, equipment, storage medium and program product
CN115690645A
Distribution difference adaptive image retrieval method based on space-frequency interaction
CN117370594A
Deep hash image retrieval method based on improvement of efficient semantics
CN117421440A
System and Method for Extremely Efficient Image and Pattern Recognition and Artificial Intelligence Platform
US20200184278A1
Systems and methods for a connected computing resource and event / activity identification information infrastructure using near existential or existential biometric identification of humans
US20230376581A1
Cited By
Plant disease detection method based on state space model and Fourier transform
CN119169471A
A plant disease detection method based on state space model and Fourier transform
CN119169471B
Space-time decoupling feature fusion method and system based on space-time bidirectional Vision Mama
CN119693751A
Infrared dual-band image fusion method based on self-attention and space-frequency domain cross fusion
CN119784606A
An infrared dual-band image fusion method based on self-attention and spatial-frequency domain cross fusion
CN119784606B
