Method and device for training target image retrieval model
By constructing a comprehensive loss function and updating the target image retrieval model, the problem of high time-consuming feature extraction and limited backward compatibility in image retrieval is solved, and efficient and widely applicable backward compatibility and feature comparability are achieved.
Patent Information
- Application Number
- CN202210202436.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-03
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2042-03-03
AI Technical Summary
In the existing technology, after updating the feature extraction model in image retrieval, features need to be re-extracted from a large number of candidate images, which is time-consuming and costly. Moreover, the backward-compatible representation learning method is limited to the training set of the old model, and its applicable scenarios are limited.
By obtaining sample image data and labels, the original image retrieval model and the target image retrieval model are used to extract feature vectors respectively, construct a comprehensive loss function, and update the target image retrieval model parameters to make it backward compatible and applicable to all scenarios.
It achieves backward compatibility without limiting training data, is suitable for a wide range of scenarios, improves the comparability of features and the quality of retrieval models, and reduces the cost and time of feature extraction.
Smart Images

Figure CN114565807B
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of image retrieval, and in particular to a method and apparatus for training a target image retrieval model, and corresponding computing equipment, storage media, and computer program products. Background Art
[0002] In the field of image retrieval (including but not limited to image detection based on similarity, image content recognition, etc.), it usually involves feature extraction and comparison between the query image and the candidate images in the image library. That is, the comparison between the features of the query image and the features of the candidate images should be able to reflect the content similarity between the query image and the candidate images. This requirement for features can be referred to as feature comparability.
[0003] The upgrade of the image retrieval system includes the update of the feature extraction model. The features extracted by the updated feature extraction model (sometimes referred to as the new model in this article, and correspondingly, the feature extraction model before the update is sometimes referred to as the old model) will more accurately reflect the content of the image. It is generally believed that the features of multiple images extracted by the same feature extraction model are comparable. Therefore, in conventional technology, in order to maintain this comparability, after the feature extraction model is updated, the updated feature extraction model can be used to re-extract features from all candidate images in the image library, and the newly extracted features cover the old features (this way of obtaining comparability is referred to as feature upgrade coverage). In this way, the features of the image to be queried and the features of the candidate images will both be extracted by the updated feature extraction model, which is beneficial to the comparability of the features to a certain extent. However, considering that in actual application scenarios, the candidate images may reach a scale of hundreds of millions, this process of re-extracting features will be extremely time-consuming and costly.
[0004] In order to avoid the additional cost of feature upgrade coverage, another way to achieve comparability is to train the updated model in a "backward compatible representation learning" way. Through this training method, the features of the query image extracted by the updated feature extraction model are comparable to the features of the candidate image extracted by the feature extraction model before the update, thereby initially achieving backward compatibility. However, in conventional technology, the "backward compatible representation learning" method is only applicable to limited scenarios. For example, this training method relies heavily on the training set of the old model (i.e., the set of training samples), which requires that the training set of the new model contains the training set of the old model. From the concept of the set, this requires that the training set of the old model is a true subset of the training set of the new model. In short, at present, "backward compatible representation learning" is subject to large constraints and the applicable scenarios are very limited. Summary of the invention
[0005] In view of this, the present application provides a method and apparatus for training a target image retrieval model, as well as corresponding computing devices, storage media, and computer program products, in the hope of overcoming some or all of the above-mentioned deficiencies and other possible deficiencies.
[0006] According to one aspect of the present application, a method for training a target image retrieval model is provided, for making the trained target image retrieval model backward compatible with the original image retrieval model, characterized in that the method includes: obtaining sample image data and labels for training the target image retrieval model; inputting the sample image data into the original image retrieval model to obtain a first feature vector corresponding to the sample image data; performing a category characterization operation on the first feature vector to determine a category characterization result of the first feature vector; inputting the sample image data into the target image retrieval model to obtain a second feature vector corresponding to the sample image data; inputting the second feature vector into the target classifier of the target image retrieval model to obtain a target prediction classification result; determining a comprehensive loss function of the target image retrieval model based on the second feature vector corresponding to each sample image data, the category characterization result of the first feature vector, the label and the target prediction classification result; updating the parameters of the target image retrieval model based on the comprehensive loss function so that the target image retrieval model converges to complete the training of the target image retrieval model.
[0007] In some embodiments, the comprehensive loss function is constructed by a backward compatible loss function and a classification loss function, and, based on the second feature vector corresponding to each sample image data, the category characterization result of the first feature vector, the label and the target predicted classification result, determining the comprehensive loss function of the target image retrieval model includes: determining the backward compatible loss function of the target image retrieval model based on the category characterization result of the second feature vector and the first feature vector; and, determining the classification loss function of the target image retrieval model based on the label and the target predicted classification result.
[0008] In some embodiments, performing a category characterization operation on the first feature vector includes: performing a classification operation on the first feature vector based on the label, and determining a class center vector of each class of the first feature vector as a category characterization result of the first feature vector; and, based on the category characterization results of the second feature vector and the first feature vector, determining a backward compatible loss function of the target image retrieval model includes: determining the similarity between the second feature vector corresponding to each sample image data and the class center vector of the first feature vector; and, based on the similarity, determining a backward compatible loss function of the target image retrieval model.
[0009] In some embodiments, determining the class center vector of each class of first eigenvectors includes: splicing first eigenvectors belonging to the same class into an eigenvector matrix; forming a symmetric matrix with the similarities between second eigenvectors corresponding to each of the first eigenvectors belonging to the same class; normalizing the symmetric matrix to obtain a transfer matrix; determining an adjusted first eigenvector through the eigenvector matrix and the transfer matrix; and determining the class center vector of the adjusted first eigenvector as the class center vector of each class of first eigenvectors.
[0010] In some embodiments, determining the adjusted first eigenvector through the eigenvector matrix and the transfer matrix includes: performing at least one multiplication operation on the eigenvector matrix through the transfer matrix to obtain an iteration matrix; and performing weighted summation processing on the iteration matrix and the eigenvector matrix to obtain an adjustment matrix composed of the adjusted first eigenvector, thereby obtaining the adjusted first eigenvector.
[0011] In some embodiments, performing weighted summation processing on the iteration matrix and the eigenvector matrix includes: assigning a weight of λ to the iteration matrix, assigning a weight of 1-λ to the eigenvector matrix, and performing an addition operation, wherein the range of λ is 0.85-0.95.
[0012] In some embodiments, determining the adjusted first eigenvector by using the eigenvector matrix and the transfer matrix comprises: Determine the adjustment matrix to obtain the adjusted first eigenvector, where V represents the adjustment matrix, where represents the eigenvector matrix, represents the transfer matrix, I Represents the identity matrix.
[0013] In some embodiments, obtaining sample image data and labels for training the target image retrieval model includes: determining that the category of the sample image data belongs to the category of the original sample image data used to train the original image retrieval model; and, performing a category characterization operation on the first feature vector to determine the category characterization result of the first feature vector includes: inputting the first feature vector into the original classifier of the original image retrieval model to obtain a first original classification result as the category characterization result of the first feature vector; and, the method also includes: inputting the second feature vector into the original classifier of the original image retrieval model to obtain a second original classification result; and, based on the second feature vector corresponding to each sample image data, the category characterization result of the first feature vector, the label and the target predicted classification result, determining the comprehensive loss function of the target image retrieval model includes: determining the comprehensive loss function of the target image retrieval model based on the second original classification result, the first original classification result, the label and the target predicted classification result corresponding to each sample image data.
[0014] In some embodiments, the comprehensive loss function is constructed by a backward compatible loss function and a classification loss function, and, based on the second original classification result, the first original classification result, the label and the target predicted classification result corresponding to each sample image data, determining the comprehensive loss function of the target image retrieval model includes: determining the backward compatible loss function of the target image retrieval model based on the second original classification result and the first original classification result; and, determining the classification loss function of the target image retrieval model based on the label and the target predicted classification result.
[0015] In some embodiments, both the backward-compatible loss function and the classification loss function adopt the ArcFace function.
[0016] According to another aspect of the present invention, there is provided a device for training a target image retrieval model, for making the trained target image retrieval model backward compatible with the original image retrieval model. The device comprises: a sample image data and label acquisition module, which is configured to acquire sample image data and labels for training the target image retrieval model; a first feature vector determination module, which is configured to input the sample image data into the original image retrieval model to obtain a first feature vector corresponding to the sample image data; a category characterization module, which is configured to perform a category characterization operation on the first feature vector to determine a category characterization result of the first feature vector; a second feature vector determination module, which is configured to input the sample image data into the target image retrieval model to obtain a second feature vector corresponding to the sample image data; a target prediction classification module, which is configured to input the second feature vector into a target classifier of the target image retrieval model to obtain a target prediction classification result; a comprehensive loss function determination module, which is configured to determine a comprehensive loss function of the target image retrieval model based on the second feature vector corresponding to each sample image data, the category characterization result of the first feature vector, the label and the target prediction classification result; and a model parameter updating module, which is configured to update the parameters of the target image retrieval model based on the comprehensive loss function so that the target image retrieval model reaches convergence to complete the training of the target image retrieval model.
[0017] According to another aspect of the present invention, a computing device is provided, comprising: a memory configured to store computer-executable instructions; and a processor configured to execute a method for training a target image retrieval model according to any embodiment of the present application when the computer-executable instructions are executed by the processor.
[0018] According to another aspect of the present invention, a computer-readable storage medium is provided, which stores computer-executable instructions. When the computer-executable instructions are executed, the method for training a target image retrieval model according to any embodiment of the present application is executed.
[0019] According to another aspect of the present invention, a computer program product is provided, comprising computer executable instructions, wherein the computer executable instructions, when executed by a processor, perform the method for training a target image retrieval model according to any embodiment of the present application.
[0020] The target image retrieval model trained by the method of training the target image retrieval model of the embodiment of the present application has backward compatibility for all scenarios. The training of the model does not require limitation on the sample image data used to train the target image retrieval model, so the backward compatibility of the trained model has a wide range of applicable scenarios. In addition, the method of training the target image retrieval model of the embodiment of the present application also performs prototype-like adjustment on the feature vector output by the original model, and the feature vector of the sample image of the same category obtained is more compact. The loss function determined based on the adjusted prototype will help achieve higher quality backward compatibility. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Embodiments of the present application will now be described in more detail and with reference to the accompanying drawings, in which:
[0022] Figure 1 Several scenarios of the training sets of the original model and the target model are schematically shown;
[0023] Figure 2 Schematically illustrates an exemplary application scenario in which the technical solution according to the embodiments of the present application can be implemented;
[0024] Figure 3 A flowchart of a method for training a target image retrieval model according to an embodiment of the present application is schematically shown;
[0025] Figure 4 A flowchart of a method for training a target image retrieval model according to another embodiment of the present application is schematically shown;
[0026] Figure 5 A flowchart of a method for training a target image retrieval model according to another embodiment of the present application is schematically shown;
[0027] Figure 6 The implementation scenario of the method for training a target image retrieval model according to an embodiment of the present application is schematically shown;
[0028] Figure 7 The implementation scenario of the process of graph-based structured class prototype adjustment according to an embodiment of the present application is schematically shown;
[0029] Figure 8 The following schematically shows an exemplary structural block diagram of a device for training a target image retrieval model according to an embodiment of the present application;
[0030] Fig. 9 An example system is schematically illustrated that includes an example computing device that represents one or more systems and / or devices that may implement the various techniques described herein. DETAILED DESCRIPTION
[0031] The technical solutions in this application will be described clearly and completely below in conjunction with the drawings in this application. The described embodiments are only part of the embodiments of this application, not all of them. Based on the embodiments of this application, all other embodiments obtained by ordinary technicians in this field without creative work belong to the scope of protection of this application.
[0032] This application involves artificial intelligence related technologies. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making.
[0033] Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level and software-level technologies. The basic technologies of artificial intelligence generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics and other technologies. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0034] This application mainly involves machine learning in artificial intelligence. Among them, machine learning (ML) is a multi-field interdisciplinary subject, involving probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other disciplines, specializing in how computers simulate or implement human learning behavior, in order to acquire new knowledge or skills, reorganize the existing knowledge structure to continuously improve its performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all fields of artificial intelligence. Machine learning and deep learning usually include technologies such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and multi-perspective learning.
[0035] The machine learning involved in this application mainly refers to how to train an image retrieval network. In order to facilitate the understanding of the embodiments of this application, several concepts are briefly introduced below:
[0036] Backward compatibility: Also known as backward compatibility, it means that a later version of a software / program / product is compatible with its earlier version. For example, if a new version of a program can use / edit files or data created by an older version of the same program, the new version of the program can be said to be backward compatible. Backward compatibility is important because it eliminates the need to start over when upgrading.
[0037] Universal backward compatible representation learning: Representation learning refers to converting fuzzy and abstract raw data into a form that is mathematically or computationally very easy to process and can be learned by machines. Backward compatible representation learning means that the features obtained by the later version of the representation model are compatible with the features obtained by the previous version of the representation model. For example, the features generated by the new model can be directly used to search in the database indexed by the old model.
[0038] Universal backward compatible representation learning: Universal backward compatibility refers to backward compatibility in all scenarios or open scenarios. Universal backward compatible representation learning means that the training scenarios of the new representation model will not be restricted by the training scenarios of the old representation model. For example, the training data set of the new model does not need to completely cover the training data set of the old model. The process of achieving backward compatible representation learning in all scenarios can be called universal backward compatible training (UniBCT). Universal backward compatible representation learning is a new concept proposed in this application.
[0039] Faced with the limited scenarios of backward-compatible representation learning, the inventors of this application studied various potential compatible training scenarios in the real world and proposed a new problem of universal backward-compatible representation learning. As mentioned above, existing backward-compatible methods rely heavily on the training set of the old model. However, this is very limited because real scenarios are complex, variable, and unpredictable. In real scenarios, from the perspective of data and type, the training sets of the new and old models may have the following relationship. Figure 1Several scenarios of the training sets of the original model and the target model are schematically shown. For example, in the data consistency scenario, the data of the new and old training sets are exactly the same, and the data categories are obviously the same. In the extended scenario, the new training set contains the old training set. For example, in the data extension scenario, the data categories of the old training set and the new training set are the same, and the new training set covers the old training set, that is, although the amount of data in the new training set is larger than that of the old training set, the data categories are the same. For another example, in the category extension scenario, the data categories of the new training set cover the data categories of the old training set, and the new training set covers the old training set, that is, the new training set also contains data categories that are not in the old training set. In the open scenario, the data of the new and old training sets are completely different. For example, in the data open scenario, the data categories of the old training set and the new training set are the same, but the new training set has no intersection with the data of the old data set. For another example, in the category open scenario, the data category of the new training set is different from the data category of the old training set, and the data is obviously different. Conventional backward-compatible representation learning only studies the scenario where the new training set completely covers the old training set. Therefore, it can be applied to data consistency, data expansion, and category expansion scenarios at most, but cannot bring backward compatibility to open scenarios. Moreover, it should be understood that even if the data of the new and old training sets are exactly the same, it does not mean that the new and old models must be compatible, because the performance of the representation learning model is also affected by the classifier and backbone of the model. Therefore, even if conventional backward compatible representation learning can be applied to consistent or expanded scenarios, its backward compatibility effect cannot be guaranteed. The method and device for training the target image retrieval model of the present application implements universal backward compatible representation learning, which is not limited to the special constraints of the training set in the version upgrade, that is, the new training set is not required to contain the old training set. In order to make the new model backward compatible with the old model, the present invention inputs the data of the new training set into the old model and the new model respectively when training the new model, and uses the old model and the new model to extract the features of the data in the new training set respectively, and then uses the features extracted by the old model to construct the old class prototype, and determines the backward compatible loss function by the distance between the features extracted by the new model and the old class prototype, and adjusts the parameters of the new model accordingly. Since it no longer depends on the relationship between the new and old training sets, this application can uniformly solve compatible training in various training scenarios, especially for open scenarios.
[0040] Figure 2 The following schematically illustrates an exemplary application scenario in which the technical solution according to the embodiment of the present application can be implemented. Figure 1 As shown, the scene 200 may include a server 210 , terminal devices 230 , 250 , 270 , and optionally a database device 220 for storing image data. These servers or devices may communicate with each other via a network 290 .
[0041] Exemplarily, the sample image data used to train the target image retrieval model may be uploaded to the server 210 by the users 240, 260, 280 through their respective terminal devices 230, 250, 270. The uploaded sample image data may be data stored on any one or more of the terminal devices 230, 250, 270, or may be data read from an external storage device or captured or collected by the terminal devices 230, 250, 270.
[0042] The server 210 may be a single server or a cluster of servers. Each terminal device 230, 250, 270 may be connected to the server 210 through a network, so that each terminal device 230, 250, 270 may interact with the server 210 for data. When multiple servers are used, the servers may be connected to each other through a network to obtain data from each other. Different data may be stored on multiple servers, or different operations may be performed. The server 210 may receive uploaded sample image data, or convert other types of data into sample image data, and train the target image retrieval model using the sample image data according to the methods of various embodiments of the present application. The server 210 may also run other applications and store other data. For example, the server 210 may include multiple virtual hosts to run different applications and provide different services. The server in the present application may also be, for example, a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content distribution networks, and big data and artificial intelligence platforms. The terminal device may be, for example, a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart TV or other smart terminal.
[0043] In addition, in the present application, network 290 can be a wired network connected via cables, optical fibers, etc., or a wireless network such as 2G, 3G, 4G, 5G, Wi-Fi, Bluetooth, ZigBee, Li-Fi, etc.
[0044] The method for training the target image retrieval model according to the embodiment of the present application can be completed in the server, or in the combination of the server and the terminal device, or only in the terminal device. The following describes the embodiment of the present application by taking the communication between the terminal device 230 and the server 210 as an example. In the present application, the existing image retrieval model before updating is also referred to as the original image retrieval model, referred to as the original model, and the image retrieval model to be obtained through training is also referred to as the target image retrieval model, referred to as the target model. Before starting to train the target model, it is necessary to prepare the training set data. The terminal device 230 can pre-collect and store the training set data, such as sample image data, and determine the label of the training set data. In some embodiments, the training of the target model is completed in the server 210. The sample image data and the label are provided to the server 210 before the training starts. In addition, the original model and the target model to be trained are arranged in the server 210. After executing each step of the method for training the target image retrieval model according to the embodiment of the present application, the server 210 will obtain a trained target model. The specific information of the above training process will be described later.
[0045] Although the model training process of the above embodiment is implemented in the server, and the sample image data used to train the target model comes from the terminal device, the present application is not limited thereto. For example, the model training process can also be implemented in the terminal device. Moreover, in addition to being pre-collected and stored by the terminal device, the required sample image data can also use sample image data stored in the server.
[0046] According to one aspect of the present application, a method for training a target image retrieval model is provided. The method is used to make the trained target model backward compatible with the original model. Both the original model and the target model are models for image retrieval. The target model can be understood as an update of the original model. Figure 3 The flowchart of the method 300 for training a target image retrieval model according to an embodiment of the present application is schematically shown. Figure 3 As shown, the method 300 includes the following steps.
[0047] In step S305, sample image data and labels for training the target image retrieval model are obtained.
[0048] In step S310, the sample image data is input into the original image retrieval model to obtain a first feature vector corresponding to the sample image data.
[0049] In step S315, a category characterization operation is performed on the first feature vector to determine a category characterization result of the first feature vector.
[0050] In step S320, the sample image data is input into the target image retrieval model to obtain a second feature vector corresponding to the sample image data.
[0051] In step S325, the second feature vector is input into the target classifier of the target image retrieval model to obtain a target prediction classification result.
[0052] In step S330, a comprehensive loss function of the target image retrieval model is determined based on the second feature vector corresponding to each sample image data, the category characterization result of the first feature vector, the label and the target prediction classification result.
[0053] In step S335, the parameters of the target image retrieval model are updated based on the comprehensive loss function so that the target image retrieval model converges to complete the training of the target image retrieval model.
[0054] These steps are described in detail below.
[0055] First, the step of obtaining sample image data and labels for training the target image retrieval model, i.e., step S305, is described. Before training the target model, the sample image data and labels for training the target model may be determined first. The embodiment of the present application does not limit the training set of the target model due to the training set of the original model, so the training set of the target model may completely, partially, or not include the training set of the original model. After determining the sample image data and labels for training the target model, the server or terminal device will obtain the sample image data and labels, i.e., perform step S305.
[0056] In this step, in addition to obtaining the sample image data and labels themselves, it is also possible to obtain the relationship between the training set of the target model and the training set of the original model. For example, after determining the sample image data and labels used to train the target model, it can be further determined whether the category of the sample image data used to train the target model is the same as the category of the sample image data used to train the original model. The category of image data mainly refers to the category of the objective content of the image. For example, image data that describes the same, similar, or common content may be determined to belong to the same category. After feature extraction, the features obtained from image data belonging to the same category should have a relatively high degree of similarity.
[0057] Next, the sample image data is input into the original image retrieval model to obtain the first feature vector corresponding to the sample image data, i.e., step S310. The original image retrieval model here is a model that has been trained before. Various parameters of the original image retrieval model have been adjusted and determined based on the output result after the old training set is input into the model and the label of the old training set. For example, the sample image data of the old training set is input into the feature extraction model of the original image retrieval model to obtain a feature vector, and then the feature vector is input into the classifier of the model (which may be called the original classifier), and the original classifier outputs the predicted classification probability for the sample image data of the old training set. According to the labels and predicted classification probabilities corresponding to each sample image data, the classification loss function of the original image retrieval model can be obtained. Then, various parameters of the original image retrieval model can be adjusted several times based on the classification loss function and finally determined. In step S310, after the sample image data is input into the original image retrieval model, the feature extraction model of the original image retrieval model will output the corresponding feature vector, i.e., the first feature vector. That is, the term "first feature vector" is a feature vector obtained by processing the training set of the target model by the feature extraction model of the original model.
[0058] After obtaining the first feature vector corresponding to the sample image data, a category characterization operation is performed on the first feature vector to determine the category characterization result of the first feature vector, that is, step S315. In this step, the first feature vector is classified, and the classification result is represented by the category characterization result. The effect of the classification should be that relatively compact feature vectors should be determined to belong to the same category. The compactness of the feature vector can be measured in a variety of ways, such as the Euclidean distance, Manhattan distance, Chebyshev distance, Minkowski distance, Mahalanobis distance, cosine similarity, cross entropy, relative entropy, etc. between vectors. After the feature vector is classified, it is necessary to characterize the category of the feature vector in a form and obtain the category characterization result. For example, the category of a vector belonging to a class can be represented by the class center vector of the class vector. For another example, the feature vector can be determined by a classifier. In appropriate cases, the result output by the classifier can be used as the class center of the corresponding feature vector. The result output by the classifier is generally the predicted classification probability of the category.
[0059] In addition to being input into the original image retrieval model as mentioned above, the sample image data will also be input into the target image retrieval model to obtain the second feature vector corresponding to the sample image data, that is, step S320. In this step, the sample image data is input into the target model being trained. The feature extraction model of the target model will output the corresponding feature vector, that is, the second feature vector. Considering in conjunction with step S310, the sample image data used to train the target image retrieval model is input into both the original model and the target model. It can be considered that there is a corresponding relationship between the first feature vector and the second feature vector of the same sample image data. It should be noted that the embodiment of the present application does not limit the order of step S310 and step S320. These two steps can be completed in any order or simultaneously.
[0060] After obtaining the second eigenvector, the second eigenvector is input into the target classifier of the target image retrieval model to obtain the target prediction classification result, i.e., step S325. In addition to the aforementioned feature extraction model, the target image retrieval model also includes a classifier. The classifier can be called a target classifier. The target image retrieval model here can be based on the initialization of the model parameters in the early stage of training as the starting point. Initialization of the model parameters includes pre-configuration of the weight matrix in the model. At this time, the initialized target classifier has a certain image classification ability, but usually, the classification ability at this time is low. The predicted classification probability output by the target classifier can indicate the confidence level that the sample image data is classified into each category in the target category. For the same sample image data, the sum of the probabilities of its various categories is 1.
[0061] Through the aforementioned steps S310, S315, S320 and S325, the first feature vector corresponding to the sample image data, the category characterization result of the first feature vector, the second feature vector corresponding to the sample image data, and the target prediction classification result corresponding to the sample image data are obtained respectively. Then, based on these parameters, the comprehensive loss function of the target image retrieval model is determined, that is, step S330. The term "comprehensive loss function" should be understood as that the adjustment of the parameters of the target image retrieval model in this application is a comprehensive adjustment based on multiple factors. For example, this application requires that the target model has better feature characterization capabilities, and that the new features obtained by the target model and the old features obtained by the original model can be compatible with each other. Therefore, this application determines the loss function based on at least these two factors, so this loss function is comprehensive.
[0062] By constraining the image retrieval effect through the loss function, the image retrieval effect can be made more accurate. The goal of the comprehensive loss function is to enable the target image retrieval model to obtain better feature representation capabilities and to make the features of the query image obtained by the target image retrieval model directly comparable to the features of the candidate images in the gallery obtained by the original model.
[0063] After obtaining the comprehensive loss function, the parameters of the target image retrieval model can be updated based on the comprehensive loss function so that the target image retrieval model converges to complete the training of the target image retrieval model, that is, step S335. In an embodiment of the present application, the server or terminal device can iteratively update the network parameters of the image retrieval model through the above-mentioned comprehensive loss function. When the loss value of the comprehensive loss function remains stable, or when the loss value of the comprehensive loss function is less than the loss threshold, the target image retrieval model converges. At this time, the training of the target image retrieval model is completed.
[0064] The method for training the target image retrieval model according to the embodiment of the present application provides a simple and effective unified training paradigm to achieve backward-compatible representation learning in all scenarios. This method does not need to limit the sample image data used to train the target image retrieval model, so it is universal and unified. The comprehensive loss function of the embodiment of the present application takes into account the first feature vector (represented by the category characterization result) obtained in the original image retrieval model and the second feature vector obtained in the target image retrieval model for the same sample image data, and aligns the latent space of the second feature vector with the first feature vector based on the distance between the category characterization result of the first feature vector and the second feature vector. Therefore, the features extracted by the target image retrieval model are compatible with the features extracted by the original image retrieval model.
[0065] It should be understood that Figure 3 It is only used to indicate the specific steps involved in the method for training the target image retrieval model, but is not intended to limit the execution time and logical order of these steps. The execution time and logical order between each step should be understood based on the context of this application.
[0066] Figure 4The flowchart of the method for training the target image retrieval model according to another embodiment of the present application is schematically shown. As mentioned above, in some embodiments, the training goal of the target image retrieval model of the present application is to make the trained target image retrieval model have better feature characterization ability, and make the features extracted by the trained target image retrieval model directly comparable with the features extracted by the original model. Therefore, in some embodiments, the comprehensive loss function is constructed by a backward compatible loss function and a classification loss function. That is to say, the comprehensive loss function is divided into two parts, and the factors determining the loss functions of the two parts are different. In the backward compatible loss function part, the loss function of this part is mainly determined based on the compatibility of the features extracted by the target model and the original model. In the parameters used to determine the comprehensive loss function, the difference between the category characterization results of the second feature vector and the first feature vector corresponding to each sample image data can reflect the difference in the features extracted by the new and old models, so it is mainly used to determine the backward compatible loss function. In the classification loss function part, the loss function of this part is mainly determined based on the difference between the predicted classification result output by the target model (target classifier) and the corresponding label. The label of the sample image data and the target predicted classification result reflect the performance of the target image retrieval model in analyzing the sample image data, so it is mainly used to determine the classification loss function. Therefore, in some embodiments, the step of determining the comprehensive loss function of the target image retrieval model based on the second feature vector corresponding to each sample image data, the category characterization result of the first feature vector, the label and the target prediction classification result (step S330) may include determining the backward compatible loss function of the target image retrieval model based on the category characterization results of the second feature vector and the first feature vector (step S405); and determining the classification loss function of the target image retrieval model based on the label and the target prediction classification result (step S410).
[0067] In order to make the trained target image retrieval model backward compatible, the present application determines the backward compatibility loss function by using the difference between the category characterization result of the first feature vector obtained by inputting the sample image data used to train the target image retrieval model into the original image retrieval model and the second feature vector obtained by inputting the corresponding sample image data into the target image retrieval model, without considering the relationship between the sample image data and the training samples of the original model. Therefore, the application scenarios of the backward compatibility of the obtained image retrieval model will be more extensive.
[0068] same, Figure 4 It is only used to indicate the steps required for the process of determining the comprehensive loss function, but is not intended to limit the execution time and logical order of these steps. The execution time and logical order between each step should be understood based on the context of this application.
[0069] In some embodiments, the backward compatible loss function and the classification loss function can be added together, and then the network parameters of the target image retrieval model are updated by the added loss function. In a more specific embodiment, the backward compatible loss function and the classification loss function are assigned loss weights. The loss weight is a hyperparameter and can be adjusted by experimental results. In some embodiments, the loss weights of the backward compatible loss function and the classification loss function can both be set to 1.
[0070] In some embodiments, the category characterization operation on the first feature vector may be performed using a supervised learning method, for example, the first feature vector is classified with the help of the label of the sample image data corresponding to the first feature vector. Specifically, the first feature vector is first classified into several categories with the help of the label, and then the class center vector of each category can be determined in an appropriate manner. At this time, determining the backward compatibility loss function of the target image retrieval model may include: determining the similarity between the second feature vector corresponding to each sample image data and the class center vector of the first feature vector; and, based on the similarity, determining the backward compatibility loss function of the target image retrieval model. The closer the second feature vector is to the class center vector of the first feature vector, the closer the feature extraction performance of the target model and the original model for the same input data is, reflecting that the backward compatibility of the target model is better.
[0071] The inventors of the present application recognize that the quality of the category representation of the first feature vector is crucial for backward compatible learning, especially when the new training set of the target model is different from the old training set of the original model. This situation is also called the domain gap phenomenon. In this case, the category representation results obtained by conventional methods (such as simply averaging or weighted averaging of the first feature vectors of each class) have inevitable noise. In order to solve this problem, the present application proposes a simple and effective category representation adjustment algorithm. The category representation adjustment algorithm can also be called a class prototype adjustment algorithm. The inventor believes that the features corresponding to visually similar samples in the same category should be more compact. Moreover, considering that the new model has a stronger feature representation ability, it can more accurately measure the similarity between features. In addition, it is also known that the transfer matrix can be used to calculate the trend of feature changes. Therefore, the present application proposes to form a transfer matrix with the similarity between the second feature vectors determined by the target model, and then by operating the first feature vector of the same class obtained by the original model with the transfer matrix, the first feature vector can be made to change toward a more compact trend of the features corresponding to similar samples. After the above operations, the feature vectors of similar sample images will be adjusted to be closer, and the abnormal features will be corrected, so that the adjusted first feature vector is closer to the class center. The class center obtained based on the adjusted first feature vector can more accurately characterize the class.
[0072] Figure 5 The flowchart of a method 500 for training a target image retrieval model according to another embodiment of the present application is schematically shown. Figure 5 As shown, the step of determining the class center vector of each class of the first eigenvector includes:
[0073] In step S505, first eigenvectors belonging to the same class are concatenated into an eigenvector matrix;
[0074] In step S510, the similarities between the second eigenvectors corresponding to the first eigenvectors belonging to the same class are used to form a symmetric matrix;
[0075] In step S515, the symmetric matrix is normalized to obtain a transfer matrix;
[0076] In step S520, an adjusted first eigenvector is determined by using the eigenvector matrix and the transfer matrix;
[0077] In step S525, the class center vector of the adjusted first feature vector is determined as the class center vector of each class of the first feature vector.
[0078] The above steps are introduced below. In order to adjust the first eigenvector using the similarity between the second eigenvectors, after the category of the first eigenvector is determined, the first eigenvectors belonging to the same category will be spliced into an eigenvector matrix. The similarity between the second eigenvectors corresponding to the first eigenvector constitutes a symmetric matrix. In some embodiments, the similarity can be represented by, for example, the cosine similarity of the second eigenvector. The characteristic of the transfer matrix is that the sum of each row is 1. Therefore, it is necessary to normalize the symmetric matrix to obtain the transfer matrix. Then, through the eigenvector matrix and the transfer matrix, a matrix spliced by the adjusted first eigenvectors can be obtained, thereby determining the adjusted first eigenvector. Specifically, each time the transfer matrix is multiplied by the eigenvector matrix, the first eigenvector in the eigenvector matrix will be adjusted once according to the similarity between the sample image data, so that the distance between the eigenvectors corresponding to the similar sample image data is closer, that is, the similar eigenvectors will be more aggregated.
[0079] In theory, the transfer matrix itself only considers the relationship between two adjacent states. Therefore, in some embodiments, in order to avoid the potential collapse problem during the aggregation process, the initial eigenvector matrix is also taken into account. Specifically, in the step of determining the adjusted first eigenvector through the eigenvector matrix and the transfer matrix, on the one hand, the eigenvector matrix is multiplied at least once through the transfer matrix to obtain an iterative matrix that has been adjusted at least once, and on the other hand, the unadjusted initial eigenvector matrix is also taken into account, so that the previously obtained iterative matrix and the initial eigenvector matrix are weighted and summed to obtain the adjustment matrix. The adjustment matrix obtained at this time is a matrix spliced by the adjusted first eigenvector, that is, the adjusted first eigenvector has been obtained at this time. In some embodiments, in the weighted summation process, the iterative matrix can be assigned a weight of λ, and the eigenvector matrix can be assigned a weight of 1-λ, and an addition operation can be performed. The weight λ here is also a hyperparameter between 0 and 1, and different λ values will also have a certain impact on the result. In a more specific embodiment, the weight λ ranges from 0.85 to 0.95. For example, in some embodiments, the weight λ is set to 0.9.
[0080] As mentioned above, the eigenvector matrix is multiplied by the transfer matrix at least once, i.e., iterated at least once. In some embodiments, the number of iterations can be selected to a suitable value by experimental results. In other embodiments, the number of iterations can be directly set to infinity. In this case, the adjustment matrix can be obtained based only on the eigenvector matrix, the transfer matrix and the weight λ. Specifically, the adjustment matrix V can be determined by the following formula:
[0081] (1)
[0082] in, I represents the identity matrix, represents the transfer matrix, represents the eigenvector matrix, Represents the inverse operation of a matrix.
[0083] The obtained adjustment matrix V is formed by concatenating the adjusted first eigenvectors, so the adjusted class center vector can be obtained by performing a column average operation on the adjustment matrix V. The adjusted class center vector has higher accuracy and less noise, and can more accurately characterize the category of the first eigenvector.
[0084] Through the above steps, the training method of the present application utilizes the stronger feature representation ability of the new model to judge the similarity of the image, and adjusts the characteristics corresponding to the similar images output by the original model to be more compact, thereby constructing a higher quality class center, reducing noise, and helping the target model to have higher backward compatibility performance.
[0085] The above embodiment performs a category characterization operation based on the first feature vector adjusted by the class prototype. This approach can solve the problem of domain differences between the new training set of the target model and the old training set of the original model. The inventors also found that in some cases, the classifier of the original model is available. For example, if the category of the sample image data of the new training set of the target model belongs to the category of the sample image data of the old training set of the original model, the classification result of the original classifier can be used to perform category characterization on the first feature vector.
[0086] In some embodiments, performing a category characterization operation on the first feature vector to determine the category characterization result of the first feature vector includes: inputting the first feature vector into the original classifier of the original image retrieval model to obtain a first original classification result as the category characterization result of the first feature vector. In this case, the method for training the target image retrieval model according to the embodiment of the present application also needs to determine the classification result of the second feature vector, that is, the second original classification result, by means of the original classifier. Then, based on the difference between the first original classification result and the second original classification result, the comprehensive loss function of the target image retrieval model is determined, especially the backward compatible loss function of the target image retrieval model is determined, so that the trained target image retrieval model has backward compatibility and reduces the computational burden. In this embodiment, based on the second feature vector corresponding to each sample image data, the category characterization result of the first feature vector, the label and the target prediction classification result, the step of determining the comprehensive loss function of the target image retrieval model includes: based on the second original classification result corresponding to each sample image data, the first original classification result, the label and the target prediction classification result, the comprehensive loss function of the target image retrieval model is determined. In the case where the comprehensive loss function is constructed by a backward-compatible loss function and a classification loss function, the step of determining the comprehensive loss function of the target image retrieval model based on the second original classification result, the first original classification result, the label and the target predicted classification result corresponding to each sample image data includes: determining the backward-compatible loss function of the target image retrieval model based on the second original classification result and the first original classification result; and, determining the classification loss function of the target image retrieval model based on the label and the target predicted classification result.
[0087] The above-mentioned embodiment uses the label of the sample image data or the original classifier to determine the category of the first feature vector. In other embodiments, the category of the first feature vector may be determined by clustering instead of relying on the label or the classifier.
[0088] In some embodiments, the comprehensive loss function is constructed by the backward compatible loss function and the classification loss function. This can be expressed by the following formula.
[0089] (2)
[0090] in, is the comprehensive loss function, is a classification loss function used to achieve the goal of obtaining better feature representation capabilities. It is a backward compatible loss function used to achieve the goal of making the features extracted by the target model and the original model directly comparable. η is the loss weight, which is used to adjust the proportion of the backward compatible loss function in the comprehensive loss function and can be set manually according to the actual situation. For example, in some embodiments, the loss weight η The value is 1.
[0091] In some embodiments, the backward compatible loss function and classification loss function of the present application both use the ArcFace function. The ArcFace function is defined as follows:
[0092] (3)
[0093] Among them, D n is a sample data set, y is the label corresponding to the training sample image x, s is the scaling scalar, and m is the interval.
[0094] In the classification loss function, is the weight ω of the y-th prototype in the target classifier ω y The angle between the feature φ(x) and the feature φ(x) can be expressed by the following formula:
[0095] (4)
[0096] In the backward compatible loss function, Is a synthetic class prototype The feature φ output by the target image retrieval model n The angle between them can be expressed by the following formula:
[0097] (5)
[0098] After experimental verification, the ArcFace function has achieved good results as a backward compatible loss function and classification loss function.
[0099] The following is a more comprehensive introduction to the method of training the target image retrieval model in an embodiment of the present application from the perspective of practical application.
[0100] Image retrieval generally involves giving a query image (Query, denoted as Q), and then correctly retrieving images with the same or similar content or objects from a large-scale candidate image library (Gallery, denoted as G). x is input to the backbone network or feature extractor of the model φ After that, the feature v can be output. This process can be expressed as .
[0101] This application generally uses the superscript "o" to represent the original model related parameters, and the superscript "n" to represent the target model related parameters. For example, A feature extractor that can represent the original model, A feature extractor that can represent the target model.
[0102] Without considering compatibility, the performance of the image retrieval model can be determined by a single model test (Self Test). In a single model test, the features of the query image and the features of the images in the candidate image library are extracted by the same model. For example, when testing the retrieval performance of the original model, a single model test can be performed, in which the features of the query image and the features of the images in the candidate image library are extracted by the original model. Extraction. The retrieval performance of the original model can be expressed as .
[0103] Taking compatibility into consideration, the performance of the image retrieval model can be determined through cross-model testing. In cross-model testing, the features of the query image and the features of the images in the candidate image library are extracted by different models. For example, when measuring the retrieval performance of the updated target image retrieval model, a cross-model test is performed in which the features of the query image are extracted by the target model. Extraction, the features of the images in the candidate image library are determined by the original model Extraction. The retrieval performance of the target model can be expressed as .
[0104] This application requires that the updated image retrieval system has better feature representation capabilities and that the features extracted by the updated image retrieval system are comparable to those extracted by the image retrieval system before the update. These two performance goals can be expressed as:
[0105] (6).
[0106] Figure 6The implementation scenario of the method for training a target image retrieval model according to an embodiment of the present application is schematically shown. Figure 6 As shown, the compatible training of the target image retrieval model according to the embodiment of the present application is supervised by two regularization terms, one is to use the classification loss function to ensure that the target model has better feature representation capabilities, and the other is to use the backward compatible training loss function to make the new features output by the target model compatible with the old features output by the original model. When determining the classification loss function, in the target model, a second feature vector is extracted from the sample image data, and the target prediction classification result is obtained by inputting the second feature vector into the target classifier in the target model, and then the classification loss function is determined based on the difference between the target prediction classification result and the label of the corresponding sample image data. When determining the backward compatible loss function, the sample image data is input into the original model to obtain the first feature vector. Then, the first feature vector is classified and the representation results of each category are determined. Then, based on the category representation results of the second feature vector and the first feature vector, the backward compatible loss function of the target image retrieval model is determined.
[0107] In some embodiments, the original classifier of the original model can be directly used to characterize the category of the first feature vector for backward compatibility training. However, in an open training scenario, there may be a problem of domain differences between the original model and the target model. The domain difference problem involves the introduction of new categories of sample image data, so accurate characterization of the category of the first feature vector may be more difficult. For example, the original classifier cannot be used directly for backward compatibility training. To solve this problem, in some embodiments, in the training of the target image retrieval model, the first feature vector is first extracted using the model, and the class center vectors of these feature vectors are used for category characterization. This process replaces the use of the original classifier.
[0108] In some embodiments, in order to improve the quality of the class center vector, the first feature vector may be adjusted using a class prototype adjustment module based on a graph structure so as to more accurately determine the class center vector and ultimately achieve better compatibility. The implementation scenario of this adjustment process is introduced below.
[0109] Figure 7The implementation scenario of the process of graph-based structured class prototype adjustment according to an embodiment of the present application is schematically shown. According to the inventor's understanding, the features corresponding to samples with similar content in the same category should be more compact, and the updated model can more accurately measure the similarity between features because the updated model has a stronger feature characterization capability. Therefore, the present application proposes to construct a transfer matrix based on the similarity of sample image data, wherein this similarity is determined based on the second eigenvector extracted by the target image retrieval model, and then the first eigenvector of each category is iterated using the transfer matrix to adjust the first eigenvector to obtain a more accurate class prototype. The specific process is as follows.
[0110] like Figure 7 As shown, the sample image data is input into the old model (original model) to obtain the first feature vector to be adjusted. The first feature vector can be classified according to its corresponding label. In addition, the sample image data is input into the new model (target model) to obtain the second feature vector, and the similarity between the second feature vectors is determined to characterize the similarity of the content of the corresponding sample image data.
[0111] The first eigenvector and the corresponding similarity can be represented in the form of a fully connected undirected graph. The first eigenvector of each category can be used as a vertex of the fully connected undirected graph, and the corresponding similarity obtained based on the corresponding second eigenvector extracted from the target model can be used as an edge of the fully connected undirected graph. For example, sample image No. 1 and sample image No. 2 are respectively input into the old model and the new model as sample image data, and vectors Vo1 and Vo2 output by the old model and vectors Vn1 and Vn2 output by the new model are respectively obtained. The present application believes that the similarity between Vn1 and Vn2 can more accurately measure the similarity between sample image No. 1 and sample image No. 2. In the fully connected undirected graph, Vo1 and Vo2 are used as vertices, and the similarity between Vn1 and Vn2 (such as cosine similarity) is used as an edge between Vo1 and Vo2. By analogy, a fully connected undirected graph of the first eigenvectors of each category can be constructed.
[0112] The first eigenvectors of the same category output by the old model can be concatenated to form the eigenvector matrix V (0) The size of the feature vector matrix V is m*d, where d represents the feature dimension and m represents the number of samples corresponding to each category.
[0113] The similarity between the second eigenvectors output by the new model is formed into a symmetric matrix E. Take the input of three sample images as an example, for example, the second eigenvectors of two sample images are Vn1, Vn2, and Vn3 respectively. Let the similarity between the second eigenvectors Vn1 and Vn2 be s1, the similarity between Vn2 and Vn3 be s2, and the similarity between Vn3 and Vn1 be s3. Then the form of the symmetric matrix is:
[0114] .
[0115] Of course, those skilled in the art will appreciate that this example is only used to describe the formation principle of a symmetric matrix and is not intended to limit the number of sample images.
[0116] Then the symmetric matrix is normalized according to the following formula to obtain the transfer matrix , where the symbol It represents the normalized value of similarity, i and j represent the number of rows and columns of the matrix respectively.
[0117] (7).
[0118] After normalization, the values of the positions with the same number of rows and columns in the matrix, that is, the diagonal positions, are all 0, while the values of other positions are symmetric with respect to the diagonal of the matrix, as shown in the figure below. It should be noted that the sum of each row of the transfer matrix is 1.
[0119]
[0120] Then, the transfer matrix can be used according to the following formula For the eigenvector matrix V (0) Perform t iterations to obtain the adjustment matrix V (t) , where t is a positive integer.
[0121] (8)
[0122] Each iteration can be expressed as:
[0123] (9).
[0124] With each iteration, the distances between similar first eigenvectors will become closer, and abnormal eigenvectors will be corrected, so that the first eigenvector will be closer to the cluster center.
[0125] In some embodiments, in order to avoid the potential collapse problem during the polymerization process, the matrix V is adjusted (t) The determination of also needs to refer to the initial eigenvector matrix V (0) , as described in the following formula, where the aggregation weight λ∈[0,1].
[0126] (10).
[0127] In some embodiments, the number of iterations t can be selected as a suitable value based on experimental results. In other embodiments, the number of iterations t is set to approach infinity. In this case, formula (10) will have a closed form:
[0128] (11)
[0129] The obtained V ( ∞ ) That is, the adjustment matrix V when the number of iterations t is infinite (t) , which is the adjustment matrix V mentioned above. In formula (11), represents the transfer matrix, I represents the identity matrix, () -1 Represents the inverse operation of a matrix.
[0130] By V ( ∞ ) By performing column averaging, we can obtain the adjusted class prototype, as shown in the following formula:
[0131] (12)
[0132] in Represents the jth class prototype. The adjusted class prototype can be used as a supervisory signal for the general backward compatible loss.
[0133] The inventor of the present application experimentally verified the performance of the trained target image retrieval model. The present application was verified on two large-scale face recognition datasets, MS1Mv3 and IJB-C. The previous article mentioned five scenarios for the new and old model training sets. The following table (I) shows the number of images and the number of categories of the new and old training sets in various scenarios used in the verification of the present application.
[0134]
[0135] Table (I): Data statistics under different training scenarios.
[0136] In order to verify the backward compatibility performance of the image retrieval model trained by this application, this application is compared with several other compatible loss functions, including feature regression-based Loss Function and Contrastive Learning Loss function.
[0137] The loss function is defined as follows:
[0138] (13)
[0139] The loss function is defined as follows:
[0140] (14).
[0141] This application uses two sets of standard test protocols in face recognition, namely (1) 1:1 face verification, which calculates the true acceptance rate (TAR) at different false acceptance rates (FAR) for different template pairs, abbreviated as TAR@FAR; and (2) 1:N face identification, which calculates the accuracy of the top k recalled samples, denoted as Top-k Acc.
[0142] This experiment verifies the loss function of the present application without using the structured prototype adjustment module. and the loss function of the structured prototype conditioning module Performance of the trained model. The backbone network of the model uses the standard ResNet18 (ϕ r18 ) and ResNet50 (ϕ r50 ). The experiment selected the large-scale face recognition dataset MS1Mv3 as the training set and tested it on IJB-C. The results are shown in the following table (II):
[0143]
[0144] Table (II): Performance comparison of different training methods in different scenarios on the IJB-C dataset.
[0145] Table 2 shows the performance comparison of image retrieval models trained with different loss functions in five training scenarios. The first and second rows of each scenario are the performance of the image retrieval model trained without considering the backward compatible loss function. Since the new model has stronger feature representation ability, the performance of the new model is generally better without considering the backward compatible loss function.
[0146] The third and fourth rows of Table (II) show the The loss function and The cross-model test retrieval performance and single-model test retrieval performance of the image retrieval model trained with the loss function. The cross-model test retrieval performance obtained by loss function training is poor, indicating that this loss function is not suitable for backward compatibility training. The fifth row of Table (II) shows the performance of the image retrieval model according to the embodiment of the present application. As shown in Table (II), in the cross-model test retrieval performance, the performance of the image retrieval model trained by the method of the embodiment of the present application is significantly better than the performance of other conventional image retrieval models, indicating that the image retrieval model obtained by the training method of the embodiment of the present application has excellent backward compatibility. The sixth row of Table (II) shows the performance value of the image retrieval model trained by introducing a class prototype adjustment module based on a graph structure, which is higher than the performance value of the fifth row, indicating that the performance of the image retrieval model is further improved. Moreover, the single model test performance value of the sixth row is basically higher than other conventional models in each scenario, indicating that it has better image representation capabilities. In short, in these five scenarios, the method of training the target image retrieval model according to the embodiment of the present application achieved excellent performance.
[0147] According to another aspect of the present application, a device for training a target image retrieval model is provided. Figure 8 The exemplary structural block diagram of a device 800 for training a target image retrieval model according to an embodiment of the present application is schematically depicted. The device for training a target image retrieval model is used to make the trained target image retrieval model backward compatible with the original image retrieval model. Figure 8As shown, the device 800 for training the target image retrieval model includes a sample image data and label acquisition module 805, a first feature vector determination module 810, a category characterization module 815, a second feature vector determination module 820, a target prediction classification module 825, a comprehensive loss function determination module 830, and a model parameter update module 835. The sample image data and label acquisition module 805 is configured to acquire sample image data and labels for training the target image retrieval model. The first feature vector determination module 810 is configured to input the sample image data into the original image retrieval model to obtain the first feature vector corresponding to the sample image data. The category characterization module 815 is configured to perform a category characterization operation on the first feature vector to determine the category characterization result of the first feature vector. The second feature vector determination module 820 is configured to input the sample image data into the target image retrieval model to obtain the second feature vector corresponding to the sample image data. The target prediction classification module 825 is configured to input the second feature vector into the target classifier of the target image retrieval model to obtain the target prediction classification result. The comprehensive loss function determination module 830 is configured to determine the comprehensive loss function of the target image retrieval model based on the second feature vector corresponding to each sample image data, the category characterization result of the first feature vector, the label and the target prediction classification result. The model parameter updating module 835 is configured to update the parameters of the target image retrieval model based on the comprehensive loss function so that the target image retrieval model reaches convergence to complete the training of the target image retrieval model.
[0148] Fig. 9 An example system 900 is illustrated, which includes an example computing device 910 that represents one or more systems and / or devices that can implement the various techniques described herein. Computing device 910 can be, for example, a server of a service provider, a device associated with a server, a system on a chip, and / or any other suitable computing device or computing system. Figure 8 The described apparatus 900 for training a target image retrieval model may take the form of a computing device 910. Alternatively, the apparatus 900 for training a target image retrieval model may be implemented as a computer program in the form of an application 916.
[0149] The example computing device 910 as shown includes a processing system 911, one or more computer-readable media 912, and one or more I / O interfaces 913 that are communicatively coupled to each other. Although not shown, the computing device 910 may also include a system bus or other data and command transmission system that couples various components to each other. The system bus may include any one or combination of different bus structures, such as a memory bus or memory controller, a peripheral bus, a universal serial bus, and / or a processor or local bus utilizing any one of a variety of bus architectures. Various other examples are also contemplated, such as control and data lines.
[0150] Processing system 911 represents the functionality of performing one or more operations using hardware. Therefore, processing system 911 is illustrated as including hardware elements 914 that can be configured as processors, functional blocks, etc. This can include other logic devices implemented in hardware as application specific integrated circuits or formed using one or more semiconductors. Hardware elements 914 are not limited by the materials from which they are formed or the processing mechanisms employed therein. For example, a processor can be composed of (multiple) semiconductors and / or transistors (e.g., electronic integrated circuits (ICs)). In such a context, processor executable instructions can be electronic executable instructions.
[0151] Computer-readable media 912 is illustrated as including memory / storage 915. Memory / storage 915 represents memory / storage capacity associated with one or more computer-readable media. Memory / storage 915 may include volatile media (such as random access memory (RAM)) and / or non-volatile media (such as read-only memory (ROM), flash memory, optical disks, magnetic disks, etc.). Memory / storage 915 may include fixed media (e.g., RAM, ROM, fixed hard drives, etc.) and removable media (e.g., flash memory, removable hard drives, optical disks, etc.). Computer-readable media 912 may be configured in various other ways as further described below.
[0152] One or more I / O interfaces 913 represent functionality that allows a user to input commands and information to the computing device 910 using various input devices and optionally also allows information to be presented to the user and / or other components or devices using various output devices. Examples of input devices include a keyboard, a cursor control device (e.g., a mouse), a microphone (e.g., for voice input), a scanner, a touch function (e.g., a capacitive or other sensor configured to detect physical touch), a camera (e.g., a gesture that can detect motion that does not involve touch using visible or invisible wavelengths (such as infrared frequencies)), and the like. Examples of output devices include a display device (e.g., a monitor or projector), a speaker, a printer, a network card, a tactile response device, and the like. Thus, the computing device 910 can be configured in various ways as further described below to support user interaction.
[0153] The computing device 910 also includes an application 916. The application 916 may be, for example, a software instance of the apparatus 900 for training a target image retrieval model, and in combination with other elements in the computing device 910 implement the techniques described herein.
[0154] Various techniques may be described herein in the general context of software hardware elements or program modules. Generally, these modules include routines, programs, objects, elements, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The terms "module," "function," and "component" as used herein generally represent software, firmware, hardware, or a combination thereof. The features of the techniques described herein are platform-independent, meaning that these techniques can be implemented on various computing platforms with various processors.
[0155] The implementation of the described modules and techniques may be stored on or transmitted across some form of computer-readable media. Computer-readable media may include various media that can be accessed by a computing device. By way of example and not limitation, computer-readable media may include "computer-readable storage media" and "computer-readable signal media."
[0156] As opposed to a simple signal transmission, carrier wave, or signal itself, "computer-readable storage medium" refers to a medium and / or device capable of persistently storing information, and / or a tangible storage device. Therefore, computer-readable storage media refers to non-signal-bearing media. Computer-readable storage media include hardware such as volatile and non-volatile, removable and non-removable media and / or storage devices implemented in a method or technology suitable for storing information (such as computer-readable instructions, data structures, program modules, logic elements / circuits, or other data). Examples of computer-readable storage media may include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disk (DVD) or other optical storage device, hard disk, cassette, magnetic tape, magnetic disk storage device or other magnetic storage device, or other storage device, tangible medium, or article of manufacture suitable for storing the desired information and accessible by a computer.
[0157] "Computer-readable signal media" refers to signal-bearing media that is configured to send instructions to hardware of a computing device, such as via a network. Signal media typically can embody computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave, data signal, or other transport mechanism. Signal media also include any information transfer media. The term "modulated data signal" refers to a signal that has one or more of its characteristics set or changed so as to encode information into the signal. By way of example and not limitation, communication media include wired media such as a wired network or direct connection and wireless media such as acoustic, RF, infrared, and other wireless media.
[0158] As previously described, hardware elements 914 and computer-readable media 912 represent instructions, modules, programmable device logic, and / or fixed device logic implemented in hardware form, which in some embodiments can be used to implement at least some aspects of the technology described herein. Hardware elements may include integrated circuits or systems on a chip, application specific integrated circuits (ASICs), field programmable gate arrays (FPGAs), complex programmable logic devices (CPLDs), and other implementations in silicon or components of other hardware devices. In this context, hardware elements can be used as processing devices that perform program tasks defined by instructions, modules, and / or logic embodied by hardware elements, as well as hardware devices for storing instructions for execution, such as the computer-readable storage media described previously.
[0159] The foregoing combinations may also be used to implement the various techniques and modules described herein. Thus, software, hardware or program modules and other program modules may be implemented as one or more instructions and / or logic embodied on some form of computer-readable storage medium and / or by one or more hardware elements 914. The computing device 910 may be configured to implement specific instructions and / or functions corresponding to the software and / or hardware modules. Thus, for example, by using a computer-readable storage medium and / or hardware element 914 of a processing system, a module may be implemented at least in part in hardware as a module executable by the computing device 910 as software. Instructions and / or functions may be executable / operable by one or more articles (e.g., one or more computing devices 910 and / or processing systems 911) to implement the techniques, modules and examples described herein.
[0160] In various embodiments, computing device 910 can adopt various different configurations. For example, computing device 910 can be implemented as a computer-type device including a personal computer, a desktop computer, a multi-screen computer, a laptop computer, a netbook, etc. Computing device 910 can also be implemented as a mobile device-type device including mobile devices such as mobile phones, portable music players, portable game devices, tablet computers, multi-screen computers, etc. Computing device 910 can also be implemented as a television-type device, which includes a device with or connected to a generally larger screen in a casual viewing environment. These devices include televisions, set-top boxes, game consoles, etc.
[0161] The techniques described herein may be supported by these various configurations of computing device 910 and are not limited to the specific examples of the techniques described herein. Functionality may also be implemented in whole or in part on the "cloud" 920 by using a distributed system, such as through a platform 922 as described below.
[0162] Cloud 920 includes and / or represents a platform 922 for resources 924. Platform 922 abstracts the underlying functionality of the hardware (e.g., servers) and software resources of cloud 920. Resources 924 may include applications and / or data that may be used when performing computer processing on a server remote from computing device 910. Resources 924 may also include services provided over the Internet and / or over a subscriber network such as a cellular or Wi-Fi network.
[0163] The platform 922 may abstract resources and functionality to connect the computing device 910 with other computing devices. The platform 922 may also be used to abstract hierarchies of resources to provide hierarchies of corresponding levels of demand encountered for resources 924 implemented via the platform 922. Thus, in an interconnected device embodiment, the implementation of the functionality described herein may be distributed throughout the system 900. For example, functionality may be implemented in part on the computing device 910 and through the platform 922 that abstracts the functionality of the cloud 920.
[0164] The present application provides a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computing device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computing device executes the method for training a target image retrieval model provided in the above-mentioned various optional implementations.
[0165] It should be understood that, for the sake of clarity, embodiments of the present application are described with reference to different functional units. However, it will be apparent that, without departing from the present application, the functionality of each functional unit can be implemented in a single unit, in multiple units or as a part of other functional units. For example, the functionality that is described as being performed by a single unit can be performed by multiple different units. Therefore, reference to a specific functional unit is only considered as a reference to the appropriate unit for providing the described functionality, rather than indicating a strict logical or physical structure or organization. Therefore, the present application can be implemented in a single unit, or can be physically and functionally distributed between different units and circuits.
[0166] It will be understood that although the first, second, etc. terms may be used to describe various devices, elements, parts or portions in this article, these devices, elements, parts or portions should not be limited by these terms. These terms are only used to distinguish one device, element, part or portion from another device, element, part or portion.
[0167] Although the present application has been described in conjunction with some embodiments, it is not intended to be limited to the specific form set forth herein. On the contrary, the scope of the present application is limited only by the appended claims. Additionally, although individual features may be included in different claims, these may possibly be advantageously combined, and the inclusion in different claims does not imply that the combination of features is not feasible and / or advantageous. The order of features in the claims does not imply any specific order in which the features must work. In addition, in the claims, the word "comprising" does not exclude other elements, and the term "one" or "an" does not exclude a plurality. The figure marks in the claims are provided only as clear examples and should not be interpreted as limiting the scope of the claims in any way.
Claims
1. A method for training a target image retrieval model, for making the trained target image retrieval model backward compatible with the original image retrieval model, characterized in that: The method comprises: Acquire sample image data and labels for training the target image retrieval model; Inputting the sample image data into the original image retrieval model to obtain a first feature vector corresponding to the sample image data; Performing a category characterization operation on the first feature vector to determine a category characterization result of the first feature vector; Inputting the sample image data into the target image retrieval model to obtain a second feature vector corresponding to the sample image data; Inputting the second feature vector into the target classifier of the target image retrieval model to obtain a target prediction classification result; Based on the second feature vector corresponding to each sample image data, the category characterization result of the first feature vector, the label and the target prediction classification result, determining a comprehensive loss function of the target image retrieval model, wherein the comprehensive loss function is constructed by a backward compatible loss function and a classification loss function, Wherein, (1) when the first feature vector is classified based on the label and the class center vector of each class of the first feature vector is determined as the class characterization result of the first feature vector, the backward compatible loss function of the target image retrieval model is determined, including: determining the similarity between the second feature vector corresponding to each sample image data and the class center vector of the first feature vector, and determining the backward compatible loss function of the target image retrieval model based on the similarity; (2) when it is determined that the category of the sample image data belongs to the category of the original sample image data used to train the original image retrieval model, and the first feature vector is input into the original classifier of the original image retrieval model to obtain a first original classification result as the class characterization result of the first feature vector, the second feature vector is input into the original classifier of the original image retrieval model to obtain a second original classification result, and the backward compatible loss function of the target image retrieval model is determined, including: determining the backward compatible loss function of the target image retrieval model based on the second original classification result and the first original classification result; and determining the classification loss function of the target image retrieval model based on the label and the target prediction classification result. wherein, based on the label and the target prediction classification result, determining the classification loss function of the target image retrieval model; and The parameters of the target image retrieval model are updated based on the comprehensive loss function so that the target image retrieval model converges to complete the training of the target image retrieval model.
2. The method according to claim 1, wherein: Determining the class center vector of the first eigenvector of each class includes: Concatenate the first eigenvectors belonging to the same class into an eigenvector matrix; The similarities between the second eigenvectors corresponding to the first eigenvectors belonging to the same class form a symmetric matrix; Normalizing the symmetric matrix to obtain a transfer matrix; Determining an adjusted first eigenvector by using the eigenvector matrix and the transfer matrix; The class center vector of the adjusted first feature vector is determined as the class center vector of each class of the first feature vector.
3. The method according to claim 2, wherein: Determining the adjusted first eigenvector by means of the eigenvector matrix and the transfer matrix comprises: Performing at least one multiplication operation on the eigenvector matrix by the transfer matrix to obtain an iteration matrix; and A weighted summation process is performed on the iteration matrix and the eigenvector matrix to obtain an adjustment matrix composed of the adjusted first eigenvectors, thereby obtaining the adjusted first eigenvectors.
4. The method according to claim 3, wherein: Performing weighted summation processing on the iteration matrix and the eigenvector matrix includes: A weight of λ is assigned to the iteration matrix, and a weight of 1-λ is assigned to the eigenvector matrix, and an addition operation is performed, wherein the range of λ is 0.85-0.
95.
5. The method according to claim 4, wherein: Determining the adjusted first eigenvector by using the eigenvector matrix and the transfer matrix comprises: According to the formula Determine the adjustment matrix to obtain the adjusted first eigenvector, where V represents the adjustment matrix, where V (0) represents the eigenvector matrix, represents the transfer matrix, and I represents the identity matrix.
6. The method according to claim 1, wherein: The backward compatible loss function and the classification loss function both use the ArcFace function.
7. A device for training a target image retrieval model, for making the trained target image retrieval model backward compatible with the original image retrieval model, characterized in that: The device comprises: A sample image data and label acquisition module, configured to acquire sample image data and labels for training the target image retrieval model; a first feature vector determination module configured to input the sample image data into the original image retrieval model to obtain a first feature vector corresponding to the sample image data; a category characterization module, configured to perform a category characterization operation on the first feature vector to determine a category characterization result of the first feature vector; a second feature vector determination module configured to input the sample image data into the target image retrieval model to obtain a second feature vector corresponding to the sample image data; a target prediction and classification module, configured to input the second feature vector into a target classifier of the target image retrieval model to obtain a target prediction and classification result; a comprehensive loss function determination module, configured to determine a comprehensive loss function of the target image retrieval model based on the second feature vector corresponding to each sample image data, the category characterization result of the first feature vector, the label and the target prediction classification result, wherein the comprehensive loss function is constructed by a backward compatible loss function and a classification loss function, Wherein, (1) when the first feature vector is classified based on the label and the class center vector of each class of the first feature vector is determined as the class characterization result of the first feature vector, the backward compatible loss function of the target image retrieval model is determined, including: determining the similarity between the second feature vector corresponding to each sample image data and the class center vector of the first feature vector, and determining the backward compatible loss function of the target image retrieval model based on the similarity; (2) when it is determined that the category of the sample image data belongs to the category of the original sample image data used to train the original image retrieval model, and the first feature vector is input into the original classifier of the original image retrieval model to obtain a first original classification result as the class characterization result of the first feature vector, the second feature vector is input into the original classifier of the original image retrieval model to obtain a second original classification result, and the backward compatible loss function of the target image retrieval model is determined, including: determining the backward compatible loss function of the target image retrieval model based on the second original classification result and the first original classification result; and determining the classification loss function of the target image retrieval model based on the label and the target prediction classification result. wherein, based on the label and the target prediction classification result, determining the classification loss function of the target image retrieval model; and A model parameter updating module is configured to update the parameters of the target image retrieval model based on the comprehensive loss function so that the target image retrieval model reaches convergence to complete the training of the target image retrieval model.
8. A computing device comprising: a memory configured to store computer-executable instructions; A processor configured to perform the method according to any one of claims 1 to 6 when the computer executable instructions are executed by the processor. 9 . A computer-readable storage medium storing computer-executable instructions, wherein when the computer-executable instructions are executed, the method according to claim 1 is executed.
10. A computer program product comprising computer executable instructions, wherein the computer executable instructions, when executed by a processor, perform the method according to any one of claims 1 to 6.
