Image searching method, electronic equipment, computer readable storage medium and computer program product
Through image semantic segmentation and feature extraction, the similarity similarity of object areas is obtained and the similarity calculation model is constructed, which solves the problem of image retrieval errors in the prior art and improves the accuracy of image search in weak texture scenes and high similarity scenes sex.
Patent Information
- Application Number
- CN202410909755.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-08
- Publication Date
- 2024-11-01
AI Technical Summary
The existing descriptive sub-vector search method based on image texture is prone to error retrieval when weak texture scenes and textures are highly similar.
The image semantic segmentation process obtains the object area features and position similarity, builds a similarity calculation model, combines the object area feature matrix and position relationship vector, and improves the accuracy of image search.
Even in weak texture scenes and high similarity scenes, the accuracy of image search is enhanced through semantic segmentation and feature extraction to ensure the accuracy of search results.
Smart Images

Figure CN118885633A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of communication technology, and specifically relates to an image search method, an electronic device, a computer-readable storage medium, and a computer program product. Background Art
[0002] The existing technology mainly encodes the texture features of the image and calculates the descriptor vector of each image. Therefore, for some scenes with weak texture or high scene texture similarity, the existing retrieval method based on the image texture descriptor vector may produce incorrect retrieval. Summary of the invention
[0003] The embodiments of the present application provide an image search method, an electronic device, a computer-readable storage medium, and a computer program product, which can solve the problem that the existing retrieval method based on image texture descriptor vectors may produce erroneous retrieval.
[0004] In a first aspect, an image search method is provided, comprising:
[0005] Acquire a plurality of first object regions in the first image and a plurality of second object regions in the second image through image semantic segmentation processing;
[0006] Acquire a first similarity and a second similarity between the plurality of first object regions and the plurality of second object regions;
[0007] searching, according to the first similarity and the second similarity, for a target image corresponding to the first image in the plurality of second images;
[0008] The first similarity is a similarity associated with a feature of an object region, and the second similarity is a similarity associated with a position of the object region.
[0009] In an optional embodiment, the method further includes:
[0010] Construct object region feature matrix of training images;
[0011] Obtaining a third similarity between the two different training images according to the object region feature matrices of the two different training images;
[0012] Obtaining the positional relationship of the object regions of the training image;
[0013] Obtaining a fourth similarity between the two different training images according to a positional relationship between object regions of the two different training images;
[0014] A similarity calculation model is obtained by training according to the third similarity and the fourth similarity between two different training images;
[0015] Wherein, the third similarity is a similarity associated with the object region feature, and the fourth similarity is a similarity associated with the object region position;
[0016] The obtaining of the first similarities and the second similarities between the plurality of first object regions and the plurality of second object regions comprises:
[0017] The first similarities and the second similarities between the plurality of first object regions and the plurality of second object regions are acquired through the similarity calculation model.
[0018] In an optional implementation, constructing an object region feature matrix of a training image includes:
[0019] Through image semantic segmentation processing, multiple training object regions corresponding to different image semantics are obtained in the training image;
[0020] By extracting image feature points, a feature point vector of each training object region is obtained;
[0021] Traversing the feature point vectors of each training object region, generating a plurality of center vectors corresponding to the feature point vectors of each training object region, wherein the number of the center vectors is the same as the number of the training object regions, and the dimension of the center vector is the same as the dimension of the feature point vector;
[0022] According to the feature point vector and the center vector, an object region feature matrix of the training image is obtained.
[0023] In an optional implementation, acquiring the third similarity between the two different training images according to the object region feature matrices of the two different training images includes:
[0024] The cosine value of the object feature matrix of two different training images is calculated to obtain the similarity of each object region between the two different training images;
[0025] The similarities of all object regions between two different training images are combined to obtain a third similarity between the two different training images.
[0026] In an optional implementation, the acquiring the position relationship of the object region of the training image includes:
[0027] Traverse the key point coordinates of each object area in the training image and calculate the coordinate information of each object area;
[0028] Constructing a first matrix according to the coordinate information;
[0029] According to the first matrix, a position feature vector of each object region is obtained;
[0030] According to the position feature vector of each object region, the relative position relationship vector between different object regions is obtained;
[0031] According to the relative position relationship vectors between the different object regions, the object region position relationship vector of the training image is obtained.
[0032] In an optional implementation, obtaining the object region position relationship vector of the training image according to the relative position relationship vectors between the different object regions includes:
[0033] The first neural network is constructed by taking the position feature vector of each object region as a node and the relative position relationship vectors between different object regions as an edge;
[0034] The position feature vectors of each object region are merged through the first neural network to obtain the object region position relationship vector of the training image.
[0035] In an optional implementation, searching the plurality of second images for a target image corresponding to the first image according to the first similarity and the second similarity includes:
[0036] When the first similarity between the first image and a first target image among the plurality of second images is greater than or equal to a preset threshold, determining the first target image as a target image corresponding to the first image;
[0037] When the first similarity between the first image and all the images in the multiple second images is less than a preset threshold, the sum of the first similarity and the second similarity between the first image and each image in the multiple second images is calculated, and the second target image having the largest sum of the first similarity and the second similarity is determined as the target image corresponding to the first image.
[0038] In a second aspect, an image search device is provided, comprising:
[0039] A first acquisition module, used for acquiring a plurality of first object regions in the first image and a plurality of second object regions in the second image through image semantic segmentation processing;
[0040] A second acquisition module, configured to acquire a first similarity and a second similarity between the plurality of first object regions and the plurality of second object regions;
[0041] A search module, configured to search for a target image corresponding to the first image in the plurality of second images according to the first similarity and the second similarity;
[0042] The first similarity is a similarity associated with a feature of an object region, and the second similarity is a similarity associated with a position of the object region.
[0043] In an optional embodiment, the device further comprises:
[0044] Model training module, used to:
[0045] Construct object region feature matrix of training images;
[0046] Obtaining a third similarity between the two different training images according to the object region feature matrices of the two different training images;
[0047] Obtaining the positional relationship of the object regions of the training image;
[0048] Obtaining a fourth similarity between the two different training images according to a positional relationship between object regions of the two different training images;
[0049] A similarity calculation model is obtained by training according to the third similarity and the fourth similarity between two different training images;
[0050] Wherein, the third similarity is a similarity associated with the object region feature, and the fourth similarity is a similarity associated with the object region position;
[0051] The second acquisition module is used to:
[0052] The first similarities and the second similarities between the plurality of first object regions and the plurality of second object regions are acquired through the similarity calculation model.
[0053] In an optional implementation, the model training module is used to:
[0054] Through image semantic segmentation processing, multiple training object regions corresponding to different image semantics are obtained in the training image;
[0055] By extracting image feature points, a feature point vector of each training object region is obtained;
[0056] Traversing the feature point vectors of each training object region, generating a plurality of center vectors corresponding to the feature point vectors of each training object region, wherein the number of the center vectors is the same as the number of the training object regions, and the dimension of the center vector is the same as the dimension of the feature point vector;
[0057] According to the feature point vector and the center vector, an object region feature matrix of the training image is obtained.
[0058] In an optional implementation, the model training module is used to:
[0059] The cosine value of the object feature matrix of two different training images is calculated to obtain the similarity of each object region between the two different training images;
[0060] The similarities of all object regions between two different training images are combined to obtain a third similarity between the two different training images.
[0061] In an optional implementation, the model training module is used to:
[0062] Traverse the key point coordinates of each object area in the training image and calculate the coordinate information of each object area;
[0063] Constructing a first matrix according to the coordinate information;
[0064] According to the first matrix, a position feature vector of each object region is obtained;
[0065] According to the position feature vector of each object region, the relative position relationship vector between different object regions is obtained;
[0066] According to the relative position relationship vectors between the different object regions, the object region position relationship vector of the training image is obtained.
[0067] In an optional implementation, the model training module is used to:
[0068] The first neural network is constructed by taking the position feature vector of each object region as a node and the relative position relationship vectors between different object regions as an edge;
[0069] The position feature vectors of each object region are merged through the first neural network to obtain the object region position relationship vector of the training image.
[0070] In an optional implementation, the search module is used to:
[0071] When the first similarity between the first image and a first target image among the plurality of second images is greater than or equal to a preset threshold, determining the first target image as a target image corresponding to the first image;
[0072] When the first similarity between the first image and all the images in the multiple second images is less than a preset threshold, the sum of the first similarity and the second similarity between the first image and each image in the multiple second images is calculated, and the second target image having the largest sum of the first similarity and the second similarity is determined as the target image corresponding to the first image.
[0073] According to a third aspect, an electronic device is provided, comprising a processor and a memory, wherein the memory stores programs or instructions executable on the processor, and the programs or instructions, when executed by the processor, implement the steps of the method described in the first aspect.
[0074] In a fourth aspect, a computer-readable storage medium is provided, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.
[0075] In a thirteenth aspect, a computer program product is provided, wherein the computer program product is stored in a storage medium and is executed by at least one processor to implement the steps of the method described in the first aspect.
[0076] In the embodiment of the present application, the first image and the second image are segmented into multiple object regions with different semantics through image semantic segmentation processing, the object region feature similarity and object region position similarity between the object regions in the first image and the second image are obtained, and based on the target object region feature similarity and target object region position similarity, a target image corresponding to the first image is searched in multiple second images. In this way, by combining the semantic segmentation of the image and increasing the calculation of the feature similarity and position similarity of the object region in the image, the image search accuracy can still be ensured even in the face of weak texture scenes and scenes with high texture similarity. BRIEF DESCRIPTION OF THE DRAWINGS
[0077] Figure 1 is a flowchart of an image search method provided in an embodiment of the present application;
[0078] Figure 2 is a structural schematic diagram of an image search device provided in an embodiment of the present application;
[0079] Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0080] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field belong to the scope of protection of this application.
[0081] The terms "first", "second", etc. of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchanged where appropriate, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first" and "second" are generally of one type, and the number of objects is not limited, for example, the first object can be one or more. In addition, "or" in the present application represents at least one of the connected objects. For example, the protection scope of "A or B" covers at least three schemes, that is, scheme one: including A and excluding B; scheme two: including B and excluding A; scheme three: including both A and B. In addition, the terms "A and / or B", "at least one of A and B", and "at least one of A or B" also cover at least the above three schemes respectively. The character " / " generally indicates that the objects associated before and after are in an "or" relationship.
[0082] The term "indication" in this application can be a direct indication (or explicit indication) or an indirect indication (or implicit indication). A direct indication can be understood as the sender explicitly informing the receiver of specific information, operations to be performed, or request results in the sent indication; an indirect indication can be understood as the receiver determining the corresponding information according to the indication sent by the sender, or making a judgment and determining the operation to be performed or the request result according to the judgment result.
[0083] The image search method provided in the embodiment of the present application is described in detail below through some embodiments and their application scenarios in combination with the accompanying drawings.
[0084] See also Figure 1 , the present application embodiment provides an image search method, including:
[0085] Step 101: obtaining a plurality of first object regions in a first image and a plurality of second object regions in a second image through image semantic segmentation processing;
[0086] Step 102: Obtaining a first similarity and a second similarity between a plurality of first object regions and a plurality of second object regions;
[0087] Step 103: searching for a target image corresponding to the first image in a plurality of second images according to the first similarity and the second similarity;
[0088] The first similarity is the similarity associated with the object region feature, and the second similarity is the similarity associated with the object region position. Optionally, the first similarity may be referred to as object region feature similarity, and the second similarity may be referred to as object region position similarity.
[0089] The significance of the above-mentioned image semantic segmentation processing is to separate the regions corresponding to different semantics in the image. Different semantics correspond to different specific object regions in the image, such as the region of the building and the region of the sky, and mark these regions. The existing Spectral Angle Mapping (SAM) segmentation algorithm is used in this case. Optionally, in the actual processing process, in order to clearly display the segmentation results, the image marks each object with a different color.
[0090] Correspondingly, the above-mentioned first object region refers to a region corresponding to different semantics obtained from the first image through image semantic segmentation processing, and the above-mentioned second object region refers to a region corresponding to different semantics obtained from the second image through image semantic segmentation processing.
[0091] The above-mentioned first image refers to the reference image provided when performing an image search. For example, when a user uses the image search solution of an embodiment of the present application, the reference image provided by the user is the above-mentioned first image. The second image can be understood as a set of image resources used to search for the target image, that is, by providing the first image, based on the above-mentioned target object area feature similarity and target object area position similarity, a second image is searched out from multiple second images as the search result of the first image.
[0092] The above-mentioned object region feature similarity is used to represent the similarity between the object regions respectively contained in the first image and the second image after the image semantic segmentation processing, and can be used to measure the similarity between the specific image contents of the first image and the second image;
[0093] The above-mentioned object area position similarity is used to represent the similarity between the position relationship between each object area in the first image and the position relationship between each object area in the second image, and can be used to measure the similarity between the specific image content position arrangement mode of the first image and the second image.
[0094] In the above, based on the first similarity and the second similarity, a target image corresponding to the first image is searched in multiple second images, specifically by obtaining the object area feature similarity and the object area position similarity between the first image and each second image, and selecting a suitable target image in the multiple second images as the search result of the first image based on the obtained similarity.
[0095] In the embodiment of the present application, the first image and the second image are segmented into multiple object regions with different semantics through image semantic segmentation processing, the target object region feature similarity and the target object region position similarity between the object regions in the first image and the second image are obtained, and based on the target object region feature similarity and the target object region position similarity, the target image corresponding to the first image is searched in multiple second images. In this way, by combining the semantic segmentation of the image and increasing the calculation of the feature similarity and position similarity of the object region in the image, the image search accuracy can still be ensured even in the face of weak texture scenes and scenes with high texture similarity.
[0096] In an optional implementation, a model may be pre-trained, and the object region feature similarity and the object region position similarity may be obtained through the model;
[0097] Optionally, the method further includes:
[0098] (1) Construct the object region feature matrix of the training image;
[0099] (2) Obtaining a third similarity between the two different training images based on the object region feature matrices of the two different training images; it can be understood that the two different training images refer to one training image being a reference image for image search, and the other training image being a search result of the image search.
[0100] (3) Obtaining the positional relationship of the object regions in the training image;
[0101] (4) obtaining a fourth similarity between the two different training images according to the positional relationship between the object regions of the two different training images;
[0102] (5) training a similarity calculation model based on the third similarity and the fourth similarity between two different training images;
[0103] The third similarity is a similarity associated with object region features, and the fourth similarity is a similarity associated with object region positions. Optionally, the third similarity may be referred to as object region feature similarity, and the fourth similarity may be referred to as object region position similarity.
[0104] By collecting a large number of training images and repeating the above (1)-(5) multiple times, the training of the similarity calculation model is completed. In this way, as long as the object area of the image to be searched is input into the model, the corresponding object area feature similarity and object area position similarity can be calculated.
[0105] Acquiring a first similarity and a second similarity between a plurality of first object regions and a plurality of second object regions includes:
[0106] A first similarity and a second similarity between the plurality of first object regions and the plurality of second object regions are obtained through a similarity calculation model.
[0107] In an optional implementation, constructing an object region feature matrix of a training image includes:
[0108] (1.1) Through image semantic segmentation processing, multiple training object regions corresponding to different image semantics are obtained in the training image;
[0109] (1.2) Obtaining feature point vectors of each training object area through image feature point extraction processing;
[0110] Feature points are extracted from the image, which is to obtain the texture information of the image. Points with rich textures are extracted from the image. At the same time, the extracted feature points are divided according to the different subordinate regions in combination with the regional results of the image semantic segmentation processing. The feature extraction method can be the existing Superpoint feature extraction method.
[0111] (1.3) traverse the feature point vectors of each training object region, and generate multiple center vectors corresponding to the feature point vectors of each training object region, where the number of center vectors is the same as the number of training object regions, and the dimension of the center vector is the same as the dimension of the feature point vector;
[0112] (1.4) Based on the feature point vector and the center vector, the object area feature matrix of the training image is obtained.
[0113] In an optional implementation, obtaining a third similarity between two different training images according to object region feature matrices of the two different training images includes:
[0114] (4.1) Calculate the cosine value of the object feature matrix of two different training images to obtain the similarity of each object region between the two different training images;
[0115] (4.2) The similarities of all object regions between two different training images are merged to obtain the third similarity between the two different training images.
[0116] The similarity of each object region is obtained by cosine calculation, and then the similarities of all object regions are merged, specifically by superposition and summation, to obtain the object region similarity of the entire image, that is, the object region feature similarity between two different training images.
[0117] In an optional implementation, obtaining the position relationship of the object region of the training image includes:
[0118] (3.1) Traverse the key point coordinates of each object area in the training image and calculate the coordinate information of each object area;
[0119] The above coordinate information may specifically include:
[0120] The average coordinates (mean), standard deviation (std), first-order momentum (moment1), second-order momentum (moment2), third-order momentum (moment3), and S component (s) of singular value decomposition (SVD) of the key points of each object area;
[0121] (3.2) Construct the first matrix based on the coordinate information;
[0122] (3.3) According to the first matrix, the position feature vector of each object region is obtained; for example, a multilayer perceptron (MLP) operation can be performed on the first matrix;
[0123] (3.4) Calculating the relative position relationship vectors between different object regions based on the position feature vector of each object region;
[0124] (3.5) Based on the relative position relationship vectors between different object regions, the object region position relationship vector of the training image is calculated.
[0125] In an optional implementation, calculating the object region position relationship vector of the training image according to the relative position relationship vectors between different object regions includes:
[0126] (3.5.1) Constructing a first neural network with the position feature vector of each object region as a node and the relative position relationship vectors between different object regions as edges;
[0127] (3.5.2) merging the position feature vectors of each object region through the first neural network to obtain the object region position relationship vector of the training image;
[0128] The position feature vectors of each object region are combined, specifically by superposition and summation, to obtain the object region position relationship of the entire image, that is, the object region position relationship vector of the training image.
[0129] In an optional implementation, obtaining a fourth similarity between two different training images according to the positional relationship of the object regions of the two different training images includes:
[0130] The cosine value of the object region position relationship vectors of two different training images is calculated to obtain a fourth similarity between the two different training images.
[0131] In an optional implementation, searching for a target image corresponding to the first image in a plurality of second images according to the first similarity and the second similarity includes:
[0132] (1) when a first similarity between the first image and a first target image among the plurality of second images is greater than or equal to a preset threshold, determining the first target image as the target image corresponding to the first image;
[0133] If the object region feature similarity between two images is greater than or equal to a preset threshold, it means that the similarity between the image contents is high enough to ensure the accuracy of the image search results. In this case, the image search results can be determined directly based on the object region feature similarity.
[0134] (2) When the first similarities between the first image and all images in the plurality of second images are less than a preset threshold, the sum of the first similarity and the second similarity between the first image and each image in the plurality of second images is calculated, and the second target image having the largest sum of the first similarity and the second similarity is determined as the target image corresponding to the first image.
[0135] If the object area feature similarity between two images is less than the preset threshold, it means that the similarity between the image contents alone is not sufficient to prove that the corresponding images can be used as image search results. It is also necessary to use the object area position similarity to measure the similarity of the specific image content position arrangement of the two images to further ensure the accuracy of the image search results.
[0136] The technical solution of the present application is described below in conjunction with specific application examples:
[0137] The technical solution of this case is to enrich the descriptor vector of the original technical solution. On the basis of the original texture information, it combines the semantic and structural information of the image to improve the generalization of the descriptor vector, thereby improving the retrieval accuracy of the retrieval model in weak texture scenes and high similarity scenes. The steps of this solution are mainly divided into the following steps:
[0138] 1. Image preprocessing, semantic segmentation of images
[0139] First, perform semantic segmentation on the image. The meaning of image semantic segmentation is to divide each area in the image, such as the building area and the sky area, and mark these areas. The existing SAM segmentation algorithm is used in this case. The effect after segmentation Figure 1 As shown, in order to clearly show the segmentation results, each object (specifically, object region, hereinafter referred to as object) is marked with a different color in the image. The relative position of each region is the structural information in the image that this case wants to use.
[0140] 2. Image feature point extraction
[0141] Extract feature points from the image to obtain the texture information of the image. Extract points with rich texture in the image. At the same time, combined with the regional results of step 1, divide the extracted feature points according to the different subordinate regions. The feature extraction method used in this case is the existing Superpoint feature extraction method. The results after extraction are as follows Figure 2 As shown in the figure, all feature points are represented in green.
[0142] 3. Combine the semantic structure information from step 1 and the texture information from step 2 to calculate the image descriptor vector. After calculations in steps 1 and 2, the objects in the image and the feature points of each object are obtained. Step 3 first traverses the feature points of each object in the image and performs the following processing on the feature points of each object:
[0143] 1. Randomly generate C center vectors from the feature points of the current object (C is the number of objects segmented). The dimension of each center vector is the same as the dimension of the feature point vector, and is represented by P. P is generally 1024 or 2048.
[0144] 2. Calculate the object-based feature matrix O for each image based on the segmented objects. The latitude of the O matrix is C*P, where C is the number of objects and P is the length of the feature descriptor vector. The feature matrix O is calculated by traversing all feature points of the current object and calculating it according to the following formula. In the formula, O(n) represents the feature vector of the nth center, and n ranges from 1 to C. d i represents the i-th eigenvector, where i ranges from 1 to the number of feature points. n represents the center of the nth object, a n () is a learnable parameter, a weight value, which is used to indicate the degree of match between the di feature vector and the current center. Nor() is an L2 normalization function used to normalize the result vector.
[0145]
[0146] 3. Through the above steps, our model can calculate the object-based feature matrix O of each image. In order to use this matrix in image retrieval, we use the following formula to calculate the similarity relationship S of the O matrix between different images. In the formula, O d (m), O q (n) represents the object feature matrix calculated from two different images. By calculating the cosine values of the two matrices, a value between (0, 1) is calculated to represent the similarity of the two images in terms of object latitude. The closer to 1, the higher the similarity.
[0147] S(m,n)=cos(O d (m),O q (n));
[0148] In the above formula, d represents the identifier of the training image used as the search reference image, q represents the identifier of the training image used as the search result, that is, the training purpose is to search for image d to obtain image q, m represents the mth center in image d, and n represents the nth center in image q.
[0149] 4. By superimposing the similarity scores between each object, the object-based similarity of the two images can be obtained; through the following formula, Z represents the number of objects used for comparison, and Ra represents the similarity of the two images at the object level
[0150]
[0151] Fourth, through step 3, we get the similarity of objects in the two images, but only the similarity of objects can easily lead to misjudgment, because even if there are similar objects, but the placement of the objects is different, it cannot be said that the two images are similar. Therefore, it is necessary to build a position relationship model between objects. The construction steps are as follows:
[0152] 1. Traverse the key point coordinates (x, y, z) of each object, calculate the average coordinates (mean), standard deviation (std), 1st-order momentum (moment1), 2nd-order momentum (moment2), 3rd-order momentum (moment3), and S component (s) of SVD decomposition of the key points of each object; stack the above coordinate information into a 6*3-dimensional matrix (the dimension parameter is only for example and does not constitute a specific limitation), and pass this matrix through two layers of MLP operations to obtain the position feature g of the object. The relative position relationship e of the two objects is expressed by the following formula: where o1 and o2 represent two objects respectively;
[0153] e=g(o1)-g(o2);
[0154] 2. Construct a two-layer graph neural network (the number of neural network layers is only an example and does not constitute a specific limitation), with the position feature g of each object as a node and the relative position relationship e as an edge. The position relationship between each object is obtained as an edge The position feature vector of the output of the tth layer of the neural layer of the uth object is superimposed on the position feature vector of each object in each picture to obtain the position relationship vector Rg of this image. u , W is a trainable parameter. u represents the uth object. By superimposing the positional relationship of each object, the positional relationship R of the entire image is calculated.
[0155]
[0156] 3. The similarity of the object position relationship between the two images is calculated using the cosine similarity formula;
[0157] Step 5. Loss function design. The loss function of the entire model is as follows: The loss function is divided into two parts. When the two pictures are positive samples, we hope that the first half is as close to 1 as possible and the second half is close to 0. On the contrary, when the two pictures are negative samples, we hope that the first half is close to 0 and the second half is close to 1. ω is a fixed value of 0.3. Rg represents the similarity of position relationship and Ra represents the similarity of object.
[0158] L r =∑ {d,q}∈+ (1-cos(R g (d),R g (q))-R a (d,q))+∑ {d,q}∈- max(0,cos(R g (d),R g (q))+R a (d,q)-ω);
[0159] In the above formula, d represents the identifier of the training image used as the search reference image, and q represents the identifier of the training image used as the search result, that is, the training purpose is to search for image d to obtain image q.
[0160] Step 6: Model reasoning. The model compares the object similarity and object position similarity of the two images. Generally, a threshold x is set. If the object similarity exceeds x, the object position similarity is no longer compared. If it is lower than x, the sum of the two is calculated, and the largest image is taken as the final retrieval image.
[0161] See also Figure 2 , the embodiment of the present application provides an image search device 200, comprising:
[0162] A first acquisition module 201 is used to acquire a plurality of first object regions in a first image and a plurality of second object regions in a second image through image semantic segmentation processing;
[0163] A second acquisition module 202, configured to acquire a first similarity and a second similarity between the plurality of first object regions and the plurality of second object regions;
[0164] A search module 203, configured to search for a target image corresponding to the first image in the plurality of second images according to the first similarity and the second similarity;
[0165] The first similarity is a similarity associated with a feature of an object region, and the second similarity is a similarity associated with a position of the object region.
[0166] In an optional embodiment, the device further comprises:
[0167] Model training module, used to:
[0168] Construct object region feature matrix of training images;
[0169] Obtaining a third similarity between the two different training images according to the object region feature matrices of the two different training images;
[0170] Obtaining the positional relationship of the object regions of the training image;
[0171] Obtaining a fourth similarity between the two different training images according to a positional relationship between object regions of the two different training images;
[0172] A similarity calculation model is obtained by training according to the third similarity and the fourth similarity between two different training images;
[0173] Wherein, the third similarity is a similarity associated with the object region feature, and the fourth similarity is a similarity associated with the object region position;
[0174] The second acquisition module is used to:
[0175] The first similarities and the second similarities between the plurality of first object regions and the plurality of second object regions are acquired through the similarity calculation model.
[0176] In an optional implementation, the model training module is used to:
[0177] Through image semantic segmentation processing, multiple training object regions corresponding to different image semantics are obtained in the training image;
[0178] By extracting image feature points, a feature point vector of each training object region is obtained;
[0179] Traversing the feature point vectors of each training object region, generating a plurality of center vectors corresponding to the feature point vectors of each training object region, wherein the number of the center vectors is the same as the number of the training object regions, and the dimension of the center vector is the same as the dimension of the feature point vector;
[0180] According to the feature point vector and the center vector, an object region feature matrix of the training image is obtained.
[0181] In an optional implementation, the model training module is used to:
[0182] The cosine value of the object feature matrix of two different training images is calculated to obtain the similarity of each object region between the two different training images;
[0183] The similarities of all object regions between two different training images are combined to obtain a third similarity between the two different training images.
[0184] In an optional implementation, the model training module is used to:
[0185] Traverse the key point coordinates of each object area in the training image and calculate the coordinate information of each object area;
[0186] Constructing a first matrix according to the coordinate information;
[0187] According to the first matrix, a position feature vector of each object region is obtained;
[0188] According to the position feature vector of each object region, the relative position relationship vector between different object regions is obtained;
[0189] According to the relative position relationship vectors between the different object regions, the object region position relationship vector of the training image is obtained.
[0190] In an optional implementation, the model training module is used to:
[0191] The first neural network is constructed by taking the position feature vector of each object region as a node and the relative position relationship vectors between different object regions as an edge;
[0192] The position feature vectors of each object region are merged through the first neural network to obtain the object region position relationship vector of the training image.
[0193] In an optional implementation, the search module is used to:
[0194] When the first similarity between the first image and a first target image among the plurality of second images is greater than or equal to a preset threshold, determining the first target image as a target image corresponding to the first image;
[0195] When the first similarity between the first image and all the images in the multiple second images is less than a preset threshold, the sum of the first similarity and the second similarity between the first image and each image in the multiple second images is calculated, and the second target image having the largest sum of the first similarity and the second similarity is determined as the target image corresponding to the first image.
[0196] See also Figure 3 The embodiment of the present invention provides an electronic device 300, including: at least one processor 301, a memory 302, a user interface 303 and at least one network interface 304. The components in the electronic device 300 are coupled together via a bus system 305.
[0197] It is understood that the bus system 305 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 305 also includes a power bus, a control bus, and a status signal bus. Figure 3 Various buses are labeled as bus system 305 .
[0198] The user interface 303 may include a display, a keyboard, or a pointing device (eg, a mouse, a trackball, a touch pad, or a touch screen, etc.).
[0199] It is understood that the memory 302 in the embodiment of the present invention may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM) and direct memory bus random access memory (DRRAM). The memory 302 described in the embodiments of the present invention is intended to include, but is not limited to, these and any other suitable types of memory.
[0200] In some implementations, the memory 302 stores the following elements, executable modules or data structures, or a subset thereof, or an extended set thereof: an operating system 3021 and an application program 3022 .
[0201] The operating system 3021 includes various system programs, such as a framework layer, a core library layer, a driver layer, etc., which are used to implement various basic services and process hardware-based tasks. The application 3022 includes various application programs, such as a media player, a browser, etc., which are used to implement various application services. The program for implementing the method of the embodiment of the present invention can be included in the application 3022.
[0202] In the embodiment of the present invention, the electronic device 300 may further include: a program stored in the memory 302 and executable on the processor 301, which implements the steps of the method provided in the embodiment of the present invention when executed by the processor 301.
[0203] The method disclosed in the above embodiment of the present invention can be applied to the processor 301, or implemented by the processor 301. The processor 301 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit in the processor 301 or the instructions in the form of software. The above processor 301 can be a general processor, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiment of the present invention can be directly embodied as a hardware decoding processor to execute, or the hardware and software modules in the decoding processor are combined and executed. The software module can be located in a computer-readable storage medium mature in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The computer-readable storage medium is located in the memory 302, and the processor 301 reads the information in the memory 302 and completes the steps of the above method in combination with its hardware. Specifically, the computer-readable storage medium stores a program or instruction.
[0204] It is to be understood that the embodiments described in the embodiments of the present invention may be implemented by hardware, software, firmware, middleware, microcode or a combination thereof. For hardware implementation, the processing unit may be implemented in one or more ASICs, DSPs, digital signal processing devices (DSP Device, DSPD), programmable logic devices (Programmable Logic Device, PLD), FPGAs, general-purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described in the present application or a combination thereof.
[0205] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises one..." does not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the method and device in the embodiment of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0206] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of a computer software product plus a necessary general hardware platform, and of course, can also be implemented by hardware. The computer software product is stored in a storage medium (such as ROM, RAM, disk, CD, etc.), including several instructions to enable a terminal or a network-side device to execute the methods described in each embodiment of the present application.
[0207] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms of implementation methods without departing from the purpose of the present application and the scope of protection of the claims, and these implementation methods are all within the protection of the present application.
Claims
1. An image search method, characterized in that: include: Acquire a plurality of first object regions in the first image and a plurality of second object regions in the second image through image semantic segmentation processing; Acquire a first similarity and a second similarity between the plurality of first object regions and the plurality of second object regions; searching, according to the first similarity and the second similarity, for a target image corresponding to the first image in the plurality of second images; The first similarity is a similarity associated with a feature of an object region, and the second similarity is a similarity associated with a position of the object region.
2. The method according to claim 1, characterized in that The method further comprises: Construct object region feature matrix of training images; Obtaining a third similarity between the two different training images according to the object region feature matrices of the two different training images; Obtaining the positional relationship of the object regions of the training image; Obtaining a fourth similarity between the two different training images according to a positional relationship between object regions of the two different training images; A similarity calculation model is obtained by training according to the third similarity and the fourth similarity between two different training images; Wherein, the third similarity is a similarity associated with the object region feature, and the fourth similarity is a similarity associated with the object region position; The obtaining of the first similarities and the second similarities between the plurality of first object regions and the plurality of second object regions comprises: The first similarities and the second similarities between the plurality of first object regions and the plurality of second object regions are acquired through the similarity calculation model.
3. The method according to claim 2, characterized in that The step of constructing an object region feature matrix of a training image includes: Through image semantic segmentation processing, multiple training object regions corresponding to different image semantics are obtained in the training image; By extracting image feature points, a feature point vector of each training object region is obtained; Traversing the feature point vectors of each training object region, generating a plurality of center vectors corresponding to the feature point vectors of each training object region, wherein the number of the center vectors is the same as the number of the training object regions, and the dimension of the center vector is the same as the dimension of the feature point vector; According to the feature point vector and the center vector, an object region feature matrix of the training image is obtained.
4. The method according to claim 2, characterized in that: The step of obtaining the third similarity between the two different training images according to the object region feature matrices of the two different training images includes: The cosine value of the object feature matrix of two different training images is calculated to obtain the similarity of each object region between the two different training images; The similarities of all object regions between two different training images are combined to obtain a third similarity between the two different training images.
5. The method according to claim 2, characterized in that: The obtaining of the object region position relationship of the training image includes: Traverse the key point coordinates of each object area in the training image and calculate the coordinate information of each object area; Constructing a first matrix according to the coordinate information; According to the first matrix, a position feature vector of each object region is obtained; According to the position feature vector of each object region, the relative position relationship vector between different object regions is obtained; According to the relative position relationship vectors between the different object regions, the object region position relationship vector of the training image is obtained.
6. The method according to claim 5, characterized in that The step of obtaining the object region position relationship vector of the training image according to the relative position relationship vectors between the different object regions comprises: The first neural network is constructed by taking the position feature vector of each object region as a node and the relative position relationship vectors between different object regions as an edge; The position feature vectors of each object region are merged through the first neural network to obtain the object region position relationship vector of the training image.
7. The method according to claim 1, characterized in that The step of searching the plurality of second images for a target image corresponding to the first image according to the first similarity and the second similarity includes: When the first similarity between the first image and a first target image among the plurality of second images is greater than or equal to a preset threshold, determining the first target image as a target image corresponding to the first image; When the first similarity between the first image and all the images in the multiple second images is less than a preset threshold, the sum of the first similarity and the second similarity between the first image and each image in the multiple second images is calculated, and the second target image having the largest sum of the first similarity and the second similarity is determined as the target image corresponding to the first image.
8. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores a program or instruction that can be run on the processor, and when the program or instruction is executed by the processor, the steps of the image search method according to any one of claims 1 to 7 are implemented.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a program or instruction, and when the program or instruction is executed by a processor, the steps of the image search method according to any one of claims 1 to 7 are implemented.
10. A computer program product, characterized in that The method comprises computer instructions, which, when executed by a processor, implement the steps of the image search method according to any one of claims 1 to 7.
