Image retrieval method based on hierarchical hash floating point features, storage medium and product
Through the image retrieval method of hierarchical hash floating point features, combined with knowledge distillation and teaching assistant mechanism, it solves the problem of low retrieval efficiency of deep hash algorithm in large-scale image databases, achieves efficient and accurate image retrieval, and meets the real-time requirements. sexual needs.
Patent Information
- Application Number
- CN202410659880.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-27
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2044-05-27
AI Technical Summary
The existing deep hashing algorithm is not efficient in retrieving large-scale image databases, resulting in slow search speed and reduced accuracy, making it difficult to meet real-time requirements.
An image retrieval method based on hierarchical hash floating point features is adopted. By constructing a deep floating point feature network and a hierarchical hash-floating point feature network, the knowledge distillation and teaching assistant mechanism are used to train the model to generate multi-layer deep hash features and floating point features. point features, and establish a hierarchical tree index for level-by-level search.
It improves the accuracy and efficiency of image retrieval, reduces the complexity of query algorithms, and meets the real-time needs of tasks such as pedestrian re-identification in large-scale spatio-temporal scenes.
Smart Images

Figure CN118585665A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image retrieval technology, and more specifically to an image retrieval method, storage medium and product based on knowledge distillation layered deep hash-floating point features. Background Art
[0002] Video images often contain a large amount of objective world information. Content-based image retrieval allows users to input a picture to find other pictures with the same or similar content. However, as the size of images in the image and video library increases, the speed of content-based image retrieval methods is also getting slower and slower, which brings great difficulties to the application of image retrieval technology.
[0003] Content-based image retrieval is one of the important topics in the field of information retrieval and computer vision. When establishing an image database, the system analyzes the input image and classifies it into a unified model. Then, it extracts image features based on various image models and stores them in the feature library. At the same time, it indexes the feature library to improve search efficiency. For feature extractors, it is necessary to have feature vectors with close distances for features of images with similar content. Distance measurement methods can use Euclidean distance, Hamming distance, cosine distance, etc.
[0004] The search for similar vectors, the features extracted from the image are usually high-dimensional information. Since the distance measurement method is used, directly measuring the similarity will result in a slow speed. Therefore, most heuristic search algorithms, or approximate nearest neighbor search algorithms, are used to find similar vectors. Specific categories include hashing, quantization, graph search and other methods. Among them, there are three main methods for extracting feature vectors: 1) Methods based on local descriptors, such as SIFT descriptors, but because the number of SIFT descriptors generated for a single image is uncertain, they are rarely used for retrieval; 2) Methods based on global descriptors, which are fused by local descriptors or directly extracted global descriptors, such as Fisher, Gist and other methods, which were commonly used methods before breakthroughs in neural network algorithms; 3) Methods based on convolutional neural networks. Convolutional neural networks can extract high-level descriptors, which contain more semantic information than lower-level features, and are invariant to scale, illumination, rotation, etc., and have stronger robustness, so they are more effective in actual use.
[0005] Since feature vectors are high-dimensional and sparse, it is not efficient to directly search for their nearest neighbor vectors. Therefore, it is usually necessary to obtain similar feature vectors through the approximate nearest neighbor search method. The approximate nearest neighbor methods can be mainly divided into three types: 1) Data-independent algorithms represented by Locality Sensitive Hashing; 2) Unsupervised data-related algorithms represented by Productive Quantization; 3) Data-related supervised algorithms represented by Deep Hashing with Convolutional Neural Networks. For the deep hashing algorithm, which currently has outstanding retrieval accuracy, a convolutional neural network is used to extract feature vectors from images and generate image indexes at the same time. The feature vectors extracted by the convolutional neural network provide more high-level semantic information than other low-level descriptors. The convolutional neural network can be used to make similar indexes at the semantic level more than other methods. By adding hidden layers to the CNN network and training the Fine-tune network, feature vectors are extracted from images and binary hash codes are directly generated for image retrieval. The two sub-problems of vector extraction and retrieval are combined into one. In order to effectively utilize the numerous manually extracted annotation information, the deep hashing algorithm can use supervised learning to calculate the hash and hash value distance of similar and dissimilar images input to the network through image label information, and add them to the loss function, and back-propagate the network weights. Thus, through supervision, the information about the similarity or dissimilarity of images can be learned.
[0006] However, the current deep hashing structure adopts a single-layer structure and a linear indexing and searching method, which is not efficient enough for the retrieval of large-scale image data sets. At the same time, the deep hashing algorithm uses a deep convolutional neural network to extract image features, and then compresses, reduces the dimension and binarizes the extracted feature vector to generate a binary vector. Due to the process of compression and dimensionality reduction, there is inevitably a loss of information, which leads to a reduction in the final retrieval accuracy. Every time a similar image is queried, each feature vector needs to be compared. If the size of the image database is N, the algorithm complexity of querying an image is O(N), so its performance continues to deteriorate as the data set expands. For large-scale databases, such as image databases of the order of 1 million, the time for image retrieval is currently thousands of times slower than the time for image processing to generate hash values. Therefore, it is difficult for existing deep hashing retrieval algorithms to achieve satisfactory results in terms of search speed and retrieval accuracy.
[0007] Therefore, how to improve the accuracy and efficiency of image search is an urgent problem to be solved by those skilled in the art. Summary of the invention
[0008] In view of this, the present invention provides an image retrieval method, storage medium and product based on hierarchical hash floating-point features, which can improve the image retrieval speed while ensuring that the retrieval accuracy is not reduced, and meet the real-time requirements of tasks such as pedestrian re-identification in large-scale spatiotemporal scenes.
[0009] In order to achieve the above object, the present invention adopts the following technical solution:
[0010] The image retrieval method based on hierarchical hash floating point features includes the following steps:
[0011] Step 1: Obtain a training sample image, build a deep floating-point feature network model, and use the training sample to train the deep floating-point feature network model to obtain the trained deep floating-point feature network model and the deep floating-point features of the training sample image;
[0012] Step 2: construct a deep hierarchical hash-floating-point feature network model based on the trained deep floating-point feature network model, and use the deep floating-point features of the training sample images for training, to obtain the trained deep hierarchical hash-floating-point feature network model and N layers of deep hash features of the training sample images, N ≥ 2, and each layer of deep hash features has different dimensions;
[0013] Step 3: Input the images in the image library to be retrieved into the deep hierarchical hash-floating point feature network model to obtain the image features of each image, including N layers of deep hash features and deep floating point features, and construct a hierarchical tree index of the image features of the image library to be retrieved;
[0014] Step 4: Input the image to be retrieved into the deep hierarchical hash-floating point feature network model to obtain its N-layer deep hash features and deep floating point features, and perform a level-by-level search in the hierarchical tree index of image features in the image library to output the retrieval results.
[0015] The dimensions of multiple deep hash features are different. For example, the first layer is a 128-dimensional deep hash feature, and the second layer is a 256-dimensional deep hash feature. Both layers of deep hash features can be used to uniquely represent images. During the retrieval process, the first layer of deep hash features are first used for comparison and sorting. Similar images are retained and then the second layer of deep hash features are used for comparison and sorting, and so on.
[0016] Preferably, the deep floating-point feature network model can be selected from various deep learning models such as HRNet, ResNet, and ViT.
[0017] Preferably, the specific implementation process of step 1 is:
[0018] Step 11: Annotate the training sample images with similarity information. Based on the similarity information of the training sample images and the back propagation algorithm, use the classification loss and triplet loss to supervise and complete the training of the deep floating-point feature network model.
[0019] Step 12: Input the training sample images into the trained deep floating-point feature network model to extract the deep floating-point features of all training sample images.
[0020] Preferably, the specific implementation process of step 2 is:
[0021] Step 21: Add a layered deep hash network model after the trained deep floating-point feature network model to construct a deep layered hash-floating-point feature network model; the layered deep hash network model includes N layers of output layers consisting of a fully connected layer, an activation function, and a sign function;
[0022] The layered deep hash network model is a multi-dimensional deep hash network model. The number of layers and dimensions of the N-layer deep hash features output by the deep layered hash-floating point feature network model are preset. The number of layers used by the model and the dimension of each layer of hash features are hyperparameters that can be set by the user according to their own database conditions.
[0023] Step 22: train the layered deep hash network model according to the similarity information and deep floating-point features of the training sample images, and update the parameters of the layered deep hash network model; input each training sample image into the deep layered hash-floating-point feature network model to obtain N layers of deep hash feature prediction results. If the difference between the dimension of the deep floating-point feature corresponding to each training sample image and the dimension of the first layer of deep hash feature prediction results is less than the set threshold, proceed to step 23, otherwise proceed to step 24;
[0024] The similarity guides the training of network model parameters so that the image features generated by the network continue to maintain the similarity; the lowest dimensional deep hash network model is trained according to the similarity information and deep floating point features of the training sample images to obtain the lowest dimensional deep hash features;
[0025] Step 23: Using the knowledge distillation method, the model loss is calculated based on the prediction results and similarity information of each layer of deep hash features, and the KL divergence is calculated based on the prediction results and deep floating point features of each layer as the knowledge distillation loss. The model loss and knowledge distillation loss of each layer are weighted averaged, and the parameters of the hierarchical deep hash network model are updated through back propagation.
[0026] Step 24: Use the knowledge distillation method and teaching assistant mechanism to update the parameters of the hierarchical deep hashing network model;
[0027] Step 241: using a knowledge distillation method, calculating a model loss according to the N-layer hash feature prediction results and similarity information, and calculating a KL divergence according to the N-layer deep hash feature prediction results and deep floating point features as a knowledge distillation loss;
[0028] Step 242: The remaining N-1 layers of deep hash feature prediction results are respectively used to calculate the model loss with the similarity information, and the KL divergence is calculated based on the current layer of deep hash feature prediction results and the previous layer of deep hash feature prediction results as knowledge distillation;
[0029] Step 243: Update the parameters of the hierarchical deep hashing network model by back propagation after weighted averaging the model loss and knowledge distillation loss of each layer;
[0030] Step 25: The deep floating-point feature network model and the updated hierarchical deep hash network constitute a trained deep hierarchical hash-floating-point feature network model.
[0031] The knowledge distillation method and teaching assistant mechanism are used to update the parameters of the deep hierarchical hash-floating feature network model. The knowledge distillation method is used to calculate the prediction results of the hash features and the model loss of the true labels. For the highest-dimensional deep hash features, the KL divergence of the deep hash feature prediction results and the deep floating-point feature prediction results is calculated as the knowledge distillation loss. For the non-highest-dimensional deep hash features, the KL divergence of the current layer deep hash feature prediction results and the previous layer high-dimensional deep hash feature prediction results is calculated as the knowledge distillation loss. The model loss and the knowledge distillation loss are weighted averaged, and the parameters of the deep hierarchical hash-floating feature network model are updated through back propagation.
[0032] Preferably, the specific implementation process of step 3 is:
[0033] Step 31: Input the images of the image library to be retrieved into the deep layered hash-floating point feature network model to obtain N layers of deep hash features and deep floating point features for each image;
[0034] Step 32: Establish a tree index according to the obtained N-layer deep hash features and deep floating point features;
[0035] Select an image, calculate the similarity between the first-layer deep hash features of the current image and other images, and classify them according to the set similarity threshold. Images with similarity greater than the similarity threshold and other images are divided into two groups of advanced hash index classes respectively;
[0036] In each group of advanced hash index classes, the similarity between the second-layer deep hash features of the current image and other images is calculated, and classification is performed according to the set similarity threshold. Images greater than the similarity threshold and other images are divided into two groups of sub-advanced hash index classes respectively; each level of hash index class is divided in turn according to the next layer of deep hash features. The last level of hash index class contains several images, and the corresponding several deep floating-point features are stored as a list. At the same time, the file path or ID of the corresponding image is recorded to form a tuple, and a hierarchical tree index is obtained.
[0037] First, use high-level (low-dimensional) hash index for classification. Each category contains several levels of low-level (high-dimensional) hash indexes. Several low-level (high-dimensional) indexes are repeatedly classified according to the highest-level (lowest-dimensional) hash index until only the last-level (highest-dimensional) hash index remains. The last-level hash index may contain several floating-point feature indexes, which are stored as a list. Each item in the list is a tuple that records the image file path or ID and the corresponding floating-point feature index, and a hierarchical tree index is obtained.
[0038] First, the deep floating-point feature network model is trained based on the image similarity information to obtain the deep floating-point features. Then, the lowest-dimensional hierarchical deep hash network model is trained based on the deep floating-point features to obtain the lowest-dimensional N-layer deep hash features. Then, the high-dimensional N-layer deep hash features are trained based on the low-dimensional N-layer deep hash features in turn, and finally the highest-level (lowest-dimensional) deep hash features are obtained. The deep hash features of all different levels (dimensions) constitute the multi-dimensional hierarchical deep hash features, and then the deep floating-point features obtained first are added to obtain the hierarchical deep hash-floating-point features.
[0039] Preferably, the specific implementation process of step 4 is:
[0040] Step 41: input the image to be retrieved into the deep layered hash-floating point feature network model to obtain its N-layer deep hash features and deep floating point features;
[0041] Step 42: perform hierarchical retrieval in the order from the root node to the leaf node of the hierarchical tree index; starting from the first level, calculate the distance between the N-layer deep hash features of the image to be retrieved and the N-layer deep hash features of the nodes in the hierarchical tree index of the image library to be retrieved, as well as the distance between the deep floating-point features of the image to be retrieved and the deep hash features of the nodes, and sort them according to the distance. In each level of retrieval, filter the images corresponding to some N-layer deep hash features according to the set ratio based on the sorting results. The last level of retrieval is sorted according to the distance between the deep floating-point features of the filtered image and the deep floating-point features of the leaf nodes, select the image in the image library to be retrieved with the smallest distance as the retrieval result, and output the retrieval result.
[0042] According to the order from the root to the leaf node of the hierarchical tree index, that is, from low-dimensional deep hash features, high-dimensional deep hash features to deep floating-point features from coarse to fine, the distances between the N-layer deep hash features and deep floating-point features of the image to be retrieved and the corresponding dimensional features in the hierarchical tree index of the image features of the image library are calculated step by step. The first-layer deep hash features of the image to be retrieved are only calculated with the first-layer deep hash features of the images in the image library to be retrieved. The N-th layer deep hash features of the image to be retrieved are only calculated with the N-th layer deep hash features of the images in the image library, and the deep hash feature values that exceed the given threshold distance range are filtered according to a certain set ratio. For example, under the condition of retaining a ratio of 0.2, the image to be retrieved and 1000 images in the image library are sorted using the distance of the first layer deep hash features, and the first 200 images with the closest distance to the image to be retrieved are retained to enter the next layer of retrieval, and finally the retrieval results are output based on the distance sorting of the last layer of deep floating-point features. Through each layer of feature sorting, a part of the images with the highest ranking are selected to enter the next layer of retrieval. Therefore, the hash feature actually plays the role of screening images. Each layer of hash features will reduce the number of images that need to be compared. In the end, only a small part of the images will be sorted by the last layer of floating-point features to output the retrieval results.
[0043] It can be seen from the above technical solutions that, compared with the prior art, the present invention discloses an image retrieval method, storage medium and product based on hierarchical hash floating-point features, which performs efficient image retrieval based on knowledge distillation hierarchical deep hash-floating-point features, effectively improving the accuracy and efficiency of image search. It can be widely used in computer vision tasks such as pedestrian / vehicle re-identification, target classification and recognition, and natural language processing tasks such as knowledge graph relationship classification and link prediction, and tasks that also require feature similarity calculation to achieve efficient retrieval. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0045] Figure 1 The accompanying drawing is a schematic diagram of the process flow of the image retrieval method based on layered hash floating point features provided by the present invention;
[0046] Figure 2 The accompanying drawings are schematic diagrams of the structure of the hierarchical hash feature part and the floating point feature part of the convolutional neural network model provided by the present invention;
[0047] Figure 3The accompanying drawing is an example diagram of the retrieval process provided by the present invention. DETAILED DESCRIPTION
[0048] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0049] The embodiment of the present invention specifically discloses an image retrieval method based on hierarchical hash floating point features, comprising the following steps:
[0050] S1: Obtain training sample images and annotate similarity information; construct a deep floating-point feature network model, and use the training sample images and their corresponding similarity information to train the deep floating-point feature network model using a back-propagation algorithm to obtain the trained deep floating-point feature network model and the deep floating-point features of all training sample images;
[0051] S11: The deep floating-point feature network model can use various deep learning models such as HRNet, ResNet, ViT, etc.
[0052] S12: For the network model selected in S11, supervise and complete the training of the deep floating-point feature network model based on the similarity information of the training sample image annotations and the back propagation algorithm;
[0053] S13: inputting all training sample images into the trained deep floating-point feature network model to extract deep floating-point features of all training sample images;
[0054] S2: Based on the trained deep floating-point feature network model and the deep floating-point features of all training sample images, a knowledge distillation method is used to construct and train a deep hierarchical hash-floating-point feature network model to obtain hierarchical deep hash features of all training sample images;
[0055] S21: Add multiple layers of fully connected layers, activation functions, and sign functions as output layers of different dimensions after the trained deep floating-point feature network model to build a hierarchical hash-floating-point feature network model;
[0056] S22: During the training process, the parameters of the deep floating-point feature network model constructed in S1 are fixed, and only the parameters of the newly added hierarchical hash-floating-point feature network model in S21 are trained and optimized;
[0057] S23: In the training process of the deep hierarchical hash network model, the knowledge distillation method is used, that is, in addition to calculating the prediction results of the hash feature and the loss of the true label, the KL divergence of the deep hash feature prediction results and the deep floating point feature prediction results is calculated as the loss of knowledge distillation, and the parameters of the newly added hierarchical hash-floating point feature network model are updated through back propagation after the weighted average of the two parts of the loss;
[0058] S24: When the dimension of the deep floating-point feature is significantly different from that of the deep hash feature, an assistant teaching mechanism can be added on the basis of S23, that is, the deep floating-point feature network model (i.e., the teacher) guides the training of the high-dimensional hash feature model (i.e., the assistant teaching), and then the high-dimensional hash feature model (i.e., the assistant teaching) guides the low-dimensional hash feature model (i.e., the student), so as to achieve layer-by-layer distillation and accelerate convergence; specifically, for the highest-dimensional deep hash feature, the network is trained according to S23; the KL divergence of the prediction results of the deep hash feature and the prediction results of the deep floating-point feature is calculated as the knowledge distillation, and the loss guides the training; for the non-highest-dimensional deep hash feature, the KL divergence of the prediction results of the current layer deep hash feature and the prediction results of the previous layer high-dimensional deep hash feature is calculated as the loss of knowledge distillation, and the loss of the prediction results of the current layer hash feature and the true label is calculated, and the two parts of the loss are weighted averaged, and the parameters of the newly added hierarchical hash-floating feature network model are updated through back propagation;
[0059] S3: Input the images in the image library into the deep hierarchical hash-floating point feature network model to obtain hierarchical deep hash features and deep floating point features of different dimensions for each image, and construct a hierarchical tree index of the image features of the image library;
[0060] S31: Input the images in the image library into the deep hierarchical hash-floating point feature network model to obtain hierarchical deep hash features and deep floating point features of different dimensions for each image;
[0061] S32: A tree index is established according to the obtained hierarchical hierarchical hash-floating point features. A high-level (low-dimensional) hash index is first used for classification. Each category contains several levels of low-level (high-dimensional) hash indexes. Several low-level (high-dimensional) indexes are repeatedly classified according to the highest-level (lowest-dimensional) hash index, until only the last-level (highest-dimensional) hash index remains.
[0062] S33: The last level hash index obtained in S32 may contain several floating point feature indexes, which are stored as a list, each item in the list is a two-tuple that records the image file path or ID and the corresponding floating point feature index;
[0063] S4: Input the image to be retrieved into the deep hierarchical hash-floating point feature network model to obtain its hierarchical hash features and deep floating point features, and perform a level-by-level search in the hierarchical tree index of the image features in the image library, and output the retrieval results based on the distance sorting of the last layer of deep floating point features;
[0064] S41: Input the image to be retrieved into the deep hierarchical hash-floating point feature network model to obtain its hierarchical deep hash features and deep floating point features;
[0065] S42: According to the order from the root of the hierarchical hash index to the leaf node, that is, according to the coarse to fine order of low-dimensional deep hash features, high-dimensional deep hash features to deep floating-point features, the distance between the hierarchical deep hash features and deep floating-point features of the image to be retrieved and the corresponding dimensional features in the hierarchical tree index of the image features of the image library is calculated step by step, and the deep hash feature values that exceed the given threshold distance range are filtered out according to a certain ratio, and finally the retrieval results are output based on the distance sorting of the last layer of deep floating-point features.
[0066] In a specific embodiment, a method for image retrieval based on knowledge distillation layered deep hash-floating point features is disclosed. To address the problem of slow speed and low precision of deep hash image retrieval methods, a floating point feature network is used to fit the trained image library, and the obtained floating point features are used to extract layered hash values through knowledge distillation. By establishing a tree index for the layered hash-floating point values, the search process can use the comparison of high-level hash values to cut off some branches that do not need to be searched further, thereby greatly accelerating the search process. In the last layer, accurate floating point features are used for local sorting, thereby improving the accuracy of the final retrieval results. The accuracy and efficiency of content-based image search problems are guaranteed.
[0067] The overall process is as follows Figure 1 , including the training of floating point feature network, the training of layered hash neural network, the hash extraction of image library and the establishment of tree hash index, and the retrieval of query image. The specific steps include:
[0068] S1: Use the labeled image library that needs to be retrieved to train the floating point feature network;
[0069] Specifically, first use the labeled image library to train the deep convolutional neural network to extract the floating-point features of the image; the deep convolutional neural network used can select the current mainstream model for image classification, such as ResNet, HRnet, ViT, etc.; during the training process, use classification loss and triplet loss to supervise the training of the deep floating-point feature network model, and obtain the trained deep floating-point feature network model and the deep floating-point features of all training sample images;
[0070] S2: Use the labeled image library to be retrieved and the deep floating-point features generated in S1 to train the hierarchical hash neural network to obtain a deep hierarchical hash-floating-point feature network model;
[0071] The layered hash neural network is obtained by passing the deep floating-point features generated by the deep floating-point feature network model through multiple layers of fully connected layers, and then through activation functions and sign functions. The activation function after the fully connected layer makes the value of each dimension in the feature distributed near 0, reducing the information loss after binarization by the sign function. At the same time, the number of layers of the layered hash neural network and the length of each hash feature layer are specified by the user. A larger image library can use a deeper number of layers, and applications with higher retrieval accuracy requirements can use longer hash layers.
[0072] The deep layered hash-floating feature network model is connected as follows Figure 2 As shown, it is an N-level hierarchical hash-floating point network using knowledge distillation in this specific embodiment; during training, the floating point feature network is first trained by using the labeled image library Training Set as the training set to obtain floating point features. After the floating point feature network achieves the optimal effect, the parameters of the floating point feature network, that is, the parameters of the deep floating point feature network model, are fixed; the obtained floating point features are respectively passed through N hash layers to generate N hash features of different lengths. In the process of training the hash layers, as shown in FIG. Figure 2 As shown, if only the knowledge distillation method is used, as shown by the dotted line connection relationship in the figure, in addition to calculating the loss of the prediction result of the hash feature and the true label, the KL divergence of the prediction result of the deep hash feature and the prediction result of the deep floating-point feature is also calculated as the loss of knowledge distillation, and the parameters of the hierarchical hash network model are updated through back propagation after the weighted average of the two parts of the loss; when the dimension of the deep floating-point feature is quite different from the dimension of the deep hash feature, an assistant teaching mechanism can be added on the basis of the knowledge distillation method, as shown by the short dotted line in the figure, the N-th level hash feature calculates the loss of the prediction result of the deep hash feature and the prediction result of the deep floating-point feature through the KL divergence to guide the training (loss), the first level hash feature calculates the loss of the prediction result of the deep hash feature and the prediction result of the second level feature through the KL divergence to guide the training, and the second level hash feature also calculates the loss of the prediction result of the deep hash feature and the prediction result of the third level feature through the KL divergence to guide the training, and so on to achieve the effect of layer-by-layer distillation and accelerated convergence;
[0073] S3: extracting feature values from the image library to be searched and establishing a tree-like hash index for the extracted hash-floating point values;
[0074] Specifically, all images that need to be stored are input into the trained deep layered hash-floating point feature network model, and the hash feature values of each hash layer and the final floating point feature value are output;
[0075] For the hierarchical hash-float algorithm, the images can be classified according to the first-level hash features first, and the images with similar first-level hash feature distances can be stored in similar locations;
[0076] If there are only two levels of indexes, after the advanced indexing, there is only one level of index left, which can be stored as a list. Each item in the list is a two-tuple that records the image file path or ID and the low-level index at the same time. If there are three or more levels of indexes, then after the above steps, there are two or more levels of indexes under each advanced hash value, and it is necessary to continue to classify according to the higher-level hash values until only one level of index is left. Finally, each item stored in a list is a two-tuple that records the image file path or ID and the low-level index at the same time.
[0077] S4: Search for relevant images through hierarchical retrieval;
[0078] like Figure 3 , is an example of a hierarchical retrieval process. When querying, the image to be retrieved is first input into the generated deep hierarchical hash-floating point feature network model to obtain the corresponding hierarchical hash-floating point features (hash-floating point values). The Hamming distance between the first-level hash features of the image to be retrieved and the first-level hash features of all images in the database is calculated. After sorting, a certain proportion of the top-ranked images are retained to enter the next level of retrieval. The specific retention ratio can be specified by the user, and its size will affect the speed and accuracy of the retrieval process, such as Figure 3 As shown in the figure, after the first-level hash feature sorting, a portion of the images are sorted using the second-level hash feature, and a certain proportion of the images enter the next level of retrieval. This is repeated until only a small number of images are sorted locally using higher-dimensional and more accurate deep floating-point features, and the results are used as the final results. If only the top 20% of each level of index is retained and entered into the next level, then the number of images retrieved using floating-point features will only be 100% of the previous number. , where N is the number of layers of hierarchical hashing, which greatly reduces the amount of calculation and significantly improves the retrieval efficiency.
[0079] For the segmented search algorithm, you can adjust the number of segments (N) and the segment length (K) to adjust the algorithm. The larger N is, the more obvious the acceleration of the search, but the accuracy may decrease. In practical applications, it is necessary to select appropriate parameters. By controlling the ratio of layered filtering with different numbers of layers, you can choose between the speed and accuracy of the search.
[0080] In addition, the principles of the present invention can also be used for efficient calculation of feature similarity in computer vision tasks such as pedestrian / vehicle re-identification and target classification and recognition, and natural language processing tasks such as knowledge graph relationship classification and link prediction.
[0081] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0082] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. An image retrieval method based on hierarchical hash floating point features, It is characterized in that The following steps are involved: Step 1: Obtain a training sample image, build a deep floating-point feature network model, and use the training sample image to train the deep floating-point feature network model to obtain the trained deep floating-point feature network model and the deep floating-point features of the training sample image; Step 2: construct a deep hierarchical hash-floating-point feature network model based on the trained deep floating-point feature network model, and use the deep floating-point features of the training sample images for training to obtain the trained deep hierarchical hash-floating-point feature network model and N layers of deep hash features of the training sample images, N ≥ 2; each layer of deep hash features has different dimensions; Step 3: Input the images in the image library to be retrieved into the deep hierarchical hash-floating point feature network model to obtain the image features of each image, including N layers of deep hash features and deep floating point features, and construct a hierarchical tree index of the image features of the image library to be retrieved; Step 4: Input the image to be retrieved into the deep hierarchical hash-floating point feature network model to obtain its N-layer deep hash features and deep floating point features, and perform a level-by-level search in the hierarchical tree index to output the retrieval results.
2. The image retrieval method based on layered hash floating point features according to claim 1, It is characterized in that The specific implementation process of step 1 is as follows: Step 11: Annotate the training sample images with similarity information, and supervise and complete the training of the deep floating-point feature network model based on the similarity information annotated by the training sample images and the back propagation algorithm; Step 12: Input the training sample image into the trained deep floating-point feature network model to extract the deep floating-point features of the training sample image.
3. The image retrieval method based on layered hash floating point features according to claim 2, It is characterized in that The specific implementation process of step 2 is: Step 21: Add a layered deep hash network model after the trained deep floating-point feature network model to construct a deep layered hash-floating-point feature network model; The hierarchical deep hashing network model includes N layers of output layers consisting of fully connected layers, activation functions, and sign functions; Step 22: train the layered deep hash network model according to the similarity information and deep floating-point features of the training sample images, and update the parameters of the layered deep hash network model; input each training sample image into the deep layered hash-floating-point feature network model to obtain N layers of deep hash feature prediction results. If the difference between the dimension of the deep floating-point feature corresponding to each training sample image and the dimension of the first layer of deep hash feature prediction results is less than the set threshold, proceed to step 23, otherwise proceed to step 24; Step 23: Using the knowledge distillation method, the model loss is calculated based on the prediction results and similarity information of each layer of deep hash features, and the KL divergence is calculated based on the prediction results and deep floating point features of each layer as the knowledge distillation loss. The model loss and knowledge distillation loss of each layer are weighted averaged, and the parameters of the hierarchical deep hash network model are updated through back propagation. Step 24: Use the knowledge distillation method and teaching assistant mechanism to update the parameters of the hierarchical deep hashing network model; Step 241: using a knowledge distillation method, calculating a model loss according to the N-layer hash feature prediction results and similarity information, and calculating a KL divergence according to the N-layer deep hash feature prediction results and deep floating point features as a knowledge distillation loss; Step 242: The remaining N-1 layers of deep hash feature prediction results are respectively used to calculate the model loss with the similarity information, and the KL divergence is calculated based on the current layer of deep hash feature prediction results and the previous layer of deep hash feature prediction results as knowledge distillation; Step 243: Update the parameters of the hierarchical deep hashing network model by back propagation after weighted averaging the model loss and knowledge distillation loss of each layer; Step 25: The deep floating-point feature network model and the updated hierarchical deep hash network constitute a trained deep hierarchical hash-floating-point feature network model.
4. The image retrieval method based on layered hash floating point features according to claim 1, It is characterized in that The specific implementation process of step 3 is as follows: Step 31: Input the images of the image library to be retrieved into the deep layered hash-floating point feature network model to obtain N layers of deep hash features and deep floating point features for each image; Step 32: Establish a tree index according to the obtained N-layer deep hash features and deep floating point features; Select an image, calculate the similarity between the first-layer deep hash features of the current image and other images, and classify them according to the set similarity threshold. Images with similarity greater than the similarity threshold and other images are divided into two groups of advanced hash index classes respectively; In each group of advanced hash index classes, the similarity between the second-layer deep hash features of the current image and other images is calculated, and classification is performed according to the set similarity threshold. Images greater than the similarity threshold and other images are divided into two groups of sub-advanced hash index classes respectively; each level of hash index class is divided in turn according to the next layer of deep hash features. The last level of hash index class contains several images, and the corresponding several deep floating-point features are stored as a list. At the same time, the file path or ID of the corresponding image is recorded to form a tuple, and a hierarchical tree index is obtained.
5. The image retrieval method based on layered hash floating point features according to claim 1, It is characterized in that The specific implementation process of step 4 is as follows: Step 41: input the image to be retrieved into the deep layered hash-floating point feature network model to obtain its N-layer deep hash features and deep floating point features; Step 42: perform hierarchical retrieval in the order from the root node to the leaf node of the hierarchical tree index; starting from the first level, calculate the distance between the N-layer deep hash features of the image to be retrieved and the N-layer deep hash features of the nodes in the hierarchical tree index of the image library to be retrieved, as well as the distance between the depth floating-point features of the image to be retrieved and the depth floating-point features of the nodes, and sort them according to the distance. In each level of retrieval, filter the images corresponding to some N-layer deep hash features according to the set ratio based on the sorting results. The last level of retrieval is sorted according to the distance between the depth floating-point features of the filtered image and the depth floating-point features of the leaf nodes, select the image in the image library to be retrieved with the smallest distance as the retrieval result, and output the retrieval result.
6. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
7. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Deep hash and GPU acceleration-based large-scale image retrieval method
CN108920720A
A method of generating a hash code for image retrieval using a deep convolutional network
CN109800314A
A compact Hash code learning method based on semantic protection
CN109918528A
Large-scale image retrieval method based on hierarchical deep Hashing
CN111177432A
Face retrieval method and system, computer equipment and storage medium
CN113569626A
