Image recognition method, device, equipment and storage medium

By training the neural network model through multi-task learning and unsupervised data self-supervised feature compatibility image embedding algorithm, the problem of poor recognition effect of traditional models on uncovered data is solved, and higher image recognition accuracy is achieved.

CN113569081BActive Publication Date: 2025-09-23TENCENT TECH (BEIJING) CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202110105220.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-01-26
Publication Date
2025-09-23
Estimated Expiration
2041-01-27

AI Technical Summary

Technical Problem

Traditional trained neural network models have poor recognition effects on uncovered data, resulting in low image recognition accuracy.

Method used

The neural network model is trained through multi-task learning, combining labeled samples and unlabeled samples, using unsupervised data self-supervised feature compatibility image embedding learning algorithm, introducing semi-supervised learning methods, and performing multi-task joint updates by mining unsupervised data to train a neural network model that covers the entire data.

Benefits of technology

The accuracy of image recognition of the trained neural network model is improved, ensuring that the model has good recognition capabilities even in unlabeled data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113569081B_ABST
    Figure CN113569081B_ABST
Patent Text Reader

Abstract

The present application discloses an image recognition method, apparatus, device and storage medium, which are applied to the field of computer application technology. The method comprises: obtaining a matching result of an image to be recognized in a target image group through a trained neural network model, wherein the target image group includes at least one image; the trained neural network model is trained according to a total loss value of the neural network model, wherein the total loss value is determined by a first loss value and a second loss value, wherein the first loss value is obtained by processing a labeled sample cluster through the neural network model, and the second loss value is obtained by processing an unlabeled sample cluster through the neural network model, wherein the labeled sample cluster includes one or more labeled images, and the unlabeled sample cluster includes one or more unlabeled images; if the matching result indicates that a target image matching the image to be recognized exists in the target image group, then the target image is output, thereby improving the accuracy of image recognition by the trained neural network model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer application technology, and in particular to image recognition methods, devices, equipment and storage media. Background Art

[0002] Computer vision (CV) technology typically includes image processing, image recognition, image semantic understanding, optical character recognition (OCR), video processing, video semantic understanding, video content / behavior recognition, three-dimensional object reconstruction, 3D technology, virtual reality, augmented reality, simultaneous localization and mapping, and other technologies. It also includes common biometric recognition technologies such as facial recognition and fingerprint recognition. Image recognition can include image retrieval and image deduplication. For example, image deduplication depends on the quality of the features used to represent the image and the image attack capabilities that these features can cover. However, traditional trained neural network models have poor recognition performance on uncovered data, resulting in low image recognition accuracy. Summary of the Invention

[0003] The embodiments of the present invention provide image recognition methods, devices, equipment and storage media, which can enable the trained neural network model to cover the entire amount of data through multi-task learning, thereby improving the accuracy of image recognition by the trained neural network model.

[0004] In one aspect, an embodiment of the present invention provides an image recognition method, the method comprising:

[0005] Obtain an image to be identified; obtain a matching result of the image to be identified in a target image group using a trained neural network model, wherein the target image group includes at least one image; the trained neural network model is trained based on a total loss value of the neural network model, wherein the total loss value is determined by a first loss value and a second loss value, wherein the first loss value is obtained by processing a labeled sample cluster using the neural network model, and the second loss value is obtained by processing an unlabeled sample cluster using the neural network model, wherein the labeled sample cluster includes one or more labeled images, and the unlabeled sample cluster includes one or more unlabeled images;

[0006] If the matching result indicates that there is a target image in the target image group that matches the image to be recognized, the target image is output.

[0007] Accordingly, an embodiment of the present invention provides an image recognition device, comprising:

[0008] An acquisition unit, configured to acquire an image to be recognized;

[0009] a processing unit, configured to obtain, through a trained neural network model, a matching result of the image to be identified in a target image group, the target image group including at least one image; the trained neural network model is trained based on a total loss value of the neural network model, the total loss value being determined by a first loss value and a second loss value, the first loss value being obtained by processing a labeled sample cluster by the neural network model, the second loss value being obtained by processing an unlabeled sample cluster by the neural network model, the labeled sample cluster including one or more labeled images, and the unlabeled sample cluster including one or more unlabeled images;

[0010] An output unit is configured to output a target image that matches the image to be identified if the matching result indicates that there is a target image in the target image group.

[0011] Accordingly, an embodiment of the present invention provides an electronic device, including:

[0012] Memory for storing computer programs;

[0013] The processor is used to run the computer program to implement the image recognition method as described in the above aspects.

[0014] Accordingly, an embodiment of the present invention provides a computer-readable storage medium, in which a computer program is stored. The computer program is executed by a processor to implement the aforementioned image recognition method.

[0015] Accordingly, an embodiment of the present invention provides a computer program product or a computer program, wherein the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium; a processor reads and runs the computer instructions from the computer-readable storage medium to execute the above-mentioned image recognition method.

[0016] In an embodiment of the present invention, the trained neural network model is obtained based on training of labeled samples and unlabeled samples, that is, a first loss value is obtained by processing a cluster of labeled samples through the neural network model, and a second loss value is obtained by processing a cluster of unlabeled samples through the neural network model. The total loss value of the neural network model is determined by the first loss value and the second loss value, and the total loss value is fed back to the neural network model to train the neural network model to obtain a trained neural network model. Multi-task learning can be used to enable the trained neural network model to have the ability to cover the entire amount of data. Based on this, the matching result of the image to be identified in the target image group is obtained through the trained neural network model. If the matching result indicates that there is a target image matching the image to be identified in the target image group, the target image is output, which can improve the accuracy of image recognition by the trained neural network model. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0018] Figure 1 A schematic diagram of a model training framework provided by an embodiment of the present invention;

[0019] Figure 2 A schematic diagram of a flow chart of an image recognition method provided by an embodiment of the present invention;

[0020] Figure 3 A schematic diagram of a process for determining difficult-to-label triples provided by an embodiment of the present invention;

[0021] Figure 4 A schematic diagram of an enhanced image provided by an embodiment of the present invention;

[0022] Figure 5 A schematic diagram of an image duplicate removal retrieval result provided by an embodiment of the present invention;

[0023] Figure 6 A schematic diagram of a flow chart of another image recognition method provided by an embodiment of the present invention;

[0024] Figure 7 A schematic structural diagram of an image recognition device provided by an embodiment of the present invention;

[0025] Figure 8 A schematic structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0026] The embodiments of the present invention are described below with reference to the accompanying drawings.

[0027] Computer vision is the study of how machines can "see." Specifically, it involves using cameras and computers to replace the human eye in identifying, tracking, and measuring objects. This involves further processing the images, transforming them into images more suitable for human observation or transmission to instrumentation. As a scientific discipline, computer vision studies related theories and technologies, aiming to build artificial intelligence systems capable of extracting information from images or multidimensional data.

[0028] With the research and advancement of artificial intelligence technology, artificial intelligence technology has been studied and applied in many fields, such as common smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, unmanned driving, autonomous driving, drones, robots, smart medical care, smart customer service, etc. It is believed that with the development of technology, artificial intelligence technology will be applied in more fields and play an increasingly important role.

[0029] The solution provided in the embodiments of the present application relates to an artificial intelligence image recognition technology, which is specifically described by the following embodiments:

[0030] The trained neural network model provided by the embodiment of the present invention can be used to implement image recognition such as image retrieval or image duplication elimination. In one embodiment, the electronic device can obtain an image to be recognized, and obtain a matching result of the image to be recognized in the target image group through the trained neural network model. If the matching result indicates that there is a target image matching the image to be recognized in the target image group, the target image is output. In one example, the image to be recognized can be a certain image, the target image group can be a designated image library or an image library to which images existing on the Internet belong, and the target image matching the image to be recognized can refer to: the same target image as the image to be recognized, that is, the image to be recognized and the target image are the same image. For example, to determine whether an image is located in a designated image library, or whether an image is located on the Internet, the designated image library can be a cloud image database or an image database created in the device by a device using the neural network model. In one example, the image to be identified can be an image, the target image group can be a specified image library, and the target image that matches the image to be identified can refer to target images associated with the image to be identified. That is, the image to be identified and the target image contain objects of the same class, the same object, or the same background, or the image to be identified can be an enhanced image of the target image after image enhancement processing. Objects of the same class refer to objects of the same category, which can be humans, animals (which can be further categorized as cats, dogs, or birds), or buildings. For example, it can determine whether an image is associated with any image in the specified image library. In another example, the image to be identified can be an image, the target image group can be specified video data, and the target image that matches the image to be identified can refer to the same target image as the image to be identified. For example, it can determine whether an image is located in the specified video data and which frame of the specified video data the image is located in. In another embodiment, the electronic device can obtain matching results for each image in the target image group using a trained neural network model. If the matching results indicate that an image containing a specified instance exists in the target image group, the electronic device outputs an image containing the specified instance. The specified instance can refer to a specific object, such as an object of a certain class or a specific object. In one example, the target image group can be a specified image library or an image library containing images on the internet. For example, images containing a specified instance are retrieved from the specified image library or the internet. Image retrieval refers to the process of finding images containing the same instance from an image library or the internet, given a query image containing a specific instance (e.g., a specific object, scene, building, etc.). Image deduplication refers to the process of finding images that are identical or similar to an image in an image library or the internet, given a query image containing the same instance.

[0031] The image recognition method provided in the embodiments of the present application can be applied to electronic devices, which may be servers, personal computers (PCs), smartphones, tablet computers, and the like. The electronic device used to train the neural network model and the device using the trained neural network model may be the same device or different devices. For example, the device using the trained neural network model may be a PC, a smartphone, a tablet computer, a vehicle-mounted device, or a wearable device. Alternatively, the trained neural network model may be used by a client running on the device, and the client corresponds to the server.

[0032] The training process of the trained neural network model provided in the embodiment of the present application is a feature-compatibility image embedding learning algorithm based on self-supervision of unsupervised data. It analyzes the distribution of all unsupervised data and collects trusted data sets for self-supervised image metric learning, thereby adding unlabeled data features to network learning so that the model supports retrieval of full data. In a specific implementation, the electronic device can obtain a labeled sample cluster and an unlabeled sample cluster, wherein the labeled sample cluster includes one or more labeled images, and the unlabeled sample cluster includes one or more unlabeled images. The labeled sample cluster is processed by the neural network model to obtain a first loss value, and the unlabeled sample cluster is processed by the neural network model to obtain a second loss value. Then, the total loss value of the above-mentioned neural network model is determined by the first loss value and the second loss value, and the total loss value is transmitted back to the above-mentioned neural network model to train the above-mentioned neural network model to obtain a trained neural network model. In other words, the embodiment of the present application can introduce unlabeled data on the basis of metric learning data, and train the neural network model by mining unsupervised data and updating the neural network model in a semi-supervised multi-task joint manner, so as to make the model more sensitive to the metric learning (metric learning) of unsupervised samples. In the case of retrieval attack samples of unsupervised data, it can also achieve a basic detection effect through pre-supervised feature learning. In other words, the embodiment of the present application introduces a multi-task branch of unsupervised learning in metric learning, improves the semantic extraction capability of feature embedding, ensures the ability of the neural network model to perceive global features, and relies on deep learning algorithms (such as embedding learning algorithms). Sample cluster representation and mining do not require additional human labeling.

[0033] The training process of the trained neural network model provided in the embodiment of the present application is a semi-supervised learning (SSL) method. SSL is a machine learning method that combines a small number of labeled samples with a large number of unlabeled samples during the training process to achieve training of the neural network model.

[0034] by Figure 1 Taking the framework diagram of model training shown as an example, the framework is a framework based on semi-supervised semantic metric learning, and the samples used in the training process include supervised data (i.e., labeled sample clusters) and unsupervised data (i.e., unlabeled sample clusters). The framework includes a supervised data metric learning branch and an unsupervised data metric learning branch. In the supervised data metric learning branch, the electronic device can extract normal labeled triplets and difficult labeled triplets from the supervised data, where the credibility of the normal labeled triplets is higher than the credibility of the difficult labeled triplets, and then use the neural network model to process the normal labeled triplets to obtain the prediction results of the normal labeled triplets, and calculate the normal loss value based on the prediction results of the normal labeled triplets; at the same time, use the neural network model to process the difficult labeled triplets to obtain the prediction results of the difficult labeled triplets, and calculate the difficult loss value based on the prediction results of the difficult labeled triplets. In the unsupervised data metric learning branch, the electronic device can mine negative samples with close distances between features in the unsupervised data, and form triplets of negative samples, positive samples, and anchor samples. The anchor samples are samples with farther distances in the unsupervised data, and the positive samples are enhanced images obtained by image enhancement processing of the anchor samples. The above triplets are processed using a neural network model to obtain prediction results, and a fourth loss value is calculated based on the prediction results. At the same time, the electronic device can obtain attack samples, which are enhanced images obtained by image enhancement processing of each unsupervised data. The unsupervised data and the attack samples form sample pairs, and the above sample pairs are processed using a neural network model to obtain prediction results, and a fifth loss value is calculated based on the prediction results. Then, the electronic device can obtain a total loss value of the neural network model based on the normal loss value, the difficult loss value, the fourth loss value, and the fifth loss value, and the total loss value is fed back to the neural network model to train the neural network model and obtain a trained neural network model.

[0035] based on Figure 1 See the framework diagram of the model training shown in Figure 2 , Figure 2 : This is a flow chart of an image recognition method provided by an embodiment of the present invention, which includes but is not limited to the following steps:

[0036] Step S201: Obtain labeled sample clusters and unlabeled sample clusters.

[0037] The labeled sample cluster includes one or more labeled images, and the unlabeled sample cluster includes one or more unlabeled images. In a specific implementation, the electronic device can train the neural network model for at least one epoch, each epoch including at least one training session. For one training session, the electronic device can obtain a batch of data from the training set corresponding to the epoch to which the training session belongs. Each batch of data can include a labeled sample cluster and an unlabeled sample cluster. The ratio between the total number of images included in the unlabeled sample cluster and the total number of images included in the labeled sample cluster is a second preset ratio. The second preset ratio is a preset value, and the user can adjust the second preset ratio through the electronic device. For example, the electronic device can set the total number of images included in a batch of data and the second preset ratio. Then, based on the second preset ratio and the total number of images included in a batch of data, the electronic device can determine the total number of images included in the labeled sample cluster and the total number of images included in the unlabeled sample cluster. Then, based on the second preset ratio and the total number of images included in the batch of data, the electronic device can obtain a labeled sample cluster from the labeled triplet cluster based on the total number of images included in the labeled sample cluster, and obtain an unlabeled sample cluster from the image cluster based on the total number of images included in the unlabeled sample cluster. The total number of images included in the obtained labeled sample cluster is the total number of images included in the labeled sample cluster determined above. The total number of images included in the obtained unlabeled sample cluster is the total number of images included in the unlabeled sample cluster determined above.

[0038] In one embodiment, the second preset ratio is the ratio of the total number of images included in the unlabeled sample cluster to the total number of images included in the labeled sample cluster. The second preset ratio is greater than 1. For example, the second preset ratio can be 10 or 20. Based on this, the number of unlabeled images used in each training process is much greater than the number of labeled images. This allows the neural network model to learn features covering the entire amount (such as duplicate elimination features for the entire amount of images) with a large number of unlabeled samples and a small number of labeled samples, thereby ensuring that the trained neural network model also has image recognition capabilities for unlabeled data.

[0039] Epoch: refers to a complete training of the neural network model using all the data in the training set, which is called "one generation of training", that is, one period of training.

[0040] Batch: refers to using a small number of samples in the training set to update the parameters of the neural network model. This small number of samples is called a "batch of data."

[0041] Iteration: refers to the process of updating the parameters of the neural network model using a batch of data, which is called "one training".

[0042] The labeled sample clusters in different Batch data are sampled from different labeled triple clusters. At the same time, the unlabeled sample clusters in different Batch data are sampled from different image clusters. The image clusters and the labeled triple clusters can be obtained from the original data. For example, the original data can be obtained based on ImageNet, where ImageNet is an open source dataset for general object recognition, and ImageNet includes several images. Exemplarily, the image cluster may include bs images, and the labeled triple cluster may include 5*bs triplets. In an embodiment of the present application, in order to ensure that difficult labeled triplets can be sampled in the labeled triple clusters, the electronic device sets the total number of images contained in the labeled triple clusters to be much larger than the total number of images contained in the image clusters.

[0043] All images included in the image cluster are images that have not been labeled by the user. All triplets included in the labeled triplet cluster are labeled triplets. For example, the user can label some images in the original data to obtain the full image, and then the electronic device can perform metric learning labeling on the full image to obtain labeled triplets and generate a labeled triplet cluster containing the above labeled triplets. Metric learning labeling: refers to selecting three images that meet the rules from the full image to form a triplet (anchor, positive, negative), where the anchor and positive are similar category images or the same category images, and the anchor and negative are dissimilar category images or different category images.

[0044] In one embodiment, the labeled sample cluster may include multiple normal labeled triplets and multiple difficult labeled triplets, each labeled triplet includes a first target image, a similar image, and a dissimilar image. The first target image is any image labeled by the user in the labeled triplet cluster, the similar image is the image labeled by the user in the labeled triplet cluster with the greatest similarity to the first target image, and the dissimilar image is the image labeled by the user in the labeled triplet cluster with the least similarity to the first target image.

[0045] In one embodiment, the electronic device can process each labeled triple in the labeled triple cluster separately through a neural network model to obtain a third eigenvalue, and process each third eigenvalue through a first preset loss function to obtain a third loss value, and select multiple normal labeled triples and multiple difficult labeled triples in the labeled triple cluster, wherein the loss value of any normal labeled triple is less than the loss value of any difficult labeled triple. In other words, the loss value of the normal labeled triple is less than the loss value of the difficult labeled triple, indicating that the credibility of the normal labeled triple is higher than the credibility of the difficult labeled triple. The ratio of the number of multiple normal labeled triples to the number of multiple difficult labeled triples is a first preset ratio.

[0046] In one embodiment, the electronic device selects multiple normal labeled triplets and multiple difficult labeled triplets in a labeled triple cluster as follows: after the electronic device processes each third eigenvalue through a first preset loss function to obtain a third loss value, it can average all third loss values ​​to obtain an average loss value, and then select multiple normal labeled triplets from the labeled triplets whose third loss value is less than or equal to the average loss value, and select multiple difficult labeled triplets from the labeled triplets whose third loss value is greater than the average loss value, wherein the third loss value of the difficult labeled triple is greater than the third loss value of other labeled triplets, and the other labeled triplets are the labeled triplets other than the difficult labeled triples in the labeled triplets whose third loss value is greater than the average loss value.

[0047] In another embodiment, the electronic device may select multiple normal labeled triplets and multiple difficult labeled triplets from a labeled triple cluster in the manner that, after the electronic device processes each third eigenvalue through a first preset loss function to obtain a third loss value, it may sort all labeled triplets in the labeled triple cluster in descending order of loss value, select multiple normal labeled triplets from the sorted labeled triples in sequence from left to right, and select multiple difficult labeled triplets from the sorted labeled triples in sequence from right to left.

[0048] In a specific implementation, after determining the total number of labeled triplets contained in the labeled sample cluster, the electronic device can determine the total number of normal labeled triplets and the total number of difficult labeled triplets based on the total number of labeled triplets contained in the labeled sample cluster and the first preset ratio. Figure 3Taking the flowchart of determining difficult labeled triples as an example, in S301, the electronic device can perform metric learning to obtain a labeled triple cluster. In S302, the electronic device can use a neural network model to obtain the prediction results of the labeled triples in the labeled triple cluster. Specifically, the electronic device can process each labeled triple in the labeled triple cluster using the neural network model to obtain a third eigenvalue. In S303, the electronic device can calculate the loss value of each labeled triple based on the prediction results of each labeled triple. For example, the electronic device can process each third eigenvalue using a first preset loss function to obtain a third loss value. In S304, if the loss value is extremely large, the sample is taken as a difficult labeled triple. Specifically, the electronic device can average all third loss values ​​to obtain an average loss value, and then select normal labeled triples from the labeled triples whose third loss value is less than or equal to the average loss value, and the total number of the selected normal labeled triples is the total number of the normal labeled triples determined above. And select difficult labeled triples from the labeled triples whose third loss value is greater than the average loss value, and the total number of selected difficult labeled triples is the total number of difficult labeled triples determined above. For example, assuming that the labeled triple cluster includes 5*bs triplets, and the first preset ratio is 4:1, then the electronic device can select 4*bs normal labeled triples from the labeled triples whose third loss value is less than or equal to the average loss value, and select bs difficult labeled triples from the labeled triples whose third loss value is greater than the average loss value. S305, the electronic device can calculate the loss value of the difficult labeled triples, that is, the difficult loss value.

[0049] The embodiment of the present application introduces difficult labeled triplets, and obtains normal loss values ​​through normal labeled triplets and difficult loss values ​​through difficult labeled triplets, respectively. This can avoid confusing two different images during the unsupervised learning process, for example, avoiding identifying two different images as similar images or the same image through unsupervised learning.

[0050] Among them, the electronic device inputs the labeled triples in the labeled triple cluster into the neural network model, and the output of the pool_cr layer of the neural network model is the third eigenvalue, such as (Xa, Xp, Xn). The third loss value is the loss value obtained by processing the third eigenvalue through the first preset loss function. The output of the pool_cr layer can be an image retrieval result or an image deduplication result, depending on the business requirements implemented by the neural network model. For example, if the business requirement is image retrieval, the output of the pool_cr layer is the image retrieval result; if the business requirement is image deduplication, the output of the pool_cr layer is the image deduplication result.

[0051] Exemplarily, the calculation formula of the first preset loss function can be as follows:

[0052] Ltri =max(||X a -X p ||-||X a -X n ||+α,0) (1)

[0053] Among them, L tri represents the loss value obtained by processing the first preset loss function, Xa represents the feature value obtained by the neural network model processing the first target image in the labeled triplet, Xp represents the feature value obtained by the neural network model processing the similar image in the labeled triplet, Xn represents the feature value obtained by the neural network model processing the dissimilar image in the labeled triplet, α represents the distance between the two images, for example, α can be set to 0.2, then the purpose of the first preset loss function is to make the difference between the distance between the first target image and the dissimilar image and the distance between the first target image and the similar image greater than 0.2.

[0054] In one embodiment, the unlabeled sample cluster may include multiple sample pairs, each sample pair includes a second target image and an enhanced image, the second target image is any image in the image cluster, and the enhanced image is an image obtained by performing image enhancement processing on the second target image. For example, the electronic device may perform one or more combinations of the following processing methods on the second target image: adding Gaussian noise, salt and pepper noise, cropping, rotating, adding watermarks, hue conversion, flipping up and down, flipping left and right, adding black frames, etc. The total number of sample pairs may be the total number of images contained in the image cluster. Exemplarily, the enhanced image may be as follows: Figure 4 shown.

[0055] In one embodiment, the unlabeled sample cluster may include multiple sample pairs and multiple triplets, each triplet includes an anchor sample, a positive sample, and a negative sample, wherein the negative sample is an image in the image cluster whose similarity is within a preset ratio range, the positive sample is an image obtained by image enhancement processing on an image in the image cluster whose similarity is less than the minimum value of the preset ratio range, and the anchor sample is an image in the image cluster whose similarity is less than the minimum value of the preset ratio range.

[0056] For example, the minimum value of the preset ratio range may be an adaptive threshold for a training session, and the maximum value of the preset ratio range may be a set upper limit, such as 90%. If the similarity exceeds 90%, it indicates that the two images are the same image.

[0057] The electronic device can perform pairwise similarity calculations on all images in the image cluster. Specifically, the electronic device calculates similarity between every two images in the image cluster, obtains images whose similarity is greater than or equal to the minimum value within a preset ratio range, then filters out images whose similarity is greater than the maximum value within the preset ratio range, and uses the filtered images as negative samples. The electronic device can also obtain images whose similarity is less than the minimum value within the preset ratio range, and use the obtained images as anchor samples. The obtained images are then enhanced, and the resulting images are used as positive samples.

[0058] Step S202: Processing the labeled sample cluster through a neural network model to obtain a first eigenvalue, and processing the first eigenvalue through a first preset loss function to obtain a first loss value.

[0059] In a specific implementation, after the electronic device obtains the labeled sample cluster, it can process each labeled triple contained in the labeled sample cluster through a neural network model to obtain a first eigenvalue, and process each first eigenvalue through a first preset loss function to obtain a first loss value.

[0060] In one embodiment, if the labeled sample cluster includes multiple normal labeled triples and multiple difficult labeled triples, then the first loss value may include a normal loss value and a difficult loss value. On this basis, the electronic device may process each normal labeled triple through a neural network model to obtain a normal feature value, and process each normal feature value through a first preset loss function to obtain a normal loss value. The electronic device may also process each difficult labeled triple through a neural network model to obtain a difficult feature value, and process each difficult feature value through a first preset loss function to obtain a difficult loss value. The first preset loss function may be as shown in formula (1).

[0061] Step S203: Processing the unlabeled sample cluster through a neural network model to obtain a second eigenvalue, and processing the second eigenvalue through a second preset loss function to obtain a second loss value.

[0062] In a specific implementation, after the electronic device obtains the unlabeled sample cluster, it can process each unlabeled sample contained in the unlabeled sample cluster through a neural network model to obtain a second eigenvalue, and process each second eigenvalue through a second preset loss function to obtain a second loss value.

[0063] In one embodiment, if the unlabeled sample cluster includes sample pairs, the second loss value may include sampled feature values ​​and enhanced feature values. Based on this, the electronic device may process each second target image using a neural network model to obtain sampled feature values, process each enhanced image using the neural network model to obtain enhanced feature values, and process each sampled feature value and each enhanced feature value using a second preset loss function to obtain the second loss value.

[0064] The electronic device inputs the second target image in the sample pair into the neural network model, and the output of the Fc_cr layer of the neural network model is the sampled feature value. The electronic device inputs the enhanced image in the sample pair into the neural network model, and the output of the Fc_cr layer of the neural network model is the enhanced feature value. The second loss value is the loss value obtained by processing the sampled feature value or the enhanced feature value using the second preset loss function. The output of the Fc_cr layer can be an image recognition result. Image recognition is category recognition, that is, identifying the category of the object in the image.

[0065] In one embodiment, the neural network model may include at least five convolutional layers. The first to fifth convolutional layers may use parameters of ResNet101 pre-trained on the ImageNet dataset. Newly added convolutional layers, such as the Fc layer, may be initialized using a Gaussian distribution with a variance of 0.01 and a mean of 0. After the neural network model is initialized, steps S201 to S205 may be performed.

[0066] In another embodiment, the embodiments of the present application include but are not limited to using the above-mentioned network structure and pre-trained model weights, for example, parameters pre-trained on the open-image dataset can be used.

[0067] Exemplarily, the calculation formula of the second preset loss function can be as follows:

[0068]

[0069] Among them, D KL(pq) represents the loss value obtained by processing the second preset loss function, p(x i ) represents the sampling eigenvalue, q(x i ) represents the enhanced feature value, and N represents the number of sample pairs.

[0070] In this embodiment, the unlabeled sample cluster may only include sample pairs. If the labeled sample cluster is not evenly sampled in the global data distribution, it will be difficult to distinguish the features of each unsupervised data. Therefore, when the unlabeled sample cluster only includes sample pairs, the labeled triplets in the labeled sample cluster are obtained by even sampling.

[0071] In one embodiment, the unlabeled sample cluster may include multiple sample pairs and multiple triplets, each triplet including an anchor sample, a positive sample, and a negative sample. The electronic device may process each triplet using a neural network model to obtain a fourth eigenvalue, and process each fourth eigenvalue using a first preset loss function to obtain a second loss value. The first preset loss function may be as shown in formula (1).

[0072] That is, when the unlabeled sample cluster includes multiple sample pairs and multiple triplets, the number of second loss values ​​is two, including the second loss values ​​obtained by multiple sample pairs and the second loss values ​​obtained by multiple triplets.

[0073] The embodiments of the present application can learn full-scale features by maximizing the use of unlabeled sample clusters. Furthermore, by performing attack-based learning on unsupervised data during learning, the trained neural network model has a certain recall effect even in unseen attacks, and has a good ability to retrieve attack graphs of unsupervised samples. Furthermore, the embodiments of the present application screen out valid positive and negative samples for unsupervised data metric learning tasks from the full data, ensuring that the unsupervised data correctly guides the neural network model.

[0074] Step S204: Obtain a total loss value of the neural network model according to the first loss value and the second loss value.

[0075] In a specific implementation, the electronic device may perform an arithmetic operation on the first loss value and the second loss value to obtain a total loss value of the neural network model. The electronic device may also process the first loss value and the second loss value using a preset function to obtain the total loss value of the neural network model, where the preset function is a formula with the first loss value and the second loss value as independent variables.

[0076] In one embodiment, if the labeled sample cluster includes multiple normal labeled triplets and multiple difficult labeled triplets, and the unlabeled sample cluster includes multiple sample pairs, then the first loss value includes a normal loss value and a difficult loss value, and the second loss value is a loss value obtained through multiple sample pairs. The electronic device can perform weighted summation of the normal loss value, the difficult loss value, and the second loss value to obtain the total loss value of the neural network model.

[0077] In one embodiment, if the labeled sample cluster includes multiple normal labeled triplets and multiple difficult labeled triplets, and the unlabeled sample cluster includes multiple sample pairs and multiple triplets, then the first loss value includes a normal loss value and a difficult loss value, and the number of second loss values ​​is two, including loss values ​​obtained through multiple sample pairs and loss values ​​obtained through multiple triplets. The electronic device can perform weighted summation on the normal loss value, the difficult loss value and the two second loss values ​​to obtain the total loss value of the neural network model.

[0078] For example, the calculation formula of the total loss value of the neural network model can be as follows:

[0079] L total =W1L supervised-triplet +W2L supervised-hard-triplet +W3L kl +W4L triplet (3)

[0080] Among them, L total Represents the total loss value of the neural network model, L supervised-triplet Represents the normal loss value, W1 represents the weight of the normal loss value, L supervised-hard-triplet represents the difficulty loss value, W2 represents the weight of the difficulty loss value, L kl represents the second loss value obtained by processing multiple sample pairs, W3 represents the weight of the second loss value obtained by processing multiple sample pairs, L triplet W4 represents the weight of the second loss value obtained by processing multiple triplets.

[0081] The arithmetic operation method in the embodiment of the present application includes but is not limited to a weighted sum algorithm, for example, it can be a weighted average algorithm or an arithmetic average method.

[0082] Step S205: The total loss value is fed back to the neural network model to train the neural network model and obtain a trained neural network model.

[0083] In one embodiment, the electronic device may transmit the total loss value back to the neural network model, and update the convolution template parameters and bias parameters of the neural network model through a preset optimizer algorithm to train the neural network model once, and then iteratively execute to obtain the labeled sample clusters and the unlabeled sample clusters until the neural network model is trained for a preset number of epochs to obtain a trained neural network model, wherein each epoch includes at least one training. The preset number may be set by the electronic device, and the user may also adjust the preset number.

[0084] Exemplarily, the preset optimizer algorithm may include stochastic gradient descent (SGD) or mini-batch gradient descent (MBGD), etc., and is not limited by the embodiments of the present application. Taking SGD as an example, the electronic device can set all parameters of the neural network model to a state requiring learning, and in each iteration process, backpropagate the total loss value to the neural network model, calculate the gradient, and update the parameters of the neural network model based on the gradient.

[0085] by Figure 5 Taking the image duplicate retrieval result diagram shown in the figure as an example, if the business requirement of the neural network model is image duplicate retrieval, then after inputting the specified image into the trained neural network model, the output of the trained neural network model can be as follows Figure 5 As shown, Figure 5 The first image in the image may be a specified image, and subsequent images may be retrieved images that match the specified image, wherein the subsequent images may be arranged in descending order of similarity with the specified image.

[0086] In an embodiment of the present invention, multi-task learning can be used to enable the trained neural network model to have the ability to cover the entire amount of data, thereby avoiding poor image recognition effects due to limited data annotation, thereby improving the accuracy of image recognition by the trained neural network model.

[0087] based on Figure 2 For a flow chart of the image recognition method shown in Figure 6 , Figure 6 FIG. 5 is a flow chart of another image recognition method provided by an embodiment of the present invention, which includes but is not limited to the following steps:

[0088] Step S601: Acquire an image to be recognized.

[0089] The image to be identified can be obtained by the electronic device from the local storage of the electronic device or the cloud, or downloaded from the Internet by the electronic device in response to the user's search operation, or received by the electronic device from other devices, and is not limited by the embodiments of the present application.

[0090] by Figure 5 Take the schematic diagram of the image duplicate retrieval result shown in FIG as an example. Figure 5 The first image in can be the image to be recognized.

[0091] Step S602: Obtain matching results of the image to be identified in the target image group through the trained neural network model.

[0092] The electronic device can input the image to be identified into the trained neural network model, and obtain the matching result of the image to be identified in the target image group through the trained neural network model. The matching result is used to indicate whether there is a target image in the target image group that matches the image to be identified.

[0093] The target image group may include at least one image. For example, the target image group may be a designated image library or an image library to which images existing on the Internet belong, and so on.

[0094] Step S603: If the matching result indicates that there is a target image in the target image group that matches the image to be identified, the target image is output.

[0095] If the matching result indicates that there is a target image in the target image group that matches the image to be identified, then the target image can be output through the trained neural network model, or the image identifier of the target image can be output, which can be used to indicate the position of the target image in the target image group.

[0096] by Figure 5 For example, Figure 5 The first image in the image can be the image to be recognized, and the subsequent images can be target images that match the image to be recognized and output by the trained neural network model, where the target images can be arranged in descending order of similarity with the image to be recognized.

[0097] For example, assuming that the target image group is specified video data, the output of the trained neural network model can be the target image, or the image identifier of the target image, and the image identifier can be used to indicate which frame of the specified video data the target image is located in.

[0098] Step S604: If the matching result indicates that there is no target image matching the image to be identified in the target image group, a prompt message is output, where the prompt message is used to indicate that there is no target image matching the image to be identified in the target image group.

[0099] If the matching result indicates that the target image group does not contain a matching target image, the electronic device may not output any image through the trained neural network model. Alternatively, the electronic device may output a prompt message through the trained neural network model, indicating that the target image group does not contain a matching target image.

[0100] In an embodiment of the present invention, a matching result of an image to be identified in a target image group is obtained through a trained neural network model. If the matching result indicates that a target image matching the image to be identified exists in the target image group, the target image is output; if the matching result indicates that a target image matching the image to be identified does not exist in the target image group, a prompt message is output, thereby improving the accuracy of image recognition.

[0101] See also Figure 7 , is an image recognition device according to an embodiment of the present invention, which can be provided in the electronic device mentioned above. The image recognition device 70 includes the following units.

[0102] An acquisition unit 701 is used to acquire an image to be recognized;

[0103] A processing unit 702 is configured to obtain a matching result of the image to be identified in a target image group using a trained neural network model, where the target image group includes at least one image; the trained neural network model is trained based on a total loss value of the neural network model, where the total loss value is determined by a first loss value and a second loss value, where the first loss value is obtained by processing a labeled sample cluster using the neural network model, and the second loss value is obtained by processing an unlabeled sample cluster using the neural network model, where the labeled sample cluster includes one or more labeled images, and the unlabeled sample cluster includes one or more unlabeled images;

[0104] The output unit 703 is configured to output the target image if the matching result indicates that there is a target image in the target image group that matches the image to be identified.

[0105] In one embodiment, the processing unit 702 is further used to process the labeled sample cluster through the neural network model to obtain a first eigenvalue, and process the first eigenvalue through a first preset loss function to obtain a first loss value, before obtaining the matching result of the image to be identified in the target image group through the trained neural network model; process the unlabeled sample cluster through the neural network model to obtain a second eigenvalue, and process the second eigenvalue through a second preset loss function to obtain a second loss value; obtain a total loss value of the neural network model based on the first loss value and the second loss value; and transmit the total loss value back to the neural network model to train the neural network model to obtain the trained neural network model.

[0106] In one embodiment, the labeled sample cluster includes multiple normal labeled triplets and multiple difficult labeled triplets, each of the labeled triplets includes a first target image, a similar image, and a dissimilar image, the first target image is any image labeled by a user in the labeled triplet cluster, the similar image is an image labeled by a user in the labeled triplet cluster with the greatest similarity to the first target image, and the dissimilar image is an image labeled by a user in the labeled triplet cluster with the least similarity to the first target image; the first loss value includes a normal loss value and a difficult loss value;

[0107] The processing unit 702 processes the labeled sample cluster using a neural network model to obtain a first eigenvalue, and processes the first eigenvalue using a first preset loss function to obtain a first loss value, including:

[0108] Processing each of the normal labeled triples using the neural network model to obtain a normal feature value, and processing each of the normal feature values ​​using the first preset loss function to obtain a normal loss value;

[0109] Each of the difficult labeled triples is processed by the neural network model to obtain a difficult feature value, and each of the difficult feature values ​​is processed by the first preset loss function to obtain a difficult loss value.

[0110] In one embodiment, the processing unit 702 is further used to process each labeled triple in the labeled triple cluster through the neural network model to obtain a third eigenvalue, and process each third eigenvalue through the first preset loss function to obtain a third loss value, before processing the labeled sample cluster through the neural network model to obtain a first eigenvalue and processing the first eigenvalue through the first preset loss function to obtain a first loss value; select the multiple normal labeled triplets and the multiple difficult labeled triplets in the labeled triple cluster, wherein the loss value of any normal labeled triple is less than the loss value of any difficult labeled triple, and the ratio of the number of the multiple normal labeled triplets to the number of the multiple difficult labeled triplets is a first preset ratio.

[0111] In one embodiment, the unlabeled sample cluster includes a plurality of first sample pairs, each of the first sample pairs includes a second target image and an enhanced image, the second target image is any image in the image cluster, and the enhanced image is an image obtained by performing image enhancement processing on the second target image;

[0112] The processing unit 702 processes the unlabeled sample cluster using the neural network model to obtain a second eigenvalue, and processes the second eigenvalue using a second preset loss function to obtain a second loss value, including:

[0113] Processing each of the second target images through the neural network model to obtain sampling feature values;

[0114] Processing each of the enhanced images through the neural network model to obtain enhanced feature values;

[0115] Each of the sampled eigenvalues ​​and each of the enhanced eigenvalues ​​is processed using the second preset loss function to obtain the second loss value.

[0116] In one embodiment, the unlabeled sample cluster further includes a plurality of triplets, each of which includes an anchor sample, a positive sample, and a negative sample. The negative sample is an image in the image cluster whose similarity is within a preset ratio range. The anchor sample is an image in the image cluster whose similarity is less than a minimum value of the preset ratio range. The positive sample is an image obtained by performing image enhancement processing on the anchor sample.

[0117] The processing unit 702 processes the unlabeled sample cluster using the neural network model to obtain a second eigenvalue, and processes the second eigenvalue using a second preset loss function to obtain a second loss value, further comprising:

[0118] Processing each of the triples through the neural network model to obtain a fourth eigenvalue;

[0119] Each of the four eigenvalues ​​is processed using the first preset loss function to obtain the second loss value.

[0120] In one embodiment, the ratio of the total number of images included in the unlabeled sample cluster to the total number of images included in the labeled sample cluster is a second preset ratio, and the second preset ratio is greater than 1.

[0121] In one embodiment, the processing unit 702 transmits the total loss value back to the neural network model to train the neural network model to obtain a trained neural network model, including:

[0122] The total loss value is fed back to the neural network model, and the convolution template parameters and bias parameters of the neural network model are updated by a preset optimizer algorithm to train the neural network model once;

[0123] The steps of obtaining labeled sample clusters and unlabeled sample clusters are iteratively performed until the neural network model is trained for a preset number of epochs to obtain the trained neural network model, wherein each epoch includes at least one training session.

[0124] The specific implementation of the acquisition unit 701, the processing unit 702 and the output unit 703 included in the device 70 in the embodiment of the present invention can refer to the description of the relevant content in the aforementioned method embodiment, which is not repeated here.

[0125] In an embodiment of the present invention, the processing unit 702 obtains the matching result of the image to be identified in the target image group through the trained neural network model. If the matching result indicates that there is a target image matching the image to be identified in the target image group, the output unit 703 outputs the target image, wherein the trained neural network model is trained according to the total loss value of the neural network model, and the total loss value is determined by the first loss value and the second loss value. The first loss value is obtained by processing the labeled sample cluster through the neural network model, and the second loss value is obtained by processing the unlabeled sample cluster through the neural network model. Multi-task learning can be used to enable the trained neural network model to have the ability to cover the entire amount of data, thereby improving the accuracy of the trained neural network model in image recognition.

[0126] See also Figure 8 , is a structural diagram of an electronic device according to an embodiment of the present invention. The electronic device according to the embodiment of the present invention may refer to a server, a smart phone, a tablet computer or a PC. The electronic device 80 includes a memory 801, a processor 802 and a network interface 803, and may also include a user interface 804 and a communication interface 805. At the same time, it may also include a power supply, various required shell structures, etc.

[0127] The network interface 803 can ensure that the electronic device 80 is connected to the Internet and various servers through computer networks and mobile communication networks.

[0128] Processor 802 may be a central processing unit (CPU). Processor 802 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or the like. The PLD may be a field-programmable gate array (FPGA), a generic array logic (GAL), or the like.

[0129] The memory 801 may include a volatile memory, such as a random-access memory (RAM); the memory 801 may also include a non-volatile memory, such as a flash memory, a solid-state drive (SSD), etc.; the memory 801 may also include a combination of the above types of memory.

[0130] The memory 801 is used to store computer programs, and the processor 802 is used to execute computer instructions, thereby realizing the corresponding method flow or corresponding functions in the aforementioned embodiments.

[0131] In one embodiment, the network interface 803 calls the computer program stored in the memory 801 to obtain the image to be recognized;

[0132] The processor 802 calls the computer program stored in the memory 801, and is configured to obtain a matching result of the image to be identified in a target image group using a trained neural network model, where the target image group includes at least one image; the trained neural network model is trained based on a total loss value of the neural network model, where the total loss value is determined by a first loss value and a second loss value, where the first loss value is obtained by processing a labeled sample cluster using the neural network model, and the second loss value is obtained by processing an unlabeled sample cluster using the neural network model, where the labeled sample cluster includes one or more labeled images, and the unlabeled sample cluster includes one or more unlabeled images;

[0133] The network interface 803 calls the computer program stored in the memory 801 to output the target image if the matching result indicates that there is a target image in the target image group that matches the image to be identified.

[0134] In one embodiment, before obtaining a matching result of the image to be identified in the target image group through the trained neural network model, the processor 802 is further configured to perform the following operations:

[0135] Processing the labeled sample cluster using the neural network model to obtain a first eigenvalue, and processing the first eigenvalue using a first preset loss function to obtain a first loss value;

[0136] Processing the unlabeled sample cluster using the neural network model to obtain a second eigenvalue, and processing the second eigenvalue using a second preset loss function to obtain a second loss value;

[0137] Obtaining a total loss value of the neural network model according to the first loss value and the second loss value;

[0138] The total loss value is fed back to the neural network model to train the neural network model to obtain the trained neural network model.

[0139] In one embodiment, the labeled sample cluster includes multiple normal labeled triplets and multiple difficult labeled triplets, each of the labeled triplets includes a first target image, a similar image, and a dissimilar image, the first target image is any image labeled by a user in the labeled triplet cluster, the similar image is an image labeled by a user in the labeled triplet cluster with the greatest similarity to the first target image, and the dissimilar image is an image labeled by a user in the labeled triplet cluster with the least similarity to the first target image; the first loss value includes a normal loss value and a difficult loss value;

[0140] The processor 802 processes the labeled sample cluster using a neural network model to obtain a first eigenvalue, and processes the first eigenvalue using a first preset loss function to obtain a first loss value, including:

[0141] Processing each of the normal labeled triples using the neural network model to obtain a normal feature value, and processing each of the normal feature values ​​using the first preset loss function to obtain a normal loss value;

[0142] Each of the difficult labeled triples is processed by the neural network model to obtain a difficult feature value, and each of the difficult feature values ​​is processed by the first preset loss function to obtain a difficult loss value.

[0143] In one embodiment, the processor 802 is further used to process each labeled triple in the labeled triple cluster through the neural network model to obtain a third eigenvalue, and process each third eigenvalue through the first preset loss function to obtain a third loss value, before processing the labeled sample cluster through the neural network model to obtain a first eigenvalue and processing the first eigenvalue through the first preset loss function to obtain a first loss value; and select the multiple normal labeled triples and the multiple difficult labeled triples in the labeled triple cluster, wherein the loss value of any normal labeled triple is less than the loss value of any difficult labeled triple, and the ratio of the number of the multiple normal labeled triples to the number of the multiple difficult labeled triples is a first preset ratio.

[0144] In one embodiment, the unlabeled sample cluster includes a plurality of first sample pairs, each of the first sample pairs includes a second target image and an enhanced image, the second target image is any image in the image cluster, and the enhanced image is an image obtained by performing image enhancement processing on the second target image;

[0145] The processor 802 processes the unlabeled sample cluster using the neural network model to obtain a second eigenvalue, and processes the second eigenvalue using a second preset loss function to obtain a second loss value, including:

[0146] Processing each of the second target images through the neural network model to obtain sampling feature values;

[0147] Processing each of the enhanced images through the neural network model to obtain enhanced feature values;

[0148] Each of the sampled eigenvalues ​​and each of the enhanced eigenvalues ​​is processed using the second preset loss function to obtain the second loss value.

[0149] In one embodiment, the unlabeled sample cluster further includes a plurality of triplets, each of which includes an anchor sample, a positive sample, and a negative sample. The negative sample is an image in the image cluster whose similarity is within a preset ratio range. The anchor sample is an image in the image cluster whose similarity is less than a minimum value of the preset ratio range. The positive sample is an image obtained by performing image enhancement processing on the anchor sample.

[0150] The processor 802 processes the unlabeled sample cluster using the neural network model to obtain a second eigenvalue, and processes the second eigenvalue using a second preset loss function to obtain a second loss value, further comprising:

[0151] Processing each of the triples through the neural network model to obtain a fourth eigenvalue;

[0152] Each of the four eigenvalues ​​is processed using the first preset loss function to obtain the second loss value.

[0153] In one embodiment, the ratio of the total number of images included in the unlabeled sample cluster to the total number of images included in the labeled sample cluster is a second preset ratio, and the second preset ratio is greater than 1.

[0154] In one embodiment, the processor 802 transmits the total loss value back to the neural network model to train the neural network model to obtain a trained neural network model, including:

[0155] The total loss value is fed back to the neural network model, and the convolution template parameters and bias parameters of the neural network model are updated by a preset optimizer algorithm to train the neural network model once;

[0156] The steps of obtaining labeled sample clusters and unlabeled sample clusters are iteratively performed until the neural network model is trained for a preset number of epochs to obtain the trained neural network model, wherein each epoch includes at least one training session.

[0157] The specific implementation of the processor 802 and the network interface 803 in the embodiment of the present invention can refer to the description of the relevant content in the aforementioned method embodiment, which will not be repeated here.

[0158] In an embodiment of the present invention, the processor 802 obtains the matching result of the image to be identified in the target image group through the trained neural network model. If the matching result indicates that there is a target image matching the image to be identified in the target image group, the network interface 803 outputs the target image, wherein the trained neural network model is trained according to the total loss value of the neural network model, and the total loss value is determined by the first loss value and the second loss value. The first loss value is obtained by processing the labeled sample cluster through the neural network model, and the second loss value is obtained by processing the unlabeled sample cluster through the neural network model. Multi-task learning can be used to enable the trained neural network model to have the ability to cover the entire amount of data, thereby improving the accuracy of the trained neural network model in image recognition.

[0159] The present application also provides a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the above-described image recognition method.

[0160] The steps in the method of the embodiment of the present application can be adjusted in order, combined and deleted according to actual needs.

[0161] The units in the device of the embodiment of the present application can be merged, divided and deleted according to actual needs.

[0162] A person skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium, which can include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0163] The above disclosure is only part of the embodiments of the present invention, which certainly cannot be used to limit the scope of the rights of the present invention. Ordinary technicians in this field can understand that implementing all or part of the processes of the above embodiments and making equivalent changes in accordance with the claims of the present invention still fall within the scope of the invention.

Claims

1. An image recognition method, characterized in that: The method comprises: Acquire an image to be identified; obtain a matching result of the image to be identified in a target image group through a trained neural network model, wherein the target image group includes at least one image; the trained neural network model is trained according to a total loss value of the neural network model, wherein the total loss value is determined by a first loss value and a second loss value, wherein the first loss value is obtained by processing a labeled sample cluster by the neural network model, and the second loss value is obtained by processing an unlabeled sample cluster by the neural network model, wherein the labeled sample cluster includes one or more labeled images, and the unlabeled sample cluster includes one or more unlabeled images; wherein the unlabeled sample cluster includes a plurality of first sample pairs, each of the first sample pairs includes a second target image and an enhanced image, wherein the second target image is any image in the image cluster, and the enhanced image is an image enhancement process performed on the second target image. the image obtained after the first loss; the second loss value is obtained by processing each sampling eigenvalue and each enhanced eigenvalue through a second preset loss function, the each sampling eigenvalue is obtained by processing each second target image through the neural network model, and the each enhanced eigenvalue is obtained by processing each enhanced image through the neural network model; the labeled sample cluster includes a plurality of normal labeled triplets and a plurality of difficult labeled triplets, and the first loss value includes a normal loss value and a difficult loss value; the normal loss value is obtained by processing each normal labeled triplet through the neural network model to obtain a normal eigenvalue, and processing each normal eigenvalue through the first preset loss function; the difficult loss value is obtained by processing each difficult labeled triplet through the neural network model to obtain a difficult eigenvalue, and processing each difficult eigenvalue through the first preset loss function; If the matching result indicates that there is a target image in the target image group that matches the image to be recognized, the target image is output.

2. The method according to claim 1, wherein Before obtaining the matching result of the image to be identified in the target image group through the trained neural network model, the method further includes: Processing the labeled sample cluster using the neural network model to obtain a first eigenvalue, and processing the first eigenvalue using a first preset loss function to obtain a first loss value; Processing the unlabeled sample cluster using the neural network model to obtain a second eigenvalue, and processing the second eigenvalue using a second preset loss function to obtain a second loss value; Obtaining a total loss value of the neural network model according to the first loss value and the second loss value; The total loss value is fed back to the neural network model to train the neural network model to obtain the trained neural network model.

3. The method according to claim 2, wherein Each labeled triplet includes a first target image, a similar image, and a dissimilar image. The first target image is any image labeled by a user in the labeled triplet cluster. The similar image is an image labeled by a user in the labeled triplet cluster with the greatest similarity to the first target image. The dissimilar image is an image labeled by a user in the labeled triplet cluster with the least similarity to the first target image. The credibility of the normal labeled triplet is higher than the credibility of the difficult labeled triplet.

4. The method according to claim 3, wherein Before the process of processing the labeled sample cluster by the neural network model to obtain the first eigenvalue and processing the first eigenvalue by the first preset loss function to obtain the first loss value, the method further includes: Processing each labeled triple in the labeled triple cluster using the neural network model to obtain a third eigenvalue, and processing each third eigenvalue using the first preset loss function to obtain a third loss value; The multiple normal labeled triples and the multiple difficult labeled triples are selected from the labeled triple cluster, wherein the loss value of any normal labeled triple is smaller than the loss value of any difficult labeled triple, and the ratio of the number of the multiple normal labeled triples to the number of the multiple difficult labeled triples is a first preset ratio.

5. The method according to claim 1, wherein The unlabeled sample cluster further includes a plurality of triplets, each of the triplets including an anchor sample, a positive sample, and a negative sample, wherein the negative sample is an image in the image cluster whose similarity is within a preset ratio range, the anchor sample is an image in the image cluster whose similarity is less than a minimum value of the preset ratio range, and the positive sample is an image obtained by performing image enhancement processing on the anchor sample; The processing of the unlabeled sample cluster by the neural network model to obtain a second eigenvalue, and processing the second eigenvalue by a second preset loss function to obtain a second loss value, further comprising: Processing each of the triples through the neural network model to obtain a fourth eigenvalue; Each of the four eigenvalues ​​is processed using the first preset loss function to obtain the second loss value.

6. The method according to any one of claims 2 to 4, wherein: The step of returning the total loss value to the neural network model to train the neural network model and obtain the trained neural network model includes: The total loss value is fed back to the neural network model, and the convolution template parameters and bias parameters of the neural network model are updated by a preset optimizer algorithm to train the neural network model once; The labeled sample clusters and the unlabeled sample clusters are obtained by iterative execution until the neural network model is trained for a preset number of epochs to obtain the trained neural network model, wherein each epoch includes at least one training session.

7. The method according to any one of claims 1 to 5, wherein: A ratio between the total number of images included in the unlabeled sample cluster and the total number of images included in the labeled sample cluster is a second preset ratio, and the second preset ratio is greater than 1.

8. An image recognition device, characterized in that: The device comprises: An acquisition unit, configured to acquire an image to be recognized; A processing unit is used to obtain a matching result of the image to be identified in a target image group through a trained neural network model, wherein the target image group includes at least one image; the trained neural network model is trained according to a total loss value of the neural network model, wherein the total loss value is determined by a first loss value and a second loss value, wherein the first loss value is obtained by processing a labeled sample cluster by the neural network model, and the second loss value is obtained by processing an unlabeled sample cluster by the neural network model, wherein the labeled sample cluster includes one or more labeled images, and the unlabeled sample cluster includes one or more unlabeled images; wherein the unlabeled sample cluster includes a plurality of first sample pairs, each of the first sample pairs includes a second target image and an enhanced image, wherein the second target image is any image in the image cluster, and the enhanced image is an image enhancement process performed on the second target image. the image obtained after the first loss; the second loss value is obtained by processing each sampling eigenvalue and each enhanced eigenvalue through a second preset loss function, the each sampling eigenvalue is obtained by processing each second target image through the neural network model, and the each enhanced eigenvalue is obtained by processing each enhanced image through the neural network model; the labeled sample cluster includes a plurality of normal labeled triplets and a plurality of difficult labeled triplets, and the first loss value includes a normal loss value and a difficult loss value; the normal loss value is obtained by processing each normal labeled triplet through the neural network model to obtain a normal eigenvalue, and processing each normal eigenvalue through the first preset loss function; the difficult loss value is obtained by processing each difficult labeled triplet through the neural network model to obtain a difficult eigenvalue, and processing each difficult eigenvalue through the first preset loss function; An output unit is configured to output a target image that matches the image to be identified if the matching result indicates that there is a target image in the target image group.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the image recognition method according to any one of claims 1 to 7.

10. A computer program product, characterized in that The computer program product comprises computer instructions, and the computer instructions are executed to implement the image recognition method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Convolution neural network model training method device and apparatus, and computer readable storage medium

    CN109359725A

  • Deep neural network unsupervised learning method based on similarity distances in objects and between objects

    CN111401519A

  • Video deduplication method based on unsupervised deep twin network

    CN111506773A

  • Semi-supervised character re-identification method based on camera style and human body posture adaptation

    CN111639540A