Image similarity recognition model training method, device and image similarity recognition method
Through a multi-level feature extraction layer and a combination of convolution processing and upsampling processing, the image similarity recognition model is trained to solve the problem of abnormal image recognition after image transformation, achieve efficient abnormal image recognition and filtering, and ensure the security of Internet content.
Patent Information
- Application Number
- CN202311483310.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-08
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2043-11-08
AI Technical Summary
It is difficult for existing technologies to effectively identify and filter images that become abnormal due to image transformation processing, making it difficult to ensure the security of Internet content.
Using a multi-level feature extraction layer and a combination of convolution processing and upsampling processing, the target feature map is obtained through image similarity recognition model training, and the loss function is calculated to adjust the model, improve the accuracy and efficiency of image similarity recognition, and be able to identify various Image transformation.
It achieves accurate identification and filtering of abnormal images, improves the accuracy and efficiency of image similarity recognition, and ensures the security of Internet content.
Smart Images

Figure CN117611844B
Abstract
Description
Technical Field
[0001] The present application relates to the fields of image processing technology and image recognition technology, and in particular to a training method and device for an image similarity recognition model and an image similarity recognition method. Background Art
[0002] With the rapid development of the Internet and mobile communication technology, images are increasingly used as a medium for people to spread information. In the fields of social software, network disk, 5G messaging, etc., the images uploaded by users are massive and unpredictable, which also brings some inevitable problems and risks. For example, there may be some abnormal images, harmful images, or large-scale commercial promotion images on the Internet. These images are of different types, and new illegal content may appear at any time, which brings great challenges to the control and governance of bad information.
[0003] The method based on image similarity recognition is used to filter abnormal images. That is, a certain feature of the image is extracted through a method, and the feature can represent the main content of an image, and the similarity between the features is used to determine whether the images are similar, so as to build and maintain an abnormal image feature library. New abnormal images can be added to the library to achieve timely and effective management and control.
[0004] In related technologies, images may be cropped, translated, rotated, blurred, added with text and other transformations, which greatly increases the difficulty of bad control based on image similarity recognition methods. To deal with these image transformation attacks, how to improve the accuracy and efficiency of image similarity recognition, accurately and timely filter abnormal image messages, and ensure the security of Internet content has become one of the important research directions. Summary of the invention
[0005] The present application aims to solve one of the technical problems in the related art at least to some extent.
[0006] The first embodiment of the present application proposes a training method for an image similarity recognition model, comprising:
[0007] Obtaining a sample image pair and its corresponding reference label value, and training an image similarity recognition model based on the sample image pair, wherein the sample image pair includes two different sample images;
[0008] For any sample image in the sample image pair, the N-level feature extraction layer in the image similarity recognition model performs feature extraction on the sample image to obtain a candidate feature map of the multi-level feature extraction layer, where N is an integer greater than 2;
[0009] Based on the convolution process and the upsampling process, the candidate feature map N of the N-th feature extraction layer and the candidate feature map N-1 of the N-1-th feature extraction layer are subjected to feature fusion to obtain the N-1-th feature map, and the feature map N-2 of the N-1-th feature extraction layer and the candidate feature map N-2 of the N-2-th feature extraction layer are subjected to feature fusion to obtain the previous feature map, until the Nm-th feature map is obtained;
[0010] Obtain the target feature map of the sample image according to the Nm-th level feature map and the candidate feature map Nm-1 of the Nm-1-th level feature extraction layer, where m is a positive integer;
[0011] According to the reference label value and the target feature maps of the two sample images, the loss function of the sample image pair is obtained to adjust the image similarity recognition model, and the next sample image pair is used to train the adjusted image similarity recognition model until the training is completed to obtain the target image similarity recognition model.
[0012] In an embodiment of the present application, for any sample image in a sample image pair, an N-level feature extraction layer in an image similarity recognition model performs feature extraction on the sample image to obtain a candidate feature map of a multi-level feature extraction layer, and feature fusion is performed on the candidate feature map N and the candidate feature map N-1 based on convolution processing and upsampling processing to obtain an N-1th level feature map, and feature fusion is continued on the N-1th level feature map and the candidate feature map N-2 based on convolution processing and upsampling processing to obtain an upper level feature map until an Nmth level feature map is obtained, and a target feature map of the sample image is obtained based on the Nmth level feature map and the candidate feature map Nm-1, which can improve the accuracy and efficiency of image similarity recognition, and obtain a loss function of the sample image pair based on a reference label value and the target feature maps of each of the two sample images to adjust the image similarity recognition model, which can improve the recognition accuracy of the image similarity recognition model for similarity transformations, accurately and timely implement filtering of abnormal image messages, and ensure the security of Internet content.
[0013] The second embodiment of the present application proposes a training device for an image similarity recognition model, comprising:
[0014] A first acquisition module is used to acquire a sample image pair and its corresponding reference label value, and train an image similarity recognition model based on the sample image pair, wherein the sample image pair includes two different sample images;
[0015] The second acquisition module is used to extract features of any sample image in the sample image pair by using the N-level feature extraction layer in the image similarity recognition model to obtain a candidate feature map of the multi-level feature extraction layer, where N is an integer greater than 2;
[0016] A third acquisition module is used to perform feature fusion on the candidate feature map N of the N-th feature extraction layer and the candidate feature map N-1 of the N-1-th feature extraction layer based on convolution processing and upsampling processing to obtain the N-1-th feature map, and continue to perform feature fusion on the N-1-th feature map and the candidate feature map N-2 of the N-2-th feature extraction layer based on convolution processing and upsampling processing to obtain the previous level feature map, until the Nm-th level feature map is obtained;
[0017] A fourth acquisition module is used to acquire a target feature map of the sample image according to the Nm-th level feature map and the candidate feature map Nm-1 of the Nm-th level feature extraction layer, where m is a positive integer;
[0018] The training module is used to obtain the loss function of the sample image pair according to the reference label value and the target feature map of each of the two sample images to adjust the image similarity recognition model, and continue to use the next sample image pair to train the adjusted image similarity recognition model until the training is completed to obtain the target image similarity recognition model.
[0019] The third aspect of the present application provides an image similarity recognition method, including:
[0020] Obtaining a target image pair to be identified, the target image pair comprising two different target images;
[0021] Input the target image pair into the trained target image similarity recognition model, the target image similarity recognition model outputs the target feature maps of the two target images respectively, and calculates the similarity based on the target feature maps;
[0022] In response to the similarity being greater than or equal to a preset similarity threshold, determining that the two target images are similar, or in response to the similarity being less than the similarity threshold, determining that the two target images are not similar;
[0023] The target image similarity recognition model is a model trained using the training method described above.
[0024] The embodiment of the present application adopts the above training method to obtain a target image similarity recognition model, which has a high recognition accuracy rate for various image transformations. It can improve the accuracy and efficiency of image similarity recognition, accurately and timely filter abnormal image messages, and ensure the security of Internet content.
[0025] The fourth aspect of the present application provides an image similarity recognition device, including:
[0026] An acquisition module, used for acquiring a target image pair to be identified, wherein the target image pair includes two different target images;
[0027] A similarity recognition module is used to input the target image pair into a trained target image similarity recognition model, and the target image similarity recognition model outputs target feature maps of the two target images, and calculates the similarity based on the target feature maps;
[0028] a determination module, configured to determine that the two target images are similar in response to the similarity being greater than or equal to a preset similarity threshold, or to determine that the two target images are not similar in response to the similarity being less than the similarity threshold;
[0029] The target image similarity recognition model is a model trained by the above training device. The fifth aspect of the present application provides an electronic device, including:
[0030] at least one processor; and
[0031] a memory communicatively connected to at least one processor; wherein,
[0032] The memory stores instructions that can be executed by at least one processor, and the instructions are executed by at least one processor so that the at least one processor can execute the training method of the image similarity recognition model provided in the embodiment of the first aspect of the present application, or execute the image similarity recognition method provided in the embodiment of the third aspect of the present application.
[0033] The sixth aspect embodiment of the present application proposes a computer-readable storage medium on which computer instructions are stored, wherein the computer instructions are used to enable a computer to execute the training method of the image similarity recognition model provided in the first aspect embodiment of the present application, or to execute the image similarity recognition method provided in the third aspect embodiment of the present application.
[0034] The seventh aspect embodiment of the present application proposes a computer program product, including a computer program. When the computer program is executed by a processor, it implements the training method of the image similarity recognition model provided in the first aspect embodiment of the present application, or when executed, it implements the image similarity recognition method provided in the third aspect embodiment of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 is a flowchart of a method for training an image similarity recognition model according to an embodiment of the present application;
[0036] Figure 2 is a flowchart of a method for training an image similarity recognition model according to an embodiment of the present application;
[0037] Figure 3 is a schematic diagram of a training method for an image similarity recognition model according to an embodiment of the present application;
[0038] Figure 4is a schematic diagram of a training method for an image similarity recognition model according to an embodiment of the present application;
[0039] Figure 5 is a schematic diagram of a training method for an image similarity recognition model according to an embodiment of the present application;
[0040] Figure 6 is a schematic diagram of a training method for an image similarity recognition model according to an embodiment of the present application;
[0041] Figure 7 is a flowchart of a method for training an image similarity recognition model according to an embodiment of the present application;
[0042] Figure 8 is a structural block diagram of an image similarity recognition device according to an embodiment of the present application;
[0043] Fig. 9 is a structural block diagram of an image similarity recognition device according to an embodiment of the present application;
[0044] Fig.10 It is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0045] Embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.
[0046] The following describes the image similarity recognition model training method, device and image similarity recognition method of the embodiments of the present application in conjunction with the accompanying drawings.
[0047] Figure 1 FIG. 1 is a flowchart of a method for training an image similarity recognition model according to an embodiment of the present application. Figure 1 As shown, the method comprises the following steps:
[0048] S101, obtaining sample image pairs and their corresponding reference label values, and training an image similarity recognition model based on the sample image pairs.
[0049] The sample image pair includes two different sample images.
[0050] In some embodiments, the reference tag value includes a first tag value indicating that the sample image pair is similar and a second tag value indicating that the sample image pair is not similar. Optionally, the first tag value may be 1 and the second tag value may be 0. In other embodiments, the first tag value and the second tag value may also be other values, which is not limited in the embodiments of the present application.
[0051] In some implementations, sample image pairs and their corresponding reference label values are directly obtained from a database.
[0052] In some embodiments, multiple initial images are obtained, the initial images include normal images and various abnormal images, and duplicate removal is performed to ensure that the initial images do not contain similar images. For any initial image, different image transformation processes are performed on the initial image to obtain multiple transformed images of the initial image, and the initial image and the multiple transformed images of the initial image are used as the image set of the initial image.
[0053] In some embodiments, any two images are extracted from the same initial image image set to obtain a sample image pair, and the label value corresponding to the sample image pair is determined to be the first label value. In some embodiments, an image is extracted from each of two different initial image image sets to obtain a sample image pair, and the label value corresponding to the sample image pair is determined to be the second label value.
[0054] For example, let an initial image and its transformed image be set A, and another initial image and its transformed image be set B. Two images are extracted from set A to form a training group (A1, A2), whose reference label value is the first label value (1-similar) indicating that the sample image pair is similar, that is, the sample image pair and its corresponding reference label value are ((A1, A2), 1). One image is extracted from each set A and B to form a training group (A1, B1), whose label is the second label value (0-dissimilar) indicating that the sample image pair is not similar, that is, the sample image pair and its corresponding reference label value are ((A1, B1), 0). In this way, all possible combinations in all data sets are traversed to generate multiple sample image pairs and reference label values corresponding to each sample image pair.
[0055] In the embodiment of the present application, sample image pairs are constructed using similarity transformation of images, and an image similarity recognition model is trained based on the sample image pairs, which can improve the recognition accuracy of the image similarity recognition model for similarity transformation.
[0056] Optionally, multiple sample image pairs may be randomly divided into a training set and a validation set in a ratio of 8:2.
[0057] In an embodiment of the present application, image transformation processing includes one or more of the following: scaling, rotation, cropping, flipping, translation, grayscale, noise, blurring, adding text, and aliasing. Each transformation is multi-scale, such as different scaling ratios, rotation angles, cropping ranges, translation ranges, noise sizes, blurring degrees, adding different texts, multiple aliasing, etc.
[0058] S102, for any sample image in the sample image pair, extract features of the sample image using the N-level feature extraction layer in the image similarity recognition model to obtain a candidate feature map of the multi-level feature extraction layer.
[0059] Wherein, N is an integer greater than 2, and m is a positive integer.
[0060] Optionally, in an embodiment of the present application, any level of feature extraction layer from the first level feature extraction layer to the N-1 level feature extraction layer includes a convolution layer and a pooling layer. For example, feature extraction can be performed on the feature map input into the feature extraction layer through multiple convolution layers and a low-pass filter pooling layer to obtain multiple levels of candidate feature maps.
[0061] The Nth-level feature extraction layer performs convolution processing on the candidate feature map N-1 of the N-1th-level feature extraction layer to obtain the candidate feature map N; wherein the input of the first-level feature extraction layer is the sample image in the sample image pair.
[0062] S103, based on the convolution processing and upsampling processing, feature fusion is performed on the candidate feature map N of the N-th level feature extraction layer and the candidate feature map N-1 of the N-1-th level feature extraction layer to obtain the N-1-th level feature map, and the feature fusion is continued on the N-1-th level feature map and the candidate feature map N-2 of the N-2-th level feature extraction layer based on the convolution processing and upsampling processing to obtain the previous level feature map, until the Nm-th level feature map is obtained.
[0063] In the embodiment of the present application, feature fusion is performed based on the specified multi-level candidate feature map and input into the fully connected layer to obtain the target feature map of the sample image.
[0064] Optionally, the candidate feature map N is convolved and upsampled to obtain the N-th level feature map of the N-th level feature extraction layer, the candidate feature map N-1 is convolved and added to the N-th level feature map and upsampled to obtain the N-1-th level feature map, and the candidate feature map N-2 is convolved and added to the N-1-th level feature map and upsampled to obtain the previous level feature map, until the Nm-th level feature map is obtained.
[0065] S104, obtaining a target feature map of the sample image according to the Nm-th level feature map and the candidate feature map Nm-1 of the Nm-1-th level feature extraction layer.
[0066] The Nm-th level feature map is added to the candidate feature map Nm-1, then convolved and input into the fully connected layer to obtain the target feature map.
[0067] S105, according to the reference label value and the target feature map of each of the two sample images, obtain the loss function of the sample image pair to adjust the image similarity recognition model, and continue to use the next sample image pair to train the adjusted image similarity recognition model until the training is completed to obtain the target image similarity recognition model.
[0068] In some embodiments, similarity is calculated based on the target feature maps of the two sample images, and the obtained similarity is compared with a preset similarity threshold. When the similarity is greater than or equal to the similarity threshold, the predicted label value is determined to be a first label value indicating that the sample image pair is similar, and when the similarity is less than the similarity threshold, the predicted label value is determined to be a second label value indicating that the sample image pair is not similar. A cosine loss function is obtained based on the predicted label value and the reference label value.
[0069] In some embodiments, let y represent the target feature map, which has the following mathematical representation: y=F(X), where X represents the input sample image, and F() represents the forward propagation process of the image similarity recognition model.
[0070] During training, for any training set ((X1, X2), label), X1 and X2 represent two sample images in the sample image pair, and label is the reference label value, that is, 0 or 1. The following mathematical representation is available: y1 = F(X1), y2 = F(X2), where y1 represents the target feature map of sample image X1, and y2 represents the target feature map of sample image X2.
[0071] After obtaining the target feature maps of the two sample images, the cosine loss between them and the label is calculated. In some embodiments, the cosine loss function of the sample image pair is obtained using the following formula:
[0072]
[0073]
[0074] α+β=1
[0075] Among them, loss represents the cosine loss function, α, β, γ0, and γ1 represent preset parameters, max represents the operation of taking the maximum value, y1 and y2 represent the target feature maps of the two sample images respectively, label=1 represents the case where the reference label value is the first label value, label=2 represents the case where the reference label value is the second label value, and cosine() represents the similarity operation.
[0076] It should be noted that cosine(y1,y2) represents the cosine value of the angle between the target feature map y1 and the target feature map y2. The more similar the target feature maps are, the closer the cosine value is to 1, and vice versa. Specifically:
[0077] When two sample images are similar: the general loss is 1-cosine(y1,y2), which is the difference between the cosine of the angle between the feature vectors and label 1. In the embodiment of the present application, for sample image pairs with smaller losses, it can be considered that this sample image is relatively simple, and the image similarity recognition model is very easy to recognize, and there is no need to learn such sample images, so it is not included in the overall loss. That is, a parameter γ1 is set, and the loss is less than this parameter is not included in the overall loss. In actual training, sample image pairs with smaller losses gradually account for the majority as the number of iterations increases, and this part has a lower effect on improving network performance. If all losses are still used for training, it may cause the image similarity recognition model to overfit. Therefore, the cosine loss function of the embodiment of the present application can make the image similarity recognition model more focused on learning sample images that are difficult to distinguish, thereby improving the training efficiency and the generalization performance of the network;
[0078] When two sample images are not similar: the general loss is directly cosine(y1,y2). Similarly, the training group with loss less than γ0 is not included.
[0079] In the embodiment of the present application, different weights are assigned to the losses of different label values. Considering that in practical applications of different scenarios, there are different requirements for the accuracy and completeness of similarity recognition. For example, if the handling of abnormal images is very cautious and similarity recognition is required to avoid misjudgment, the weight β can be increased, that is, the weight of the loss when the label value is dissimilar but the image similarity recognition model considers it similar accounts for a larger proportion of the overall loss, thereby driving the image similarity recognition model to judge similarity more strictly;
[0080] If similarity recognition is required to find all possible similar images as much as possible, the weight α can be increased, that is, the loss whose label values are similar but the image similarity recognition model considers them dissimilar will have a larger weight on the overall loss, thereby improving the search performance of the image similarity recognition model.
[0081] The loss is calculated based on the obtained cosine loss function, and the parameters of the image similarity recognition model are updated based on the gradient back propagation algorithm until the loss tends to converge, thereby obtaining a target image similarity recognition model that can recognize various image changes.
[0082] In an embodiment of the present application, for any sample image in a sample image pair, an N-level feature extraction layer in an image similarity recognition model performs feature extraction on the sample image to obtain a candidate feature map of a multi-level feature extraction layer, and feature fusion is performed on the candidate feature map N and the candidate feature map N-1 based on convolution processing and upsampling processing to obtain an N-1th level feature map, and feature fusion is continued on the N-1th level feature map and the candidate feature map N-2 based on convolution processing and upsampling processing to obtain an upper level feature map until an Nmth level feature map is obtained, and a target feature map of the sample image is obtained based on the Nmth level feature map and the candidate feature map Nm-1, which can improve the accuracy and efficiency of image similarity recognition, and obtain a loss function of the sample image pair based on a reference label value and the target feature maps of each of the two sample images to adjust the image similarity recognition model, which can improve the recognition accuracy of the image similarity recognition model for similarity transformations, accurately and timely implement filtering of abnormal image messages, and ensure the security of Internet content.
[0083] Figure 2 FIG. 1 is a flowchart of a method for training an image similarity recognition model according to an embodiment of the present application. Figure 2 As shown, the method comprises the following steps:
[0084] S201, obtaining a sample image pair and its corresponding reference label value, and training an image similarity recognition model based on the sample image pair, wherein the sample image pair includes two different sample images.
[0085] For the introduction of step S201, please refer to the relevant introduction in the above embodiment, which will not be repeated here.
[0086] S202, for the i-th level feature extraction layer, performing convolution processing and low-pass filtering pooling processing on the candidate feature map i-1 of the i-1th level feature extraction layer input into the i-th level feature extraction layer, to obtain the candidate feature map i of the i-th level feature extraction layer.
[0087] Wherein, i is a positive integer less than N.
[0088] Among them, the candidate feature map N is obtained by convolving the candidate feature map N-1 of the N-1th level feature extraction layer by the Nth level feature extraction layer.
[0089] Among them, the input of the first-level feature extraction layer is the sample image.
[0090] like Figure 3As shown, in the embodiment of the present application, the image similarity recognition model is an improved ultra-deep convolutional network VggNet for large-scale recognition. The structure of the image similarity recognition model is described by taking N value 5 as an example. In the first-level feature extraction layer and the second-level feature extraction layer, the feature extraction layer includes two convolution layers and one low-pass filter pooling layer. In the third-level feature extraction layer and the fourth-level feature extraction layer, the feature extraction layer includes three convolution layers and one low-pass filter pooling layer. The fifth-level feature extraction layer includes three convolution layers. Figure 3 In the figure, conv represents the convolutional layer, the size of the candidate feature map of the first-level feature extraction layer is 112x112x64, the size of the candidate feature map of the second-level feature extraction layer is 56x56x128, the size of the candidate feature map of the third-level feature extraction layer is 28x28x256, the size of the candidate feature map of the fourth-level feature extraction layer is 14x14x512, and the size of the candidate feature map of the fifth-level feature extraction layer is 14x14x512.
[0091] In the embodiment of the present application, the VggNet structure obtains the deep features of the sample image through multi-layer convolution and pooling operations. The deep features contain rich semantic information, but the resolution is low and the position and texture information contained in the shallow features are lost. Therefore, images with similar semantic features may not actually be similar. The image similarity recognition model proposed in the embodiment of the present application has an improved VggNet structure, which integrates semantic features and shallow features, so that the final features contain more information and have stronger resolution.
[0092] In an embodiment of the present application, a convolution process is performed on the candidate feature map i-1 in the input i-th level feature extraction layer to obtain a first feature map. The first feature map is subjected to low-pass filtering and pooling processing to obtain a candidate feature map i. The convolution layer is used to extract image features, and the pooling layer is used to reduce the dimension of the feature map, wherein the process of low-pass filtering and pooling (FilterPool) processing on the first feature map includes: performing maximum pooling processing, padding processing, low-pass filtering convolution processing and downsampling processing with a preset step size on the first feature map. The convolution operation based on the sliding window has translation invariance, while the maximum pooling layer will cause the loss of translation invariance of the network. In an embodiment of the present application, combining low-pass filtering with maximum pooling can alleviate the loss of translation invariance to a great extent.
[0093] The following is a detailed description of the low-pass filter pooling process in the embodiment of the present application:
[0094] like Figure 4As shown, taking one-dimensional pooling as an example, the maximum pooling process with a step size of 2 can be decomposed into two equal steps: maximum pooling with a step size of 1 and downsampling. In the embodiment of the present application, a low-pass filter is introduced between the maximum pooling with a step size of 1 and the downsampling operation, and is implemented using a low-pass filter convolution kernel. The characteristic of the low-pass filter convolution kernel is that the value at the center of the kernel is greater than the value at the edge position, so as to achieve smooth processing on the edge. Taking the above one-dimensional pooling as an example, let the low-pass filter convolution kernel be [0.25, 0.5, 0.25]. The low-pass filter pooling result is as follows: Figure 5 As shown, optionally, Figure 5 The filling process in the embodiment may adopt a "reflection filling" method or other filling methods, and the embodiment of the present application is not limited to this.
[0095] like Figure 6 As shown, based on the above low-pass filtering pooling, the result obtained after shifting the input by 1 bit is [0.75, 0.75, 0.75, 0.75]. It can be calculated that based on the low-pass filtering pooling, the similarity between the two is 0.95. It can be seen that the low-pass filtering pooling ensures the translation invariance.
[0096] In summary, extended to two-dimensional pooling, a low-pass filter pooling layer is proposed in the embodiment of the present application to replace the maximum pooling layer in VggNet. The low-pass filter pooling layer includes four operation steps: maximum pooling with a step size of 1, reflection filling, low-pass filter convolution, and downsampling. The two-dimensional low-pass filter uses a convolution kernel of size 3x3. In some embodiments, the convolution kernel used for the low-pass filter convolution process is as follows:
[0097]
[0098] Among them, parameters A, B, and C satisfy 4A+4B+4C=1, that is, the sum of all parameters should be equal to 1, so that the brightness of the image before and after convolution remains unchanged. In addition, the parameters at the center should be greater than the edge parameters C>B>A.
[0099] Optionally, there is According to the above parameter selection rules, when the values of p and q are larger, the weight of the center parameter is higher, and the convolution result is closer to the original input, that is, the effect of low-pass filtering is not obvious; on the contrary, the values of all parameters are close, and the low-pass filtering effect is more significant. For example, in the above one-dimensional convolution example, if the convolution kernel of [0.2, 0.6, 0.2] is used, the weight of the center parameter is higher than that of the convolution kernel of [0.25, 0.5, 0.25]. The cosine similarity between the result of 1-bit translation and the original result is 0.91, which is less than 0.95; if the convolution kernel of [0.3, 0.4, 0.3] is used, the value is more average than that of the convolution kernel of [0.25, 0.5, 0.25]. The cosine similarity between the result of 1-bit translation and the original result is 0.97, which is greater than 0.95. However, the smaller the values of p and q are, the more likely it is that a large amount of input information will be lost, reducing the distinguishability of the final extracted features. Therefore, p=2 and q=2 can generally be selected.
[0100] S203, performing convolution processing and upsampling processing on the candidate feature map N to obtain the Nth level feature map of the Nth level feature extraction layer.
[0101] like Figure 3 As shown, the size of the input sample image is 224x224x3, and the bottom-up process is the forward propagation process. In addition, the embodiment of the present application proposes a new model propagation process: the channels of the candidate feature map of the 5th level feature extraction layer are fused by a 1x1 convolution kernel, the number of channels is reduced to 256, and the nearest neighbor interpolation method is used for upsampling, so that the output dimension is 28x28x256, which is recorded as the fifth level feature map.
[0102] S204, performing convolution processing on the candidate feature map N-1, adding the result to the Nth level feature map and performing upsampling processing to obtain the N-1th level feature map.
[0103] The channels of the candidate feature map N-1 of the N-1th level feature extraction layer are fused through a 1x1 convolution kernel, the number of channels is reduced to 256, and it is added to the Nth level feature map, and upsampled again to make the output dimension 56x56x256, which is recorded as the N-1th level feature map.
[0104] S205, continue to perform convolution processing on the candidate feature map N-2, add it to the N-1th level feature map and perform upsampling processing to obtain the previous level feature map, until the Nmth level feature map is obtained.
[0105] like Figure 3 As shown in the figure, taking m as 1 as an example, the channels of the candidate feature map of the fourth-level feature extraction layer are fused through a 1x1 convolution kernel, the number of channels is reduced to 256, and then added to the fifth-level feature map, and upsampled again to make the output dimension 56x56x256, which is recorded as the fourth-level feature map.
[0106] S206, adding the Nm-th level feature map to the candidate feature map Nm-1 to obtain a fused feature map.
[0107] like Figure 3 As shown, the fourth-level feature map is added to the candidate feature map of the third-level feature extraction layer to obtain a fused feature map.
[0108] S207, performing convolution processing on the fused feature map and inputting it into the fully connected layer to obtain the target feature map.
[0109] like Figure 3 As shown in the figure, the fused feature map is then passed through a 3x3 convolution layer to eliminate the aliasing effect caused by upsampling, and then through a 1x1 convolution kernel to fuse the information of each channel, with an output dimension of 56x56x1. Finally, a 256-neuron fully connected layer is used to obtain the target feature map of the sample image, with a dimension of 1x1x256.
[0110] S208, according to the reference label value and the target feature map of each of the two sample images, obtain the loss function of the sample image pair to adjust the image similarity recognition model, and continue to use the next sample image pair to train the adjusted image similarity recognition model until the training is completed to obtain the target image similarity recognition model.
[0111] For the introduction of step S208, please refer to the relevant content in the above embodiment, which will not be repeated here.
[0112] In the embodiment of the present application, for the i-th level feature extraction layer, the candidate feature map i-1 of the i-1th level feature extraction layer input into the i-th level feature extraction layer is convoluted and low-pass filtered and pooled to obtain the candidate feature map i of the i-th level feature extraction layer. The low-pass filtered and pooled processing can alleviate the loss of translation invariance of the convolutional network to a large extent. The image similarity recognition model has an improved VggNet structure, which integrates semantic features and shallow features, so that the final features contain more information and have stronger resolution. The cosine loss function does not count the loss for samples that are easier to identify, so that the network is more focused on learning samples that are difficult to identify, which is conducive to improving the recognition accuracy. In addition, the new loss function can assign different loss weights to similar or dissimilar training groups to balance the precision and completeness of network similarity recognition.
[0113] Figure 7 is a flow chart of an image similarity recognition method according to an embodiment of the present application. Figure 7 As shown, the method comprises the following steps:
[0114] S701, obtaining a target image pair to be identified, where the target image pair includes two different target images.
[0115] Optionally, image acquisition can be performed in a network environment to obtain two target images to be identified, or one target image can be acquired and combined with any image in a preset data set to form a target image pair.
[0116] S702, input the target image pair into the trained target image similarity recognition model, the target image similarity recognition model outputs the target feature maps of the two target images respectively, and calculates the similarity based on the target feature maps.
[0117] The target image similarity recognition model is a model trained using the training method of the above-mentioned image similarity recognition model.
[0118] Optionally, the similarity can be calculated based on the cosine distance between the two target feature maps.
[0119] S703: In response to the similarity being greater than or equal to a preset similarity threshold, determining that the two target images are similar, or in response to the similarity being less than the similarity threshold, determining that the two target images are not similar.
[0120] The embodiment of the present application adopts the above training method to obtain a target image similarity recognition model, which has a high recognition accuracy rate for various image transformations. It can improve the accuracy and efficiency of image similarity recognition, accurately and timely filter abnormal image messages, and ensure the security of Internet content.
[0121] In some embodiments, based on the target image similarity recognition model, a feature map of the abnormal image is extracted, and an abnormal feature library can be constructed and maintained. For the image to be identified, its cosine similarity with the feature map in the feature library is calculated, and a judgment threshold is set. If the cosine distance is greater than this threshold, the images are considered similar and the image to be identified needs to be processed in the next step.
[0122] Figure 8 is a structural diagram of a training device for an image similarity recognition model according to an embodiment of the present disclosure, such as Figure 8 As shown, the training device 800 of the image similarity recognition model includes:
[0123] A first acquisition module 810 is used to acquire a sample image pair and its corresponding reference label value, and train an image similarity recognition model based on the sample image pair, wherein the sample image pair includes two different sample images;
[0124] The second acquisition module 820 is used to extract features of any sample image in the sample image pair by using the N-level feature extraction layer in the image similarity recognition model to obtain a candidate feature map of the multi-level feature extraction layer, where N is an integer greater than 2;
[0125] The third acquisition module 830 is used to perform feature fusion on the candidate feature map N of the N-th feature extraction layer and the candidate feature map N-1 of the N-1-th feature extraction layer based on convolution processing and upsampling processing to obtain the N-1-th feature map, and continue to perform feature fusion on the N-1-th feature map and the candidate feature map N-2 of the N-2-th feature extraction layer based on convolution processing and upsampling processing to obtain the previous level feature map, until the Nm-th level feature map is obtained;
[0126] A fourth acquisition module 840 is used to acquire a target feature map of the sample image according to the Nm-th level feature map and the candidate feature map Nm-1 of the Nm-1-th level feature extraction layer, where m is a positive integer;
[0127] The training module 850 is used to obtain the loss function of the sample image pair according to the reference label value and the target feature map of each of the two sample images to adjust the image similarity recognition model, and continue to use the next sample image pair to train the adjusted image similarity recognition model until the training is completed to obtain the target image similarity recognition model.
[0128] In some embodiments, the second acquisition module 820 is also used to: for the i-th level feature extraction layer, perform convolution processing and low-pass filtering pooling processing on the candidate feature map i-1 of the i-1th level feature extraction layer input into the i-th level feature extraction layer, to obtain the candidate feature map i of the i-th level feature extraction layer, where i is a positive integer less than N; wherein the candidate feature map N is obtained by the N-th level feature extraction layer performing convolution processing on the candidate feature map N-1 of the N-1th level feature extraction layer; wherein the input of the first-level feature extraction layer is the sample image.
[0129] In some embodiments, the third acquisition module 830 is further used to: perform convolution processing and upsampling processing on the candidate feature map N to obtain the Nth level feature map of the Nth level feature extraction layer; perform convolution processing on the candidate feature map N-1, add it to the Nth level feature map and perform upsampling processing to obtain the N-1th level feature map.
[0130] In some implementations, the third acquisition module 830 is further used to: continue to perform convolution processing on the candidate feature map N-2, add it to the N-1th level feature map, and perform upsampling processing to obtain the previous level feature map.
[0131] In some embodiments, the fourth acquisition module 840 is further used to: add the Nm-th level feature map to the candidate feature map Nm-1 to obtain a fused feature map; and perform convolution processing on the fused feature map and input it into the fully connected layer to obtain a target feature map.
[0132] In some embodiments, the second acquisition module 820 is also used to: perform convolution processing on the candidate feature map i-1 in the input i-th level feature extraction layer to obtain a first feature map; perform low-pass filtering and pooling processing on the first feature map to obtain a candidate feature map i; wherein the process of performing low-pass filtering and pooling processing on the first feature map includes: performing maximum pooling processing with a preset step size, padding processing, low-pass filtering convolution processing and downsampling processing on the first feature map.
[0133] In some embodiments, the convolution kernel used in the low-pass filter convolution process is as follows:
[0134]
[0135] Among them, parameters A, B, and C satisfy 4A+4B+4C=1, C>B>A.
[0136] In some embodiments, the reference label value includes a first label value indicating that the sample image pair is similar and a second label value indicating that the sample image pair is not similar. The first acquisition module 810 is also used to: acquire multiple initial images; for any initial image, perform different image transformation processing on the initial image to acquire multiple transformed images of the initial image, and use the initial image and the multiple transformed images of the initial image as the image set of the initial image; extract any two images from the image set of the same initial image to obtain a sample image pair, and determine that the label value corresponding to the sample image pair is the first label value; or extract an image from each of the two different initial image image sets to obtain a sample image pair, and determine that the label value corresponding to the sample image pair is the second label value.
[0137] In some implementations, the cosine loss function of the sample image pair is obtained using the following formula:
[0138]
[0139]
[0140] α+β=1
[0141] Among them, loss represents the cosine loss function, α, β, γ0, and γ1 represent preset parameters, max represents the operation of taking the maximum value, y1 and y2 represent the target feature maps of the two sample images respectively, label=1 represents the case where the reference label value is the first label value, label=2 represents the case where the reference label value is the second label value, and cosine() represents the similarity operation.
[0142] In an embodiment of the present application, for any sample image in a sample image pair, the N-level feature extraction layer in the image similarity recognition model performs feature extraction on the sample image to obtain a multi-level candidate feature map, and feature fusion is performed based on the multi-level candidate feature map to obtain a target feature map of the sample image, which can improve the accuracy and efficiency of image similarity recognition. According to the reference label value and the target feature map of each of the two sample images, the cosine loss function of the sample image pair is obtained to adjust the image similarity recognition model, which can improve the recognition accuracy of the image similarity recognition model for similarity transformations, accurately and timely implement filtering of abnormal image messages, and ensure the security of Internet content.
[0143] Fig. 9 is a structural diagram of an image similarity recognition device according to an embodiment of the present disclosure, such as Fig. 9 As shown, the image similarity recognition device 900 includes:
[0144] An acquisition module 910 is used to acquire a target image pair to be identified, where the target image pair includes two different target images;
[0145] A similarity recognition module 920 is used to input the target image pair into a trained target image similarity recognition model, and the target image similarity recognition model outputs target feature maps of the two target images, and calculates the similarity based on the target feature maps;
[0146] A determination module 930, configured to determine that the two target images are similar in response to the similarity being greater than or equal to a preset similarity threshold, or to determine that the two target images are not similar in response to the similarity being less than the similarity threshold;
[0147] Among them, the target image similarity recognition model is a model trained using the above training device.
[0148] The embodiment of the present application adopts the above training method to obtain a target image similarity recognition model, which has a high recognition accuracy rate for various image transformations. It can improve the accuracy and efficiency of image similarity recognition, accurately and timely filter abnormal image messages, and ensure the security of Internet content.
[0149] Based on the same application concept, an embodiment of the present application also provides an electronic device.
[0150] Fig.10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Fig.10 As shown, the electronic device 1000 includes a memory 1001, a processor 1002, and a computer program product stored in the memory 1001 and executable on the processor 1002. When the processor executes the computer program, the aforementioned image similarity recognition model training method or image similarity recognition method is implemented.
[0151] In order to implement the above embodiments, the present application also proposes a computer-readable storage medium, which stores computer execution instructions. When the computer execution instructions are executed by a processor, they are used to implement the training method of the image similarity recognition model or the image similarity recognition method provided in the above embodiments.
[0152] In order to implement the above embodiments, the present application also proposes a computer program product, including a computer program, which, when executed by a processor, implements the training method of the image similarity recognition model or the image similarity recognition method provided in the above embodiments.
[0153] The collection, storage, use, processing, transmission, provision and disclosure of user personal information involved in this application are in compliance with relevant laws and regulations and do not violate public order and good morals.
[0154] It should be noted that personal information from users should be collected for legitimate and reasonable purposes and should not be shared or sold outside of these legitimate uses. In addition, such collection / sharing should be carried out after receiving the user's informed consent, including but not limited to notifying the user to read the user agreement / user notice and sign the agreement / authorization including authorization of relevant user information before the user uses the function. In addition, any necessary steps should be taken to protect and safeguard access to such personal information data and ensure that others who have access to personal information data comply with its privacy policy and procedures.
[0155] The present application is expected to provide an implementation scheme for users to selectively block the use or access of personal information data. That is, the present disclosure is expected to provide hardware and / or software to prevent or block access to such personal information data. Once the personal information data is no longer needed, the risk can be minimized by limiting data collection and deleting the data. In addition, when applicable, such personal information is de-identified to protect the privacy of the user.
[0156] In the description of the aforementioned embodiments, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0157] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0158] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or more executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0159] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute the instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purpose of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.
[0160] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0161] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0162] In addition, each functional unit in each embodiment of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0163] The storage medium mentioned above may be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limiting the present application. A person of ordinary skill in the art may change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A training method for an image similarity recognition model, characterized in that: include: Acquire a sample image pair and its corresponding reference label value, and train an image similarity recognition model based on the sample image pair, wherein the sample image pair includes two different sample images; the reference label value includes a first label value indicating that the sample image pair is similar and a second label value indicating that the sample image pair is not similar; For any sample image in the sample image pair, extract features of the sample image using an N-level feature extraction layer in the image similarity recognition model to obtain a candidate feature map of a multi-level feature extraction layer, where N is an integer greater than 2; Based on the convolution process and the upsampling process, feature fusion is performed on the candidate feature map N of the N-th feature extraction layer and the candidate feature map N-1 of the N-1-th feature extraction layer to obtain the N-1-th feature map, and the feature fusion is continued on the N-1-th feature map and the candidate feature map N-2 of the N-2-th feature extraction layer to obtain the previous feature map, until the Nm-th feature map is obtained, where m is a positive integer; Acquire a target feature map of the sample image according to the Nm-th level feature map and the candidate feature map Nm-1 of the Nm-1-th level feature extraction layer; According to the reference label value and the target feature maps of the two sample images, a loss function of the sample image pair is obtained to adjust the image similarity recognition model, and the adjusted image similarity recognition model is continuously trained using the next sample image pair until the training is completed to obtain a target image similarity recognition model; Wherein, obtaining the loss function of the sample image pair according to the reference label value and the target feature maps of the two sample images respectively includes: Similarity is calculated based on the target feature maps of each of the two sample images, and the obtained similarity is compared with a preset similarity threshold. When the similarity is greater than or equal to the similarity threshold, the predicted label value is determined to be a first label value indicating that the sample image pair is similar; when the similarity is less than the similarity threshold, the predicted label value is determined to be a second label value indicating that the sample image pair is not similar; and the loss function is obtained based on the predicted label value and the reference label value.
2. The method according to claim 1, characterized in that The method further comprises: For the i-th level feature extraction layer, convolution processing and low-pass filtering pooling processing are performed on the candidate feature graph i-1 of the i-1th level feature extraction layer input into the i-th level feature extraction layer to obtain the candidate feature graph i of the i-th level feature extraction layer, where i is a positive integer less than N; The candidate feature map N is obtained by performing convolution processing on the candidate feature map N-1 by the N-th level feature extraction layer; The input of the first-level feature extraction layer is the sample image.
3. The method according to claim 2, characterized in that The method of performing feature fusion on the candidate feature map N of the Nth level feature extraction layer and the candidate feature map N-1 of the N-1th level feature extraction layer based on convolution processing and upsampling processing to obtain the N-1th level feature map includes: Performing convolution processing and upsampling processing on the candidate feature map N to obtain an N-th level feature map of the N-th level feature extraction layer; The candidate feature map N-1 is convolved and then added to the Nth level feature map and up-sampled to obtain the N-1th level feature map.
4. The method according to claim 3, characterized in that The step of continuing to perform feature fusion on the N-1th level feature map and the candidate feature map N-2 of the N-2th level feature extraction layer based on convolution processing and upsampling processing to obtain the previous level feature map includes: The candidate feature map N-2 is further convolved and added to the N-1th level feature map, and then up-sampled to obtain the previous level feature map.
5. The method according to claim 3, characterized in that: The step of obtaining the target feature map of the sample image according to the Nm-th level feature map and the candidate feature map Nm-1 of the Nm-1-th level feature extraction layer includes: Add the Nm-th level feature map to the candidate feature map Nm-1 to obtain a fused feature map; The fused feature map is convolutionally processed and then input into a fully connected layer to obtain the target feature map.
6. The method according to claim 2, characterized in that The step of performing convolution processing and low-pass filtering and pooling processing on the candidate feature graph i-1 of the i-1th level feature extraction layer input into the i-th level feature extraction layer to obtain the candidate feature graph i of the i-th level feature extraction layer comprises: Performing convolution processing on the candidate feature map i-1 input into the i-th level feature extraction layer to obtain a first feature map; Performing low-pass filtering and pooling processing on the first feature map to obtain the candidate feature map i; Among them, the process of performing low-pass filtering and pooling processing on the first feature map includes: performing maximum pooling processing with a preset step size, padding processing, low-pass filtering convolution processing and downsampling processing on the first feature map.
7. The method according to claim 2, characterized in that: The convolution kernel used in the low-pass filter convolution process is as follows: Among them, parameters A, B, and C satisfy 4A+4B+4C=1, C>B>A.
8. The method according to any one of claims 1 to 7, characterized in that: The reference label value includes a first label value indicating that the sample image pair is similar and a second label value indicating that the sample image pair is not similar. The acquiring the sample image pair and its corresponding reference label includes: Obtain multiple initial images; For any initial image, perform different image transformation processing on the initial image to obtain multiple transformed images of the initial image, and use the initial image and the multiple transformed images of the initial image as an image set of the initial image; Extract any two images from the image set of the same initial image to obtain the sample image pair, and determine that the label value corresponding to the sample image pair is the first label value; or extract an image from each of two different initial image image sets to obtain the sample image pair, and determine that the label value corresponding to the sample image pair is the second label value.
9. The method according to claim 8, characterized in that The loss function is a cosine loss function, and the cosine loss function of the sample image pair is obtained using the following formula: α+β=1 Among them, loss represents the cosine loss function, α, β, γ0, and γ1 represent preset parameters, max represents the operation of taking the maximum value, y1 and y2 respectively represent the target feature maps of the two sample images, label=1 represents the case where the reference label value is the first label value, label=2 represents the case where the reference label value is the second label value, and cosine() represents the similarity operation.
10. A method for image similarity recognition, characterized in that: include: Acquire a target image pair to be identified, wherein the target image pair includes two different target images; Input the target image pair into a trained target image similarity recognition model, the target image similarity recognition model outputs target feature maps of the two target images, and calculates similarity based on the target feature maps; In response to the similarity being greater than or equal to a preset similarity threshold, determining that the two target images are similar, or in response to the similarity being less than the similarity threshold, determining that the two target images are not similar; Wherein, the target image similarity recognition model is a model trained using the training method described in any one of claims 1-9.
11. A training device for an image similarity recognition model, characterized in that: include: A first acquisition module is used to acquire a sample image pair and a reference label value corresponding thereto, and train an image similarity recognition model based on the sample image pair, wherein the sample image pair includes two different sample images; the reference label value includes a first label value indicating that the sample image pair is similar and a second label value indicating that the sample image pair is not similar; A second acquisition module is used to extract features of any sample image in the sample image pair by using N-level feature extraction layers in the image similarity recognition model to obtain a candidate feature map of a multi-level feature extraction layer, where N is an integer greater than 2; A third acquisition module is used to perform feature fusion on the candidate feature map N of the N-th feature extraction layer and the candidate feature map N-1 of the N-1-th feature extraction layer based on convolution processing and upsampling processing to obtain the N-1-th feature map, and continue to perform feature fusion on the N-1-th feature map and the candidate feature map N-2 of the N-2-th feature extraction layer based on convolution processing and upsampling processing to obtain the previous level feature map, until the Nm-th level feature map is obtained; A fourth acquisition module is used to acquire a target feature map of the sample image according to the Nm-th level feature map and the candidate feature map Nm-1 of the Nm-1-th level feature extraction layer, where m is a positive integer; A training module, used to obtain the loss function of the sample image pair according to the reference label value and the target feature map of each of the two sample images, so as to adjust the image similarity recognition model, and continue to use the next sample image pair to train the adjusted image similarity recognition model until the training is completed to obtain the target image similarity recognition model; Wherein, the training module is specifically used for: Similarity is calculated based on the target feature maps of each of the two sample images, and the obtained similarity is compared with a preset similarity threshold. When the similarity is greater than or equal to the similarity threshold, the predicted label value is determined to be a first label value indicating that the sample image pair is similar; when the similarity is less than the similarity threshold, the predicted label value is determined to be a second label value indicating that the sample image pair is not similar; and the loss function is obtained based on the predicted label value and the reference label value.
12. An image similarity recognition device, characterized in that: include: An acquisition module, used for acquiring a target image pair to be identified, wherein the target image pair includes two different target images; A similarity recognition module, used for inputting the target image pair into a trained target image similarity recognition model, having the target image similarity recognition model output target feature maps of the two target images, and calculating similarity based on the target feature maps; a determination module, configured to determine that the two target images are similar in response to the similarity being greater than or equal to a preset similarity threshold, or to determine that the two target images are not similar in response to the similarity being less than the similarity threshold; Wherein, the target image similarity recognition model is a model trained by using the training device as described in claim 11.
13. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the method of any one of claims 1 to 9, or execute the method of claim 10.
14. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to make the computer execute the steps of the method according to any one of claims 1 to 9, or execute the steps of the method according to claim 10.
15. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements the method according to any one of claims 1 to 9, or implements the method according to claim 10.
