Multi-negative example hash image retrieval method and system for class center loss of smart oil field
By adopting the multi-negative example hashing method based on class center loss in the image retrieval system, and using the convolutional neural network and similarity matrix to update parameters, the problems of real-time retrieval and hash code distance control in the existing technology are solved and achieved. More efficient image retrieval.
Patent Information
- Application Number
- CN202310145702.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-21
- Publication Date
- 2024-08-23
AI Technical Summary
The nearest neighbor search method in the existing technology is difficult to meet the real-time requirements in larger-scale image retrieval systems, the deep supervised hashing method cannot effectively control the distance between hash codes, and the utilization rate of label information is insufficient.
A multi-negative example hash image retrieval method based on class center loss is used to obtain the class center position of the image through a convolutional neural network, construct a similarity matrix and loss function, and use the calculus chain rule to update network parameters and control the hash code distance to improve retrieval accuracy.
The accuracy and efficiency of image retrieval are improved, target images can be retrieved more quickly and accurately, and the performance of the image retrieval system is improved.
Smart Images

Figure CN118535752A
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of image retrieval, and relates to a multi-negative hash image retrieval method and system based on class center loss for smart oil fields. Background Art
[0002] Smart oilfield is a development concept of oilfield information construction, that is, to comprehensively utilize information technologies such as 5G and the Internet of Things to upload relevant data and information collected at the production site to the server in real time, so as to realize intelligent perception, tracking and monitoring of the site; to use big data and cloud computing technology to process and analyze the massive data collected, and to establish an optimization model for production, management and decision-making, so as to monitor, warn, manage and make decisions on the entire production process. While increasing production, it can also reduce the cost budget of the actual production process of the mailing company and increase the safety of the production process. Therefore, at this stage, smart oilfield has become the key mining technology used by oilfield companies in the actual development process.
[0003] Using video surveillance, combined with robot inspection, drone pipeline inspection and VR inspection, we can achieve all-weather monitoring of the oil field without blind spots. The unmanned operation of the oil field is an indispensable part of the smart oil field. Unmanned operation generates a huge amount of image data, which continues to grow exponentially over time. Quickly and accurately retrieving similar images to user queries has always been the goal of image retrieval technology. Quick, accurate and convenient retrieval from massive images can free image data managers from heavy manual labor.
[0004] Currently, many applications require the use of image retrieval technology to quickly retrieve target images. For example, in face recognition applications, image retrieval technology is used to extract high-level semantic features such as texture, color, and gradient of personal facial images as image features to calculate the similarity between images and achieve image retrieval. For example, in the image search application of Visual China, image retrieval technology is used to describe the image in text, extract tag information such as keywords, and search for corresponding images by searching keywords.
[0005] Classic content-based image retrieval methods mainly include nearest neighbor search method, deep supervised hashing method, etc. The nearest neighbor search method is given a database point set S and a query point q∈M in the scale space M, and finds the point closest to q in S, which is considered to be the search result. Where M is a multidimensional Euclidean space, and the distance is determined by the Euclidean distance. The deep supervised hashing method binarizes the feature vector of the image, converts the problem into a binary vector and then compares it. Similar images should be encoded as similar binary codes in the Hamming space.
[0006] Although the classical methods can complete data retrieval, the above methods also have shortcomings. The nearest neighbor search method is a brute force search method. In a large-scale image retrieval system, it is difficult to meet the real-time requirements. The deep supervised hashing method uses a quantization-based loss function and uses binary and triplet loss design. It does not control the distance between hash codes well, and the label information utilization is insufficient. Summary of the invention
[0007] The purpose of the present invention is to solve the problems in the prior art that the nearest neighbor search method is difficult to meet the real-time requirements in a large-scale image retrieval system, the deep supervised hashing method cannot control the distance between hash codes, and the label information utilization rate is insufficient, and to provide a multi-negative example hashing image retrieval method and system based on class center loss for smart oil fields.
[0008] In order to achieve the above object, the present invention adopts the following technical solutions:
[0009] The multi-negative hash image retrieval method based on class center loss for smart oil fields includes:
[0010] Step 1: Collect training set images and divide them into several categories; initialize the convolutional neural network information at the same time;
[0011] Step 2: Determine whether the current training round number iter is greater than the initial pre-training round number s. If so, obtain the class center position of each class image based on the training set image; if not, proceed to step 3;
[0012] Step 3: Shuffle the order of the training set images and randomly select several image samples to construct a similarity matrix. Based on the similarity matrix and the class center position, obtain the loss function of the convolutional neural network.
[0013] Step 4: Based on the chain rule in calculus, propagate the loss function of the convolutional neural network from back to front, calculate the gradient and update the parameters of each layer of the convolutional neural network;
[0014] Step 5: Determine whether the current number of training rounds iter is greater than the maximum number of iterations Maxiter; if so, the training is completed, and the convolutional neural network with trained parameters is output to obtain the target image; otherwise, repeat steps 2 to 4 to continue training until the training is completed.
[0015] A further improvement of the present invention is:
[0016] Furthermore, the set of training set images is: image dataset X = {x1, x2, ..., x m} and dataset labels L = {l1,l2,...,l m}; The convolutional neural network information includes: initial learning rate, initial weight decay rate, maximum number of iterations Maxiter, batchsize value, initial hash loss weight α, class center loss weight β, initial number of pre-training rounds s < Maxiter, number of rounds for calculating class center interval k < Maxiter, and current training round iter.
[0017] Furthermore, when determining whether the current training round iter is greater than the initial number of pre-training rounds s, it also includes: the relationship between the current training round iter and the number of rounds for class center interval k is: iter = k + i×k.
[0018] Furthermore, based on the training set images, obtain the class center positions of each class of images, specifically: input the training set images into the convolutional neural network, and extract the image features u through the convolutional layer, pooling layer, and fully connected layer of the convolutional neural network; calculate the class center of each class according to the label values k = {k 1 , k 2 ,..., k c}; where k j = Σ j u j .
[0019] Furthermore, construct a similarity matrix, specifically:
[0020] Divide the image samples into two tuples Q1 and Q2, then transpose the Q2 labels, and construct a label similarity matrix S through the supervision information of Q1 and Q2 l ; if s i = s j = 1, then s ij = 1, meaning that x i and x j are similar, otherwise s ij = 0 means that x i and x j are not similar;
[0021] Send the image samples into the convolutional neural network to obtain the hashed feature vectors U, V; transpose the feature vector V, and construct a similarity matrix S through the training data of the feature vectors U, V im ; where s ij = 0 means that xi and x j are not similar, s ij = 1 means that x i and x j are similar.
[0022] Furthermore, based on the similarity matrix and the class center positions, obtain the loss function of the convolutional neural network, specifically:
[0023] If the current number of training rounds does not exceed the number of initial pre-training rounds, that is, iter≤s; based on the label similarity matrix S l and the training data similarity matrix S im Get the loss function Loss;
[0024] If the current number of training rounds exceeds the initial number of pre-training rounds, that is, iter>s; based on the label similarity matrix S l , training data similarity matrix S im And the center position of each class, get the loss function Loss.
[0025] Furthermore, based on the label similarity matrix S l and the training data similarity matrix S im Get the loss function Loss, specifically:
[0026]
[0027] Among them, η is the scaling factor; margin is the interval parameter; α is the hyperparameter; Γ q is the positive example set of query q; q is the negative example set of query q;
[0028] The label similarity matrix S l , training data similarity matrix S im And the center position of each class, get the loss function Loss, specifically:
[0029]
[0030] in, The i in represents the category, and t represents the number in this category.
[0031] Furthermore, the loss function of the convolutional neural network is propagated from back to front by the convolutional neural network, and the gradient is calculated to update the parameters of each layer of the convolutional neural network, specifically:
[0032]
[0033] The multi-negative hash image retrieval system based on class center loss for smart oil fields includes:
[0034] An initialization module, wherein the initialization module collects training set images and divides the training set images into several classes; and initializes the convolutional neural network information at the same time;
[0035] A first judgment module, wherein the first judgment module judges whether the current training round number iter is greater than the initialization pre-training round number s, and if so, obtains the class center position of each class image based on the training set image; if not, enters the construction module;
[0036] A construction module, wherein the construction module shuffles the order of the training set images, randomly extracts a number of image samples, constructs a similarity matrix, and obtains a loss function of the convolutional neural network based on the similarity matrix and the class center position;
[0037] An update module, which propagates the loss function of the convolutional neural network from back to front based on the chain rule in calculus, calculates the gradient and updates the parameters of each layer of the convolutional neural network;
[0038] The second judgment module determines whether the current number of training rounds iter is greater than the maximum number of iterations Maxiter; if so, the training is completed, and the convolutional neural network with trained parameters is output to obtain the target image; otherwise, the training is continued until the training is completed.
[0039] Compared with the prior art, the present invention has the following beneficial effects:
[0040] The present invention obtains the center point of each class in the training set image and constructs a similarity matrix through image samples. Based on the similarity matrix and the class center position, the loss function of the convolutional neural network is obtained; the loss function is propagated from the back to the front by the convolutional neural network, and the gradient is calculated to update the parameters of each layer of the convolutional neural network. The present invention uses label supervision information to control the distance of image hash codes, improve the accuracy of image retrieval, and can more accurately and quickly retrieve target images, thereby improving image retrieval efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0042] Figure 1 A schematic diagram of the multi-negative hash image retrieval method based on class center loss for smart oil fields of the present invention;
[0043] Figure 2 Another schematic diagram of the multi-negative hash image retrieval method based on class center loss for smart oil fields of the present invention;
[0044] Figure 3 It is a schematic diagram of the multiple negative example process;
[0045] Figure 4 A schematic diagram of constructing multiple negative example tuples provided by the present invention;
[0046] Figure 5 It is a schematic diagram of the structure of the multi-negative example hash image retrieval system based on class center loss for smart oil fields of the present invention. DETAILED DESCRIPTION
[0047] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0048] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. 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] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0050] In the description of the embodiments of the present invention, it should be noted that if the terms "upper", "lower", "horizontal", "inner", etc. indicate an orientation or positional relationship based on the orientation or positional relationship shown in the drawings, or the orientation or positional relationship in which the product of the invention is usually placed when in use, it is only for the convenience of describing the present invention and simplifying the description, and does not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention. In addition, the terms "first", "second", etc. are only used to distinguish the description, and cannot be understood as indicating or implying relative importance.
[0051] In addition, if the term "horizontal" appears, it does not mean that the component must be absolutely horizontal, but can be slightly tilted. For example, "horizontal" only means that its direction is more horizontal than "vertical", which does not mean that the structure must be completely horizontal, but can be slightly tilted.
[0052] In the description of the embodiments of the present invention, it should also be noted that unless otherwise clearly specified and limited, if the terms "set", "install", "connect", "connection" appear, they should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be directly connected, or indirectly connected through an intermediate medium, and it can be the communication inside two components. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific situations.
[0053] The present invention will be further described in detail below with reference to the accompanying drawings:
[0054] See Figure 1 and Figure 2 , the present invention discloses a multi-negative example hashing image retrieval method based on class center loss for intelligent oilfields, including:
[0055] S101: Collect training set images and divide the training set images into several classes; at the same time, initialize the convolutional neural network information.
[0056] The set of training set images is: image data set X = {x1, x2,..., x m} and data set label L = {l1, l2,..., l m}; the convolutional neural network information includes: initialize the learning rate, initialize the weight decay rate, the maximum number of iterations Maxiter, the batchsize value, initialize the hashing loss weight α, the class center loss weight β, initialize the number of pre-training rounds s < Maxiter, calculate the number of rounds k < Maxiter for class center interval, and the current training round iter.
[0057] S102: Determine whether the current training round iter is greater than the initialized number of pre-training rounds s. If so, based on the training set images, obtain the class center positions of each class of images; if not, perform S103.
[0058] The relationship between the current training round iter and the class center interval round k is: iter = k + i × k.
[0059] Input the training set images into the convolutional neural network, extract the image features u through the convolutional layer, pooling layer and fully connected layer of the convolutional neural network; calculate the class center k = {k 1 , k 2 ,..., k c} of each class according to the label values; where k j = Σ j u j .
[0060] S103: Shuffle the order of the training set images, randomly extract a number of image samples, construct a similarity matrix, and obtain the loss function of the convolutional neural network based on the similarity matrix and the class center position.
[0061] Randomly sample 2n image samples, and use the collected samples to construct the similarity matrix and class center position to calculate the loss function. In the multi-negative loss, each query image q corresponds to a similar image q + and multiple dissimilar images q - ,like Figure 3 shown.
[0062] The image samples are divided into two tuples Q1 and Q2, and then the Q2 label is transposed. The label similarity matrix S is constructed through the supervision information of Q1 and Q2. l ;like Figure 4 As shown; if s i =s j =1, then s ij =1, which means x i and x j are similar, whereas s ij =0 means x i and x j not similar;
[0063] Send the image sample into the convolutional neural network to obtain the hashed feature vectors U, V; transpose the feature vector V, and construct the similarity matrix S through the training data of the feature vectors U, V im ; where s ij =0 means x i and x j Not similar, ij =1 means x i and x j are similar.
[0064] Get the loss function of the convolutional neural network, assuming binary code For all points, use b + To represent the hash code of similar images, use b - To represent the hash code of dissimilar images, the Hamming distances of similar pairs and non-similar pairs are expressed as At the same time That is, the sigmoid activation function. Assume that the positive example set of query q is Γ q , the negative example set of query q is Ψ q The probability of a positive example is expressed as formula (1).
[0065]
[0066] The image feature output by the last layer of the network is u, and the binary hash code is b. Directly using u instead of the binary code b will cause a large error in network optimization. In order to reduce the error caused by using u and facilitate optimization, let the network output u be close to a symmetrical number +1, -1. At the same time, combined with the actual training process that a batch corresponds to multiple tuples, the average of the similarities between the query and multiple positive examples is used to replace the single similarity in the above formula, and the relationship between the two parts of the loss is adjusted by the hyperparameter α. The multiple negative example loss is taken as the opposite of the log-likelihood, and the loss function of multiple negative examples is shown in Formula (2).
[0067]
[0068] In order to improve the retrieval accuracy, it is necessary to reduce the feature space distance between images of the same class as much as possible and increase the feature space distance between images of different classes. In order to reduce the feature space distance between images of the same class and increase the feature space distance between images of different classes, the interval parameter margin is introduced. At the same time, the cosine similarity is introduced to improve the stability of the convergence result. The new loss function form is shown in formula (3).
[0069]
[0070] Adding the scaling factor η solves the problem of slow optimization caused by the calculation method of formula (3). The scaling factor expands the similarity interval from [-1, +1] to [-η, +η], which can keep the similarity differentiation within a controllable range. The loss function with the scaling factor η is shown in formula (4).
[0071]
[0072] Among them, η is the scaling factor; margin is the interval parameter; α is the hyperparameter; Γ q is the positive example set of query q; q is the set of negative examples for query q.
[0073] The class center of a class is called the center k = (k 1 ,k 2 ,...,k C ), the image feature vector of the same type is x=(u 1 ,u 2 ,...,u C ). Define the Euclidean distance from x to k as the class center loss of this sample, as shown in formula (5).
[0074]
[0075] Assume that there are C classes in the data set, and the feature vector of each class is C = (k1, k2, ..., kc ), assuming the symbol Here, i represents the category and t represents the number in the category. Combined with formula (4), the loss calculation formula is shown in formula (6).
[0076]
[0077] in, The i in represents the category, and t represents the number in this category.
[0078] If the current number of training rounds does not exceed the number of initial pre-training rounds, that is, iter≤s; based on the label similarity matrix S l and the training data similarity matrix S im Get the loss function Loss;
[0079] If the current number of training rounds exceeds the initial number of pre-training rounds, that is, iter>s; based on the label similarity matrix S l , training data similarity matrix S im And the center position of each class, get the loss function Loss.
[0080] S104: Based on the chain rule in calculus, the loss function of the convolutional neural network is propagated from the back to the front of the convolutional neural network, and the gradient is calculated to update the parameters of each layer of the convolutional neural network.
[0081]
[0082] S105: Determine whether the current number of training rounds iter is greater than the maximum number of iterations Maxiter; if so, the training is completed, and the convolutional neural network with trained parameters is output to obtain the target image; otherwise, repeat S102 to S104 to continue training until the training is completed.
[0083] See also Figure 5 The present invention discloses a multi-negative hash image retrieval system based on class center loss for smart oil fields, comprising:
[0084] An initialization module, wherein the initialization module collects training set images and divides the training set images into several classes; and initializes the convolutional neural network information at the same time;
[0085] A first judgment module, wherein the first judgment module judges whether the current training round number iter is greater than the initialization pre-training round number s, and if so, obtains the class center position of each class image based on the training set image; if not, enters the construction module;
[0086] A construction module, wherein the construction module shuffles the order of the training set images, randomly extracts a number of image samples, constructs a similarity matrix, and obtains a loss function of the convolutional neural network based on the similarity matrix and the class center position;
[0087] An update module, which propagates the loss function of the convolutional neural network from back to front based on the chain rule in calculus, calculates the gradient and updates the parameters of each layer of the convolutional neural network;
[0088] The second judgment module determines whether the current number of training rounds iter is greater than the maximum number of iterations Maxiter; if so, the training is completed, and the convolutional neural network with trained parameters is output to obtain the target image; otherwise, the training is continued until the training is completed.
[0089] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. Multiple negative hash image retrieval method based on class center loss for smart oilfields, It is characterized in that include: Step 1: Collect training set images and divide them into several categories; initialize the convolutional neural network information at the same time; Step 2: Determine whether the current training round number iter is greater than the initial pre-training round number s. If so, obtain the class center position of each class image based on the training set image; if not, proceed to step 3; Step 3: Shuffle the order of the training set images and randomly select several image samples to construct a similarity matrix. Based on the similarity matrix and the class center position, obtain the loss function of the convolutional neural network. Step 4: Based on the chain rule in calculus, propagate the loss function of the convolutional neural network from back to front, calculate the gradient and update the parameters of each layer of the convolutional neural network; Step 5: Determine whether the current number of training rounds iter is greater than the maximum number of iterations Maxiter; if so, the training is completed, and the convolutional neural network with trained parameters is output to obtain the target image; otherwise, repeat steps 2 to 4 to continue training until the training is completed.
2. According to claim 1, the multi-negative example hash image retrieval method based on class center loss for smart oil fields, It is characterized in that The set of the training set images is: the image data set X = {x 1 , x 2 ,..., x m} and the data set label L = {l 1 , l 2 ,..., l m}; The convolutional neural network information includes: the initial learning rate, the initial weight decay rate, the maximum number of iterations Maxiter, the batchsize value, the initial hash loss weight α, the class center loss weight β, the initial number of pre-training rounds s < Maxiter, the number of rounds k < Maxiter for calculating the class center interval, and the current training round iter.
3. The multi-negative hash image retrieval method based on class center loss for smart oil fields according to claim 2, It is characterized in that When judging whether the current number of training rounds iter is greater than the number of initialized pre-training rounds s, it also includes: the relationship between the current number of training rounds iter and the number of class center interval rounds k is: iter=k+i×k.
4. The multi-negative hash image retrieval method based on class center loss for smart oil fields according to claim 3, It is characterized in that The method of obtaining the class center position of each class image based on the training set image is specifically as follows: inputting the training set image into the convolutional neural network, extracting the image feature u through the convolutional layer, pooling layer and fully connected layer of the convolutional neural network; calculating the class center k={k 1 ,k 2 ,...,k c }; where k j =Σ j u j .
5. According to claim 4, the multi-negative hash image retrieval method based on class center loss for smart oil fields, It is characterized in that The construction of the similarity matrix is specifically as follows: Divide the image samples into two tuples Q 1 and Q 2 , then transpose Q 2 Tags, by Q 1 , Q 2 The supervision information of l ; if s i =s j =1, then s ij =1, which means x i and x j are similar, whereas s ij =0 means x i and x j not similar; Send the image sample into the convolutional neural network to obtain the hashed feature vectors U, V; transpose the feature vector V, and construct the similarity matrix S through the training data of the feature vectors U, V im ; where s ij =0 means x i and x j Not similar, ij =1 means x i and x j are similar.
6. The multi-negative hash image retrieval method based on class center loss for smart oil fields according to claim 5, It is characterized in that The loss function of the convolutional neural network is obtained based on the similarity matrix and the class center position, specifically: If the current number of training rounds does not exceed the number of initial pre-training rounds, that is, iter≤s; based on the label similarity matrix S l and the training data similarity matrix S im Get the loss function Loss; If the current number of training rounds exceeds the initial number of pre-training rounds, that is, iter>s; based on the label similarity matrix S l , training data similarity matrix S im And the center position of each class, get the loss function Loss.
7. The multi-negative hash image retrieval method based on class center loss for smart oil fields according to claim 6, It is characterized in that The label similarity matrix S l and the training data similarity matrix S im Get the loss function Loss, specifically: Among them, η is the scaling factor; margin is the interval parameter; α is the hyperparameter; Γ q is the positive example set of query q; q is the negative example set of query q; The label similarity matrix S l , training data similarity matrix S im And the center position of each class, get the loss function Loss, specifically: in, The i in represents the category, and t represents the number in this category.
8. The multi-negative hash image retrieval method based on class center loss for smart oil fields according to claim 7, It is characterized in that The loss function of the convolutional neural network is propagated from the back to the front by the convolutional neural network, and the gradient is calculated to update the parameters of each layer of the convolutional neural network, specifically:
9. Multiple negative hash image retrieval system based on class center loss for smart oil fields, It is characterized in that include: An initialization module, wherein the initialization module collects training set images and divides the training set images into several classes; and initializes the convolutional neural network information at the same time; A first judgment module, wherein the first judgment module judges whether the current training round number iter is greater than the initialization pre-training round number s, and if so, obtains the class center position of each class image based on the training set image; if not, enters the construction module; A construction module, wherein the construction module shuffles the order of the training set images, randomly extracts a number of image samples, constructs a similarity matrix, and obtains a loss function of the convolutional neural network based on the similarity matrix and the class center position; An update module, which propagates the loss function of the convolutional neural network from back to front based on the chain rule in calculus, calculates the gradient and updates the parameters of each layer of the convolutional neural network; The second judgment module determines whether the current number of training rounds iter is greater than the maximum number of iterations Maxiter; if so, the training is completed, and the convolutional neural network with trained parameters is output to obtain the target image; otherwise, the training is continued until the training is completed.
Citation Information
Patent Citations
Deep hash-based image retrieval method, device and terminal equipment
CN110532417A
