Image comparison model construction method and device, equipment, medium and product

By constructing an image comparison model and extracting features using a comparison learning framework, the problem of difficult to identify transformed images in the prior art is solved, and high-precision image comparison is achieved.

CN119600377APending Publication Date: 2025-03-11CHINA MOBILE GROUP DESIGN INST +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411602304.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-11
Publication Date
2025-03-11

AI Technical Summary

Technical Problem

The existing image plagiarism checking methods are difficult to accurately identify slightly transformed images, resulting in poor recognition accuracy.

Method used

By constructing an image comparison model, positive sample images and negative sample images are generated, image features are extracted using the contrast learning framework, and model parameters are updated to improve image comparison accuracy.

Benefits of technology

It realizes robustness for image content transformation, can accurately identify the same image or similar images after a certain transformation operation, and improves the image comparison accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119600377A_ABST
    Figure CN119600377A_ABST
Patent Text Reader

Abstract

The invention discloses an image comparison model construction method and apparatus, a device, a medium and a product. The method comprises the steps of generating corresponding positive example sample images through a transformation operation on each original image in an obtained image database; other images except the original image in the image database are determined as negative example sample images; inputting each original image, the corresponding negative example sample image and the corresponding positive example sample image into an extraction layer of a preset image comparison model for feature extraction; and performing comparative learning according to the extracted features, and updating parameters of the image comparison model. The invention provides a model capable of accurately carrying out image transformation identification, when duplicate checking detection is carried out, the model has robustness on image content transformation, the same images or similar images after certain transformation operation can be accurately identified, and the image comparison precision is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing technology, and in particular to an image contrast model construction method, device, equipment, medium and product. Background Art

[0002] In today's era of information explosion, image data, as an important part of multimedia content, is generated, disseminated and stored at an unprecedented speed. With the rapid development of social media, e-commerce, medical imaging, copyright protection and other fields, the management and retrieval of image data are facing unprecedented challenges.

[0003] However, existing image duplication detection methods often rely on direct comparison at the pixel level, and these methods are difficult to accurately identify images that have undergone certain image transformations (such as cropping, rotation, lighting changes, etc.). In fact, slightly transformed versions of images should be judged as duplicates of the original image because they do not change the key content and key features of the image. Existing recognition schemes easily identify them as different images, and the recognition accuracy of existing recognition schemes is poor. Summary of the invention

[0004] In order to solve the above problems, the present invention proposes a method, device, equipment, medium and product for constructing an image contrast model, providing a model that can accurately perform image transformation recognition and improve image contrast accuracy.

[0005] An embodiment of the present invention provides a method for constructing an image contrast model, the method comprising:

[0006] Generate corresponding positive sample images through transformation operations on each original image in the acquired image database;

[0007] Determine other images in the image database except the original image as negative sample images;

[0008] Input each original image, the corresponding negative sample image and the corresponding positive sample image into the extraction layer of the preset image contrast model for feature extraction;

[0009] Contrastive learning is performed based on the extracted features to update the parameters of the image contrast model.

[0010] Preferably, the method further comprises:

[0011] Extracting images from the image database according to the image contrast model to obtain a feature library of each image;

[0012] Inputting the image to be detected into the image comparison model to obtain the feature to be detected;

[0013] Calculating the similarity value between the feature to be measured and the features of each image in the feature library;

[0014] It is determined whether the image to be detected is repeated with the image in the image database according to the calculated similarity.

[0015] As a preferred solution, judging whether the image to be detected is repeated with the image in the image database according to the calculated similarity includes:

[0016] When the similarity value between the feature to be detected and the feature of a certain image in the feature library is less than a preset first threshold, it is determined that the image to be detected is the same as the image;

[0017] When the similarity value between the feature vector of the to-be-detected feature and a feature vector of an image in the image database is not less than the first threshold, it is determined that the to-be-detected image is different from the image.

[0018] Preferably, the process of generating corresponding positive sample images by transforming each original image in the acquired image database further comprises:

[0019] Performing image enhancement processing on each original image in the image database;

[0020] A transformation operation is randomly selected from a preset transformation library to process the enhanced image and obtain the corresponding positive sample image.

[0021] Furthermore, the transformation operations in the transformation library include at least one of the following:

[0022] Crop the image according to the preset ratio;

[0023] Rotate the image according to the preset angle;

[0024] Performing brightness and / or contrast adjustment processing on the image according to preset adjustment parameters;

[0025] Performing saturation and / or color conversion processing on the image according to preset color parameters;

[0026] Compress the image according to the preset scaling ratio.

[0027] Preferably, each original image, the corresponding negative sample image and the corresponding positive sample image are input into an extraction layer of a preset image contrast model for feature extraction, including:

[0028] An encoder is used to extract features from each original image, the corresponding negative sample image, and the corresponding positive sample image to obtain image features;

[0029] The extracted image features are subjected to dimensionality reduction extraction by the extractor to determine the encoding vector features.

[0030] Furthermore, an encoder is used to extract features from each original image, the corresponding negative sample image, and the corresponding positive sample image to obtain image features, including:

[0031] A deep residual network is used as an encoder to extract features from each original image, the corresponding negative sample image, and the corresponding positive sample image to obtain the corresponding image features.

[0032] As a preferred solution, the extracted image features are subjected to dimensionality reduction extraction by an extractor to determine the encoding vector features, including:

[0033] A fully connected layer is used as an extractor to compress and integrate the extracted image features to obtain the encoding vector features.

[0034] Preferably, performing contrast learning according to the extracted features and updating the parameters of the image contrast model include:

[0035] Calculate the loss value between different features according to the preset loss function;

[0036] The obtained loss value is transmitted back to the feature extraction layer through the back propagation algorithm, and the parameters of the image contrast model are updated by the optimizer;

[0037] When the model training termination condition is not reached, a loop iteration is performed, and the optimizer is used to update the parameters of the image contrast model to minimize the contrast loss;

[0038] When the model training termination condition is reached, the image contrast model is output.

[0039] Furthermore, the loss function is

[0040]

[0041] Among them, InfoNCE loss is the calculated loss value, N is the number of positive pairs consisting of the original image and the corresponding positive sample image, and z i is the encoding vector feature of the original image in the i-th positive example pair, is the encoding vector feature of the positive sample image in the i-th positive pair, is the encoding vector feature of the jth negative sample image corresponding to the original image in the i-th positive pair, K is the number of negative sample images, and sim(·,·) is the similarity function used.

[0042] Preferably, the obtained loss value is transmitted back to the feature extraction layer through a back propagation algorithm, and the parameters of the image contrast model are updated using an optimizer, including:

[0043] Through the back-propagation algorithm, the loss value is propagated back to the feature extraction layer, and the parameters of the encoder and extractor are updated using the SGD optimizer.

[0044] The embodiment of the present invention further provides an image contrast model construction device, the device comprising:

[0045] A positive example module, used to generate corresponding positive example sample images by transforming each original image in the acquired image database;

[0046] A negative example module, used for determining other images in the image database except the original image as negative example sample images;

[0047] An extraction module, used for inputting each original image, the corresponding negative sample image and the corresponding positive sample image into an extraction layer of a preset image contrast model for feature extraction;

[0048] The training module is used to perform contrast learning based on the extracted features and update the parameters of the image contrast model.

[0049] An embodiment of the present invention also provides a terminal device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein when the processor executes the computer program, the image contrast model construction method as described in any of the above embodiments is implemented.

[0050] An embodiment of the present invention also provides a computer-readable storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the image contrast model construction method described in any of the above embodiments.

[0051] An embodiment of the present invention further provides a computer program product, including a computer program / instruction, which implements the steps of any of the above methods when executed by a processor.

[0052] The present invention provides an image contrast model construction method, device, equipment, medium and product, which generates corresponding positive sample images by transforming each original image in an acquired image database; determines other images in the image database except the original image as negative sample images; inputs each original image, the corresponding negative sample image and the corresponding positive sample image into an extraction layer of a preset image contrast model for feature extraction; performs contrast learning based on the extracted features, and updates the parameters of the image contrast model. The present application provides a model that can accurately perform image transformation recognition, which is robust to the transformation of image content when performing duplicate detection, and can accurately identify the same image or similar images after certain transformation operations, thereby improving image comparison accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] Figure 1 is a flow chart of a method for constructing an image contrast model provided by an embodiment of the present invention;

[0054] Figure 2 is a schematic diagram of an image comparison process provided by an embodiment of the present invention;

[0055] Figure 3 is another flow chart of the method for constructing an image contrast model provided by an embodiment of the present invention;

[0056] Figure 4 is a structural schematic diagram of an image contrast model building device provided by an embodiment of the present invention;

[0057] Figure 5 It is a structural diagram of a terminal device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0058] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0059] In view of the above technical problems, this case provides a method for constructing an image contrast model, see Figure 1 , is a flow chart of a method for constructing an image contrast model provided by an embodiment of the present invention, the method comprising:

[0060] Step S1, generating corresponding positive sample images by transforming each original image in the acquired image database;

[0061] Step S2, determining other images in the image database except the original image as negative sample images;

[0062] Step S3, inputting each original image, the corresponding negative sample image and the corresponding positive sample image into the extraction layer of the preset image contrast model for feature extraction;

[0063] Step S4, performing contrast learning based on the extracted features, and updating the parameters of the image contrast model.

[0064] In the specific implementation of this embodiment, an image database containing multiple image types is collected, and the source can be an image database involved in the customer's own business, or an open source dataset such as ImageNet. The dataset should cover as wide a range of image styles and scenes as possible, and ensure that there are no duplicate images or slightly transformed similar images.

[0065] Existing solutions propose to encode and compare the pixel values ​​of the image to perform similarity judgment; or convert the pixel values ​​of the image to the wavelet domain, then generate hash codes and then perform comparison judgment. This type of solution uses the consistency of image pixel values ​​as the duplication check standard. Although it is fast, it is not robust. If certain transformation operations are performed on the image, such as rotation, cropping, etc., it will seriously interfere with the encoding results and similarity results of the image, resulting in misjudgment.

[0066] Therefore, in the specific implementation of this case, each original image in the image database is transformed to generate a corresponding positive sample image.

[0067] The other images in the image database except the original image are determined as negative sample images.

[0068] It should be noted that the positive sample image is essentially the same image obtained by transforming the original image, and it is difficult for the existing technology to identify such a transformation process. The negative sample image is essentially different image.

[0069] After obtaining the original image, the corresponding negative sample image and the corresponding positive sample image, each original image, the corresponding negative sample image and the corresponding positive sample image are input into the extraction layer of the preset image contrast model for feature extraction to obtain the extracted features.

[0070] By performing contrastive learning through the extracted features, a contrast relationship between the original image, the corresponding negative sample image and the corresponding positive sample image is established, and through the target of contrastive learning, the parameters of the image contrast model are updated to obtain the image contrast model.

[0071] Existing solutions require using a pre-trained target detection model to detect key element areas in an image, and then extracting visual feature vectors or feature points from the key areas to calculate similarity and judge visual similarity. However, such solutions require pre-training target detection models for different categories of images, which not only increases the complexity of the process (needs to label a large amount of data and train multiple target detection models), but also limits its application scenarios and generalization capabilities.

[0072] It should be noted that the image comparison model in this case can be used to accurately extract image features for similarity detection and recognition.

[0073] This embodiment introduces a contrastive learning framework for duplicate detection, takes slightly transformed versions of each image (such as rotation, cropping, brightness adjustment, etc.) as positive pairs, and all images except the image itself and the transformed version as negative pairs, and extracts image features through contrastive learning to perform duplicate detection. The proposed duplicate detection method is robust to changes in image content and can accurately identify the same image or similar images after certain transformation operations.

[0074] The present invention does not require a pre-trained target detection model and corresponding annotation data, which reduces the technical threshold and cost. The algorithm is efficient and can be quickly integrated into the database of any business side, meeting the requirements of plug-and-play, rapid integration, and flexible deployment.

[0075] In another embodiment of the present invention, when using the image comparison file to compare images, refer to Figure 2 , is a schematic diagram of an image comparison process provided by an embodiment of the present invention, which specifically includes:

[0076] After acquiring the image library, an image comparison model is obtained through model training.

[0077] According to the image contrast model, features of images in the image database are extracted, that is, Embedding extraction is performed to obtain feature vectors of each image to form an Embedding library.

[0078] After completing the comparison model training, you need to use the trained model to extract the embedding of each image in the image library. Assuming there are M images in the image library, and the feature dimension extracted from each image is 1*512, the total feature dimension that needs to be stored in the image library is M*512, and the data type is float. These features can be stored in a MySQL database for quick addition, deletion, modification and query.

[0079] After the image to be tested is uniformly resized and normalized, its embedding is extracted using the trained image comparison model to obtain the features to be tested.

[0080] The embedding of the image to be detected is quickly calculated with the embedding in the feature library. Based on the similarity calculation results, the most similar image and its corresponding similarity value are returned.

[0081] It is determined whether the image to be detected is repeated with the image in the image database according to the calculated similarity.

[0082] It should be noted that the scheme for calculating the similarity value may be calculated by using a similarity determination scheme in the prior art, such as calculation methods such as Hamming distance and cosine distance.

[0083] In another embodiment of the present invention, when determining whether an image is repeated, the following steps are specifically performed:

[0084] By setting a threshold, when the similarity score between the image to be detected and an image in the image database is less than the threshold, they are considered to be duplicates.

[0085] Therefore, the similarity value between the feature to be tested and the feature of each image in the feature library is detected.

[0086] When the similarity value between the feature to be detected and the feature of a certain image in the feature library is less than a preset first threshold, it is determined that the image to be detected is the same as the image;

[0087] When the similarity value between the feature vector of the to-be-detected feature and a feature vector of an image in the image database is not less than the first threshold, it is determined that the to-be-detected image is different from the image.

[0088] It should be noted that, for the setting of the threshold, it is possible to set the pairwise cosine distance calculation in the image embedding library, where the minimum cosine distance is set as the threshold. In addition, the threshold can be adjusted according to the actual application scenario to balance the recall rate and the precision rate.

[0089] By building an image comparison model, there is no need for a pre-trained target detection model and corresponding annotation data, which reduces the technical threshold and cost. The algorithm is efficient and can be quickly integrated into the database of any business side, meeting the needs of plug-and-play, fast integration, and flexible deployment.

[0090] In another embodiment provided by the present invention, when the step S1 is implemented, the following steps are specifically performed:

[0091] During the training process, for each original image z i , online data enhancement processing is required.

[0092] Randomly select transformation operations from the preset transformation library to process the enhanced image, that is, continuously perform image enhancement operations during the training process and randomly change its image enhancement parameters to construct data enhancement positive examples Get the corresponding positive sample image.

[0093] It should be noted that the transformation processing includes but is not limited to cropping, rotation, brightness / contrast adjustment, color transformation, and scaling.

[0094] It should be noted that when randomly selecting a transformation operation, at least one transformation operation may be selected, that is, multiple different transformation operations may be selected to process the image.

[0095] By transforming the original image in advance, we can obtain positive sample images with the same content but different image representations. This improves the robustness of the image to slight transformations during duplicate detection, is able to cope with the challenges of various image transformations, and improves the accuracy of duplicate detection.

[0096] In another embodiment of the present invention, the transformation operation in the transformation library includes at least one of the following:

[0097] The image is cropped according to a preset ratio. When cropping, different areas of the image are randomly cropped, and the size of the cropped image is controlled to be above 50%.

[0098] The image is rotated, that is, the image is rotated according to a preset angle or a random angle and a preset rotation axis (eg, -10° to 10°).

[0099] Perform brightness / contrast adjustment on the image, perform brightness and / or contrast adjustment processing on the image according to the preset adjustment parameters, and slightly adjust the brightness and / or contrast of the image.

[0100] Perform color transformation on the image, perform saturation and / or color transformation on the image according to preset color parameters, and slightly adjust the saturation, hue, etc. of the image.

[0101] The image is compressed according to a preset scaling factor, slightly scaled, and then resized to its original size to simulate compression during image transmission and storage.

[0102] It should be noted that, in this embodiment, some transformation processing operations are listed as examples. In other embodiments, other image transformation operations may also be used to obtain corresponding positive sample images.

[0103] Through the transformation operation, the main content of the image is guaranteed to be recognizable, while introducing sufficient diversity to train a robust model.

[0104] In another embodiment provided by the present invention, when feature extraction is performed through the extraction layer of the image contrast model, the following steps are specifically included:

[0105] The network structure of the image contrast model based on contrastive learning consists of two parts: encoder and extractor.

[0106] See also Figure 3 , is another flow chart of the image contrast model construction method provided by an embodiment of the present invention.

[0107] For the original image z i Perform data enhancement processing to obtain data enhancement positive example z i + , and based on the image database, determine the negative image z i - .

[0108] An encoder is used to extract features from each original image, the corresponding negative sample image, and the corresponding positive sample image to obtain image features;

[0109] The extracted image features are subjected to dimensionality reduction extraction by the extractor to determine the encoding vector features.

[0110] Then, training is performed through contrast learning loss to update the parameters of the image contrast model and determine the image contrast model.

[0111] This application generates a slightly transformed version of each image in the acquired image database, which constitutes a positive pair with the original image. At the same time, each image is formed into a negative pair with the images in the data set except itself and the transformed version. Then, a contrastive learning network model is constructed and trained to carry out model training. The model is used to extract discriminative features from the image and perform contrastive training. There is no need for a pre-trained target detection model and corresponding annotations, which reduces the process complexity, technical threshold and cost.

[0112] In another embodiment of the present invention, when an encoder is used for feature extraction, a deep residual network ResNet is specifically selected as a deep learning model encoder for image processing to extract high-level features of the image.

[0113] ResNet is a deep convolutional neural network. Since it was proposed, it has achieved excellent performance in multiple image recognition, classification, and detection tasks. Experimental results on large image datasets such as ImageNet show that ResNet not only improves classification accuracy, but also demonstrates good generalization ability, which is also important for image duplication detection tasks in practical applications.

[0114] A deep residual network is used as an encoder to extract features from each original image, the corresponding negative sample image, and the corresponding positive sample image to obtain the corresponding image features.

[0115] Since ResNet can learn high-level feature representations of images, these features are robust to slight transformations of the image (such as rotation, cropping, brightness adjustment, etc.). This means that even if the input image has undergone these transformations, ResNet can still extract stable features, thereby supporting accurate detection of image duplication.

[0116] In another embodiment provided by the present invention, after feature extraction, a vector of a fixed length (set to 512 in this case) is required to integrate and compress the image features extracted by ResNet in order to quickly calculate the similarity.

[0117] The goal of contrastive learning is to make the same or similar images closer in the feature space, while different images are farther away in the feature space.

[0118] A fully connected layer is used as an extractor to compress and integrate the extracted image features to obtain the encoding vector features.

[0119] When encoding, the embedding extractor uses the FC layer, which can reduce the high-dimensional feature space to a low-dimensional vector space. Therefore, an FC layer needs to be added after the ResNet encoder to map the encoder output to a vector, generate a more discriminative feature encoding for contrastive learning, namely embedding, and facilitate the rapid calculation of the similarity between images.

[0120] In another embodiment of the present invention, the step S4, the process of updating the parameters of the image contrast model during the training process, specifically comprises the following steps:

[0121] The preset training configuration was used for model training. The image size was uniformly processed to 256*256, the batch size was set to 32, the optimizer was set to SGD (the momentum was set to 0.9 and the weight decay was set to 0.0005), the initial learning rate was set to 0.001, the learning cycle was set to every 20 iterations, the learning rate decay rate was set to 0.5, and the total number of training rounds was 200.

[0122] Each image in the image database is used to generate a positive sample image through data augmentation, and other images in the image database are used as negative examples. After each image is uniformly resized and normalized, it is input into the image contrast model, the encoder ResNet extracts features, and generates embeddings through the embedding extractor FC layer. The loss function between all embeddings in the batch is calculated.

[0123] The loss value is propagated back to each layer in the model through the back-propagation algorithm, and the SGD optimizer is used to perform gradient updates on the model parameters to minimize the contrastive loss.

[0124] When the model training termination condition is not reached, a loop iteration is performed, and the parameters of the image contrast model are updated using an optimizer, and the above training cycle is repeated multiple times to minimize the contrast loss;

[0125] Until the model training termination condition is reached, that is, the performance of the model on the validation set no longer improves significantly or reaches the preset training rounds. During the training process, you can regularly monitor the performance of the model on the validation set and adjust hyperparameters such as learning rate and batch size as needed.

[0126] In another embodiment of the present invention, the loss function of contrastive learning is set to information-noise contrast estimation InfoNCE.

[0127] InfoNCE is a loss function widely used in contrastive learning. It maximizes the similarity between the embeddings of each positive pair (the original image and its transformed version); and minimizes the similarity between the embeddings of each negative pair (the original image and other images in the dataset).

[0128] The loss function is

[0129] Among them, InfoNCE loss is the calculated loss value, N is the number of positive pairs consisting of the original image and the corresponding positive sample image, and z i is the encoding vector feature of the original image in the i-th positive example pair, is the encoding vector feature of the positive sample image in the i-th positive pair, is the encoding vector feature of the jth negative sample image corresponding to the original image in the ith positive pair, K is the number of negative sample images, which is set to batch-1 in this case; sim() is the similarity function used, and the similarity calculation function that can be used in this embodiment is cosine similarity.

[0130] In another embodiment provided by the present invention, the optimizer used in this case is an SGD optimizer.

[0131] When updating the model parameters, the loss value is propagated back to each layer in the model through the back-propagation algorithm, and the SGD optimizer is used to perform gradient updates on the parameters of the encoder ResNet and extractor FC layer to minimize the contrast loss.

[0132] See also Figure 4 , is a schematic diagram of the structure of an image contrast model building device provided by an embodiment of the present invention, the device comprising:

[0133] A positive example module, used to generate corresponding positive example sample images by transforming each original image in the acquired image database;

[0134] A negative example module, used for determining other images in the image database except the original image as negative example sample images;

[0135] An extraction module, used for inputting each original image, the corresponding negative sample image and the corresponding positive sample image into an extraction layer of a preset image contrast model for feature extraction;

[0136] The training module is used to perform contrast learning based on the extracted features and update the parameters of the image contrast model.

[0137] The image contrast model building device provided in this embodiment can execute all the steps and functions executed by the business server in the image contrast model building method provided in any of the above embodiments, and the specific functions of the device are not described in detail here.

[0138] See also Figure 5 , is a schematic diagram of the structure of a terminal device provided in an embodiment of the present invention. The terminal device includes: a processor, a memory, and a computer program stored in the memory and executable on the processor, such as an image contrast model building program. When the processor executes the computer program, the steps in each of the above-mentioned image contrast model building method embodiments are implemented, such as Figure 1 Alternatively, the processor implements the functions of each module in the above-mentioned device embodiments when executing the computer program.

[0139] Exemplarily, the computer program may be divided into one or more modules, and the one or more modules are stored in the memory and executed by the processor to complete the present invention. The one or more modules may be a series of computer program instruction segments that can complete specific functions, and the instruction segments are used to describe the execution process of the computer program in the image contrast model construction device. For example, the computer program may be divided into several modules, and the specific functions of each module have been described in detail in the image contrast model construction method provided in any of the above embodiments, and the specific functions of the device will not be repeated here.

[0140] The terminal device may be a computing device such as a desktop computer, a notebook, a PDA, and a cloud server. The terminal device may include, but is not limited to, a processor and a memory. Those skilled in the art may understand that the schematic diagram is only an example of a terminal device and does not constitute a limitation on an image contrast model building device. The terminal device may include more or fewer components than shown in the figure, or may combine certain components, or different components. For example, the terminal device may also include input and output devices, network access devices, buses, etc.

[0141] The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the image contrast model construction device, and uses various interfaces and lines to connect the various parts of the entire image contrast model construction device.

[0142] The memory can be used to store the computer program and / or module, and the processor realizes various functions of the image contrast model building device by running or executing the computer program and / or module stored in the memory, and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0143] Wherein, if the module integrated in the image contrast model building device is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Wherein, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal and software distribution medium, etc.

[0144] An embodiment of the present invention further provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps of implementing the method by the functional network element in the above embodiment.

[0145] The computer program product provided in this embodiment can execute all the steps and functions of the image contrast model building method provided in any of the above embodiments, and the specific functions of the product are not described in detail here.

[0146] It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention, and these improvements and modifications are also considered to be within the scope of protection of the present invention.

Claims

1. A method for constructing an image contrast model, characterized in that: The method comprises: Generate corresponding positive sample images through transformation operations on each original image in the acquired image database; Determine other images in the image database except the original image as negative sample images; Input each original image, the corresponding negative sample image and the corresponding positive sample image into the extraction layer of the preset image contrast model for feature extraction; Contrastive learning is performed based on the extracted features to update the parameters of the image contrast model.

2. The image contrast model construction method according to claim 1, characterized in that: The method further comprises: Extracting images from the image database according to the image contrast model to obtain a feature library of each image; Inputting the image to be detected into the image comparison model to obtain the feature to be detected; Calculating the similarity value between the feature to be measured and the features of each image in the feature library; It is determined whether the image to be detected is repeated with the image in the image database according to the calculated similarity.

3. The image contrast model construction method according to claim 2, characterized in that: Judging whether the image to be detected is repeated with the image in the image database according to the calculated similarity includes: When the similarity value between the feature to be detected and the feature of a certain image in the feature library is less than a preset first threshold, it is determined that the image to be detected is the same as the image; When the similarity value between the feature vector of the to-be-detected feature and a feature vector of an image in the image database is not less than the first threshold, it is determined that the to-be-detected image is different from the image.

4. The image contrast model construction method according to claim 1, characterized in that: Generating corresponding positive sample images through transformation operations on each original image in the acquired image database, further comprising: Performing image enhancement processing on each original image in the image database; A transformation operation is randomly selected from a preset transformation library to process the enhanced image and obtain the corresponding positive sample image.

5. The image contrast model construction method according to claim 4, characterized in that: The transformation operations in the transformation library include at least one of the following: Crop the image according to the preset ratio; Rotate the image according to the preset angle; Performing brightness and / or contrast adjustment processing on the image according to preset adjustment parameters; Performing saturation and / or color conversion processing on the image according to preset color parameters; Compress the image according to the preset scaling ratio.

6. The image contrast model construction method according to claim 1, characterized in that: Each original image, the corresponding negative sample image and the corresponding positive sample image are input into the extraction layer of the preset image contrast model for feature extraction, including: An encoder is used to extract features from each original image, the corresponding negative sample image, and the corresponding positive sample image to obtain image features; The extracted image features are subjected to dimensionality reduction extraction by the extractor to determine the encoding vector features.

7. The image contrast model construction method according to claim 6, characterized in that: The encoder is used to extract features from each original image, the corresponding negative sample image, and the corresponding positive sample image to obtain image features, including: A deep residual network is used as an encoder to extract features from each original image, the corresponding negative sample image, and the corresponding positive sample image to obtain the corresponding image features.

8. The image contrast model construction method according to claim 6, characterized in that: The extracted image features are extracted by the extractor to reduce the dimension and determine the encoding vector features, including: A fully connected layer is used as an extractor to compress and integrate the extracted image features to obtain the encoding vector features.

9. The image contrast model construction method according to claim 1, characterized in that: Performing contrast learning according to the extracted features and updating the parameters of the image contrast model include: Calculate the loss value between different features according to the preset loss function; The obtained loss value is transmitted back to the feature extraction layer through the back propagation algorithm, and the parameters of the image contrast model are updated by the optimizer; When the model training termination condition is not reached, a loop iteration is performed, and the optimizer is used to update the parameters of the image contrast model to minimize the contrast loss; When the model training termination condition is reached, the image contrast model is output.

10. The image contrast model construction method according to claim 9, characterized in that: The loss function is Among them, InfoNCEloss is the calculated loss value, N is the number of positive pairs consisting of the original image and the corresponding positive sample image, and z i is the encoding vector feature of the original image in the i-th positive example pair, is the encoding vector feature of the positive sample image in the i-th positive pair, is the encoding vector feature of the jth negative sample image corresponding to the original image in the i-th positive pair, K is the number of negative sample images, and sim(·,·) is the similarity function used.

11. The method for constructing an image contrast model according to claim 9, characterized in that: The obtained loss value is transmitted back to the feature extraction layer through the back propagation algorithm, and the parameters of the image contrast model are updated by the optimizer, including: Through the back-propagation algorithm, the loss value is propagated back to the feature extraction layer, and the parameters of the encoder and extractor are updated using the SGD optimizer.

12. An image contrast model construction device, characterized in that: The device comprises: A positive example module, used to generate corresponding positive example sample images by transforming each original image in the acquired image database; A negative example module, used for determining other images in the image database except the original image as negative example sample images; An extraction module, used for inputting each original image, the corresponding negative sample image and the corresponding positive sample image into an extraction layer of a preset image contrast model for feature extraction; The training module is used to perform contrast learning based on the extracted features and update the parameters of the image contrast model.

13. A terminal device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein when the processor executes the computer program, the image contrast model construction method according to any one of claims 1 to 11 is implemented.

14. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located is controlled to execute the image contrast model construction method according to any one of claims 1 to 11.

15. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method according to any one of claims 1 to 11 are implemented.