Generating image classification network and image classification method, device, equipment and medium

By combining the method of class center vector and contrastive learning, three loss functions are used to train the image classification network, which solves the problem of insufficient image classification accuracy in the existing technology and achieves higher classification accuracy and efficiency.

CN115049880BActive Publication Date: 2024-10-29SHANGHAI SENSETIME LINGANG INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210765740.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-01
Publication Date
2024-10-29
Estimated Expiration
2042-07-01

AI Technical Summary

Technical Problem

Existing image classification models are not ideal in improving image classification accuracy. In particular, they cannot effectively bring the characteristics of similar image samples closer together, resulting in insufficient classification accuracy.

Method used

A method of generating image classification networks is adopted, by inputting image samples into the first and second image classification networks in each round of training, combining traditional class center vectors and contrastive learning, and using three loss functions to adjust network parameters , including the first loss function based on real category labels, the second loss function based on historical output results, and the third loss function based on virtual category labels, and parameter adjustments are made to shorten the distance between similar image samples.

Benefits of technology

It effectively improves the image classification accuracy of the image classification network, and improves the model's classification ability and efficiency by tightening similar features.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115049880B_ABST
    Figure CN115049880B_ABST
Patent Text Reader

Abstract

The present disclosure provides a method, device, electronic device and storage medium for generating an image classification network and image classification. The method for generating an image classification network includes: obtaining an image sample set for this round of training; inputting the image sample set into a first image classification network and a second image classification network respectively, obtaining a first output result output by the first image classification network and a second output result output by the second image classification network; determining a first loss of a preset first loss function based on the first output result and the true category label corresponding to each sample image; determining a second loss of a preset second loss function based on the first output result of this round of training and the historical second output result; adjusting parameters of the first image classification network based on the first loss and the second loss; repeating multiple rounds of training to obtain a trained first image classification network. The embodiment of the present application can improve the training accuracy of the first image classification network.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer vision technology, and in particular to a method for generating an image classification network, an image classification method, an apparatus, an electronic device, and a storage medium. Background Art

[0002] With the development of computer technology, various deep learning models have gradually been applied in various fields. Among them, image classification is considered to be the most basic task in computer vision. Various downstream tasks are usually performed based on the results of image classification, such as object detection, video analysis or semantic segmentation. Therefore, how to improve the accuracy of image classification is particularly important. Summary of the invention

[0003] The embodiments of the present disclosure at least provide a method for generating an image classification network, an image classification method, an apparatus, an electronic device, and a storage medium.

[0004] The present disclosure provides a method for generating an image classification network, including:

[0005] In each round of training, an image sample set for this round of training is obtained; the image sample set includes at least two sample images, and each of the sample images is annotated with a true category label of each sample image;

[0006] Inputting the image sample set into a first image classification network and a second image classification network respectively, obtaining a first output result output by the first image classification network in this round of training and a second output result output by the second image classification network, wherein the second image classification network is obtained based on the first image classification network after adjusting parameters obtained in at least one round of completed training;

[0007] Determine a first loss of a preset first loss function based on a first output result obtained in this round of training and a true category label corresponding to each sample image;

[0008] Based on the first output result of the current round of training and the historical second output result, determining a second loss of a preset second loss function, wherein the second loss function represents the distance between the first output result and the sample image whose similarity is greater than a preset threshold in the historical second output result; the historical second output result includes the second output result obtained in at least one round of historical training before the current round of training;

[0009] Adjusting parameters of the first image classification network based on the first loss and the second loss;

[0010] Repeat multiple rounds of the training to obtain a trained first image classification network.

[0011] In the disclosed embodiment, since the network parameters are adjusted according to the first loss function and the second loss function at the same time, that is, the network training is performed by combining the traditional class center vector with contrastive learning, not only can the distance between image samples of the same type be shortened, but also the distance between image samples of the same type can be shortened while more similar image samples of the same type are shortened. In this way, the goal of making similar features more compact can be achieved, which is beneficial to improving the image classification accuracy of the first image classification network.

[0012] In a possible implementation, before adjusting parameters of the first image classification network based on the first loss and the second loss, the method further includes:

[0013] Generate a virtual category label for the image sample set in the current round of training based on the second output result of the current round of training and the historical second output result;

[0014] Determine a third loss of a preset third loss function based on a difference between the first output result of this round of training and the virtual category label;

[0015] The step of adjusting parameters of the first image classification network based on the first loss and the second loss includes:

[0016] Parameters of the first image classification network are adjusted based on a weighted sum of the first loss, the second loss, and the third loss.

[0017] In the disclosed embodiment, since the first image classification network is constrained based on three loss functions, that is, in addition to the first loss function and the second loss function, the first output result and the virtual category label are constrained by the third loss function, the image classification accuracy of the first image classification network can be further improved.

[0018] In a possible implementation, the second image classification network is obtained by performing sliding average on the first image classification network after adjusting parameters obtained in the at least one completed round of training.

[0019] In the disclosed embodiment, the second image classification network is obtained by accumulating and iterating the first image classification network at a slower speed, which can ensure the timeliness of the historical second output result, and further improve the determination accuracy of the second loss function, which is beneficial to improving the classification accuracy of the first image classification network.

[0020] In a possible implementation, the first output result of the current round of training includes a first feature of each sample image of the current round of training and a first predicted probability distribution of each sample image of the current round of training, wherein the first predicted probability distribution represents the distribution of the probability that each sample image belongs to each category of a plurality of preset categories;

[0021] The determining of the first loss of a preset first loss function based on the first output result of the current round of training and the true category label corresponding to each sample image includes:

[0022] Based on the first predicted probability distribution of each sample image in the current round of training and the true category label corresponding to each sample image in the current round of training, the first loss of the first loss function is determined.

[0023] In this implementation, the first loss of the first loss function is determined by the first predicted probability distribution of each sample image and the true category label corresponding to each sample image, which can improve the determination accuracy of the first loss, thereby helping to improve the image classification accuracy of the first image classification network.

[0024] In a possible implementation, the historical second output result includes the second feature of each sample image obtained in at least one round of historical training;

[0025] The determining, based on the first output result of the current round of training and the historical second output result, the second loss of the preset second loss function comprises:

[0026] Based on the first feature of each sample image in the current round of training and the second feature of each sample image obtained in at least one round of historical training, the second loss of the second loss function is determined.

[0027] In this embodiment, the second loss of the second loss function is determined by using the first feature of each sample image and the second feature of each sample image obtained in at least one round of historical training. This can improve the accuracy of determining the second loss, which in turn helps to improve the image classification accuracy of the first image classification network.

[0028] In a possible implementation, the first output result of the current round of training includes a first predicted probability distribution of each image of the current round of training, the second output result of the current round of training includes a second feature of each sample image of the current round of training, the historical second output result includes a second feature of each sample image output by the second image classification network in at least one historical round of training and a second predicted probability distribution of each sample image, wherein the second predicted probability distribution represents the distribution of the probability that each sample image belongs to each of a plurality of preset categories;

[0029] The generating of the virtual category label of the image sample set in the current round of training based on the second output result of the current round of training and the historical second output result includes:

[0030] For each sample image in the current round of training, determine the similarity distribution between the second feature of the image sample in the current round of training and the second feature of each sample image in the historical second output result;

[0031] Based on the similarity distribution, weighted processing is performed on the second probability distribution of each sample image in the second historical output result to obtain a virtual category label of the image sample of the current round of training;

[0032] The determining of the third loss of the preset third loss function based on the difference between the first output result of the current round of training and the virtual category label includes:

[0033] Based on the virtual category label of each sample image in the current round of training and the first predicted probability distribution of each sample image in the current round of training, the third loss of the third function is determined.

[0034] In the disclosed embodiment, during the training of the first image classification network, the first predicted probability distribution of similar image samples is constrained by a third loss function, so that similar image samples predict similar probability distributions, and the features of similar samples can be further learned more compactly, thereby improving the image classification capability of the first image classification network.

[0035] In a possible implementation, before determining the second loss of a preset second loss function based on the first output result of the current round of training and the historical second output result, the method further includes:

[0036] The historical second output result is read from the cache, wherein the number of second features included in the historical second output result in the cache is a fixed value, so that the classification efficiency of the network can be improved while ensuring the classification accuracy of the first image classification network.

[0037] In a possible implementation, when the number of second features contained in the cache is less than the fixed value, the second output result obtained in the current round of training is added to the cache; or

[0038] When the number of second features contained in the cache is not less than the fixed value, the historical second output result with the earliest entry time in the cache is deleted, and the second output result obtained in the current round of training is added to the cache. In this way, the number of second features in the historical second output results can be maintained at the fixed value and kept timely, which is conducive to improving the image classification accuracy of the first image classification network.

[0039] The present disclosure provides an image classification method, including:

[0040] Get the image to be classified;

[0041] The image to be classified is input into an image classification network to obtain a classification result; the image classification network is obtained by the method described in any of the above embodiments.

[0042] The present disclosure provides a device for generating an image classification network, including:

[0043] A sample acquisition module is used to acquire, in each round of training, a set of image samples for the current round of training; the image sample set includes at least two sample images, each of which is annotated with a true category label of the sample image;

[0044] A result detection module is used to input the image sample set into a first image classification network and a second image classification network respectively, to obtain a first output result output by the first image classification network in this round of training and a second output result output by the second image classification network, wherein the second image classification network is obtained based on the first image classification network after adjusting parameters obtained in at least one round of training that has been completed;

[0045] A first determination module, used to determine a first loss of a preset first loss function based on a first output result obtained in this round of training and a true category label corresponding to each sample image;

[0046] A second determination module is used to determine a second loss of a preset second loss function based on the first output result of the current round of training and the historical second output result, wherein the second loss function represents the distance between the first output result and the sample image whose similarity is greater than a preset threshold in the historical second output result; the historical second output result includes the second output result obtained in at least one round of historical training before the current round of training;

[0047] A parameter adjustment module, configured to adjust parameters of the first image classification network based on the first loss and the second loss;

[0048] The iterative training module is used to repeat multiple rounds of the training to obtain a trained first image classification network.

[0049] In a possible implementation, the device further includes a label generation module and a third determination module, wherein the label generation module is configured to:

[0050] Generate a virtual category label for the image sample set in the current round of training based on the second output result of the current round of training and the historical second output result;

[0051] The third determination module is used for:

[0052] Determine a third loss of a preset third loss function based on a difference between the first output result of this round of training and the virtual category label;

[0053] The parameter adjustment module is specifically used for:

[0054] Parameters of the first image classification network are adjusted based on a weighted sum of the first loss, the second loss, and the third loss.

[0055] In a possible implementation, the second image classification network is obtained by performing sliding average on the first image classification network after adjusting parameters obtained in the at least one completed round of training.

[0056] In a possible implementation, the first output result of the current round of training includes a first feature of each sample image of the current round of training and a first predicted probability distribution of each sample image of the current round of training, wherein the first predicted probability distribution represents the distribution of the probability that each sample image belongs to each of the preset multiple categories; the first determination module is specifically used to:

[0057] Based on the first predicted probability distribution of each sample image in the current round of training and the true category label corresponding to each sample image in the current round of training, the first loss of the first loss function is determined.

[0058] In a possible implementation, the historical second output result includes the second feature of each sample image obtained in at least one round of historical training; and the second determination module is specifically configured to:

[0059] Based on the first feature of each sample image in the current round of training and the second feature of each sample image obtained in at least one round of historical training, the second loss of the second loss function is determined.

[0060] In a possible implementation, the first output result of the current round of training includes the first predicted probability distribution of each image of the current round of training, the second output result of the current round of training includes the second feature of each sample image of the current round of training, the historical second output result includes the second feature of each sample image output by the second image classification network in at least one historical round of training and the second predicted probability distribution of each sample image, the second predicted probability distribution characterizing the distribution of the probability that each sample image belongs to each of the preset multiple categories; the label generation module is specifically used to:

[0061] For each sample image in the current round of training, determine the similarity distribution between the second feature of the image sample in the current round of training and the second feature of each sample image in the historical second output result;

[0062] Based on the similarity distribution, weighted processing is performed on the second probability distribution of each sample image in the second historical output result to obtain a virtual category label of the image sample of the current round of training;

[0063] The third determination module is specifically used for:

[0064] Based on the virtual category label of each sample image in the current round of training and the first predicted probability distribution of each sample image in the current round of training, the third loss of the third function is determined.

[0065] In a possible implementation, the device further includes a result access module, and the result access module is used to:

[0066] The historical second output result is read from the cache, wherein the number of second features included in the historical second output result in the cache is a fixed value.

[0067] In a possible implementation manner, the result access module is further used to:

[0068] When the number of second features contained in the cache is less than the fixed value, adding the second output result obtained in the current round of training to the cache; or

[0069] When the number of second features contained in the cache is not less than the fixed value, the historical second output result with the earliest entry time in the cache is deleted, and the second output result obtained in the current round of training is added to the cache.

[0070] The present disclosure provides an image classification device, including:

[0071] An image acquisition module, used for acquiring images to be classified;

[0072] An image classification module is used to input the image to be classified into an image classification network to obtain a classification result; the image classification network is obtained by the method described in any of the above embodiments.

[0073] An embodiment of the present disclosure provides an electronic device, including: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the method for generating an image classification network as described in any of the aforementioned embodiments are performed, or the steps of the aforementioned image classification method are performed.

[0074] An embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the method for generating an image classification network as described in the first aspect and any of the aforementioned embodiments are executed, or the steps of the aforementioned image classification method are executed.

[0075] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0076] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following is a brief introduction to the drawings required for use in the embodiments. The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used together with the specification to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can also be obtained based on these drawings without creative work.

[0077] Figure 1 A flow chart of a method for generating an image classification network provided by an embodiment of the present disclosure is shown;

[0078] Figure 2 A schematic diagram showing a process of zooming in an image sample provided by an embodiment of the present disclosure is shown;

[0079] Figure 3 A flowchart of another method for generating an image classification network provided by an embodiment of the present disclosure is shown;

[0080] Figure 4 A flowchart of an image classification method provided by an embodiment of the present disclosure is shown;

[0081] Figure 5 A schematic diagram of the structure of a device for generating an image classification network provided by an embodiment of the present disclosure is shown;

[0082] Figure 6A schematic diagram showing the structure of another device for generating an image classification network provided by an embodiment of the present disclosure is shown;

[0083] Figure 7 A schematic diagram of the structure of an image classification device provided by an embodiment of the present disclosure is shown;

[0084] Figure 8 A schematic diagram of an electronic device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0085] In order to make the purpose, technical scheme and advantages of the embodiments of the present disclosure clearer, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the present disclosure for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present disclosure.

[0086] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0087] The term "and / or" herein only describes an association relationship, indicating that three relationships may exist. For example, A and / or B may represent the following three situations: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C may represent including any one or more elements selected from the set consisting of A, B, and C.

[0088] First, the relevant terms involved in the embodiments of the present application are introduced and explained:

[0089] 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.

[0090] 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.

[0091] Computer vision technology (CV) is a science that studies how to make machines "see". To be more specific, it refers to the use of cameras and computers to replace human eyes to identify, track and measure targets, and further perform image processing to make computer processing into images that are more suitable for human eye observation or transmission to instruments for detection. As a scientific discipline, computer vision studies related theories and technologies, and attempts to establish an artificial intelligence system that can obtain information from images or multi-dimensional data. Computer vision technology usually includes image processing, image recognition, image semantic understanding, image retrieval, optical character recognition (OCR), video processing, video semantic understanding, video content / behavior recognition, three-dimensional object reconstruction, 3D technology, virtual reality, augmented reality, simultaneous positioning and mapping, and other technologies, as well as common biometric recognition technologies such as face recognition and fingerprint recognition.

[0092] Machine Learning (ML) is a multi-disciplinary subject that involves probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other disciplines. It specializes in studying how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all areas of artificial intelligence. Machine learning and deep learning usually include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning and other technologies.

[0093] Among them, image classification is considered to be the most basic task in computer vision. Various downstream tasks are usually performed based on the results of image classification, such as object detection, video analysis, or semantic segmentation. Therefore, how to improve the accuracy of image classification is particularly important.

[0094] Research has found that the traditional image classification model aims to "pull" the features of similar image samples toward their corresponding class center vectors, that is, to reduce the distance between the features of similar image samples and the corresponding class center vectors; and to "push" the features of image samples away from their different class vectors, that is, to increase the distance between the features of image samples and the class center vectors of different classes. In addition, contrastive learning has achieved great success in the field of unsupervised learning. In related technologies, contrastive learning is also applied to supervised fields. It differs from traditional image classification in that it directly pulls the features of similar image samples closer, pushes away image samples of different classes, and has no class center vector. Although the above methods can improve the classification accuracy of image classification models, the results are not ideal.

[0095] Based on the above research, the present disclosure provides a method for generating an image classification network, which may include the following steps:

[0096] In each round of training, an image sample set for this round of training is obtained; the image sample set includes at least two sample images, and each of the sample images is annotated with a true category label of each sample image;

[0097] Inputting the image sample set into a first image classification network and a second image classification network respectively, obtaining a first output result output by the first image classification network in this round of training and a second output result output by the second image classification network, wherein the second image classification network is obtained based on the first image classification network after adjusting parameters obtained in at least one round of completed training;

[0098] Determine a first loss of a preset first loss function based on a first output result obtained in this round of training and a true category label corresponding to each sample image;

[0099] Based on the first output result of the current round of training and the historical second output result, determining a second loss of a preset second loss function, wherein the second loss function represents the distance between the first output result and the sample image whose similarity is greater than a preset threshold in the historical second output result; the historical second output result includes the second output result obtained in at least one round of historical training before the current round of training;

[0100] Adjusting parameters of the first image classification network based on the first loss and the second loss;

[0101] Repeat multiple rounds of the training to obtain a trained first image classification network.

[0102] The method for generating an image classification network provided by the embodiment of the present disclosure adjusts the network parameters according to the first loss function and the second loss function at the same time, that is, the network training is performed by combining the traditional class center vector with contrast learning. This can not only shorten the distance between image samples of the same type, but also shorten the distance between image samples of the same type while shortening more similar image samples of the same type. In this way, the goal of making features of the same type more compact can be achieved, which is beneficial to improving the image classification accuracy of the image classification network.

[0103] The following is a detailed introduction to the method for generating an image classification network provided by an embodiment of the present disclosure. The method for generating an image classification network can be applied to a terminal device, or can be applied to a server, or can be applied to an implementation environment composed of a terminal device and a server. In addition, the method for generating an image classification network can also be software running in a terminal device or a server, such as an application with a network training function.

[0104] Among them, the terminal device can be a mobile device, a user terminal, a terminal, a vehicle-mounted device, a computing device, a wearable device, etc. The server can be an independent physical server, or a server cluster or a distributed system composed of multiple physical servers, or 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, CDN, and big data and artificial intelligence platforms. In some possible implementations, the method for generating an image classification network can be implemented by a processor calling computer-readable instructions stored in a memory.

[0105] See also Figure 1 As shown, it is a flowchart of a method for generating an image classification network provided by an embodiment of the present disclosure, and the method for generating an image classification network includes the following S101 to S106:

[0106] S101, in each round of training, obtaining an image sample set for this round of training; the image sample set includes at least two sample images, and each of the sample images is annotated with a true category label of the sample image.

[0107] The method for generating an image classification network in the disclosed embodiment is a supervised contrastive learning method, so each sample image is annotated with a true category label. In one embodiment, the true category label is a vector matrix, for example, [0,0,0,1,0,0], which can also be called a hard label, that is, the value of one dimension is 1, and the values ​​of the other dimensions are all 0.

[0108] It can be understood that multiple trainings are usually performed during the neural network training process, wherein one training session refers to the process in which the neural network to be trained learns all the image samples once. For example, a large number of image samples can be prepared in advance before the network training, and the large number of image samples can be divided into multiple image sample sets. In each round of training, one image sample set (also called a batch) is input into the network to be trained for training. After multiple image sample sets are input into the network to be trained, one training session is completed.

[0109] For example, if the large number of image samples has a total of 1.281 million image samples, and 1024 images are used as one image sample set, then they can be divided into 1251 (128.1w / 1024) image sample sets, that is, they need to be trained in 1251 rounds, and the 1251 rounds of training correspond to one training, that is, one training iteration is 1251 rounds. Of course, the numbers in this example are only schematic, and are only used to explain the training in this application. It can be understood that in other embodiments, the size of the training set and the number of iterations of the training can be set accordingly according to the actual situation, and no specific limitation is made here.

[0110] S102, inputting the image sample set into a first image classification network and a second image classification network respectively, obtaining a first output result output by the first image classification network in this round of training and a second output result output by the second image classification network, wherein the second image classification network is obtained based on the first image classification network after adjusting parameters obtained in at least one completed round of training.

[0111] The first image classification network is used to extract features from image samples and predict the probability distribution corresponding to the features based on the extracted features. Similarly, the second image classification network is also used to extract features from image samples and predict the probability part corresponding to the features based on the extracted features. The first image classification network is different from the second image classification network, and the output result of the first image classification network and the output result of the second image classification network are distinguished by "first" and "second". Therefore, the first output result includes the first feature of each sample image and the first predicted probability distribution of each picture, and the second output result includes the second feature of each sample image and the second predicted probability distribution of each picture. The first predicted probability distribution represents the distribution of the probability that each sample image belongs to each of the preset multiple categories, and the second predicted probability distribution also represents the distribution of the probability that each sample image belongs to each of the preset multiple categories.

[0112] Of course, in other embodiments, the first output result and the second output result may also only include the features of the image samples or the predicted probability distribution. Specifically, the content included in the output result may be determined according to the actual application situation.

[0113] Optionally, since the second image classification network and the first image classification network perform feature extraction and predict probability distribution in a similar principle, the first image classification network is taken as an example for detailed description below.

[0114] For each sample image, after the image sample is input into the first image classification network, the image sample can be encoded by the convolution encoder of the first image classification network to obtain a first feature; then the first feature is multiplied with the class center feature of the first image classification network to obtain a first operation result, and then the first operation result is normalized to obtain a first predicted probability distribution of the image sample. Specifically, the first predicted probability distribution can be obtained by a softmax function. The first predicted probability distribution is used to indicate the probability corresponding to the image sample belonging to each class center.

[0115] In the disclosed embodiment, after obtaining the second output result, the second output result needs to be cached. In this way, as the number of training rounds is iterated, the second output result of multiple rounds of historical training can be obtained for use in subsequent training to determine the second loss of the second loss function. The specific content of the historical second output result will be elaborated in detail later.

[0116] Exemplarily, the second image classification network is obtained based on the first image classification network, which means that there is a preset association relationship between the second image classification network and the first image classification network, and the second image classification network is used to assist in training the first image classification network. Optionally, the first image classification network can also be called a student network, which is also a network for online training, and the second image classification network can be called a teacher network.

[0117] In some embodiments, the second image classification network can be obtained by performing a sliding average on the first image classification network after adjusting parameters obtained from at least one round of training. The sliding average is also an exponentially weighted average, which can be used to estimate the local mean of the variable so that the update of the variable is related to the historical value within a period of time.

[0118] Specifically, the sliding average can be implemented by the following formula (1).

[0119]

[0120] Among them, F t represents the second image classification network, F srepresents the first image classification network, m is a coefficient, and is usually close to 1, such as 0.99999. That is, the second image classification network is obtained by accumulating and iterating the first image classification network at a slower speed, which can enhance the timeliness of the historical second output result, make the second feature in the historical second output result relevant, and thus improve the effectiveness of the second loss function.

[0121] S103, determining a first loss of a preset first loss function based on the first output result obtained in this round of training and the true category label corresponding to each sample image.

[0122] Exemplarily, the first loss of the first loss function can be determined based on the first predicted probability distribution of each sample image in the current round of training and the true category label corresponding to each sample image in the current training. That is, the first loss function is used to characterize the distance between the first predicted probability distribution and the true category label.

[0123] Specifically, for each sample image, the first loss of the first loss function can be determined based on the first predicted probability distribution of the image sample and the true category label corresponding to the image sample. After obtaining the first loss of each image sample, the mean of the first losses of each image sample can be determined to obtain the first loss of the first loss function.

[0124] Optionally, the first loss function may be a cross entropy loss function. Optionally, the first loss function may also be a relative entropy loss function, which is not limited here.

[0125] S104, based on the first output result of this round of training and the historical second output result, determine the second loss of a preset second loss function, wherein the second loss function represents the distance between the first output result and the sample image in the historical second output result whose similarity is greater than a preset threshold; the historical second output result includes the second output result obtained in at least one round of historical training before the current round of training.

[0126] Exemplarily, since the historical second output result is obtained by caching the second output result of at least one round of previous training, the historical second output result includes the second feature of each sample image under at least one round of historical training and the second predicted probability distribution of each sample image under at least one round of historical training. For example, if the current round of training is the fifth round of training, the historical second output result can be a collection of the second output results of at least one round of training output in the previous four rounds of training.

[0127] It can be understood that if the number of second features of each sample image in the historical second output result is too small, there may be no similar samples in the current round of training and the historical round of training, which will cause the loss value of the loss function to be inaccurate and reduce the reference value. If the number of second features of each sample image in the historical second output result is too large, it will take up more memory, thereby affecting the efficiency of training. Therefore, in some embodiments, before determining the second loss of the preset second loss function based on the first output result of the current round of training and the historical second output result, the method also includes: reading the historical second output result from the cache, wherein the number of second features contained in the historical second output result in the cache is a fixed value. Optionally, the fixed value is greater than the first preset number and less than the second preset number. In this way, the classification efficiency can be improved while facilitating the improvement of the classification accuracy of the first image classification network.

[0128] It should be noted that, since the output result of each sample image corresponds to a feature and a predicted probability distribution, the number of the second predicted probability distribution of each sample image in the historical second output result is the same as the second feature.

[0129] Exemplarily, when the number of second features contained in the cache is less than the fixed value, the method further includes: adding the second output result obtained in the current round of training to the cache.

[0130] However, as the number of training rounds iterates, if the second output results obtained in each round of training are saved, the content of the historical second output results will become increasingly large, and the cache and calculation load will be relatively large. In some embodiments, in order to maintain the number of second features in the historical second output results at the fixed value and maintain timeliness, the method further includes: when the number of second features contained in the cache is not less than the fixed value, deleting the historical second output result with the earliest entry time in the cache, and adding the second output result obtained in this round of training to the cache, that is, the second output results in the cache implement the first-in-first-out principle.

[0131] Exemplarily, in combination with the above-mentioned explanation of each round of training including 1024 image samples, if a fixed value of 65536 is used as an example, then when the number of training theories reaches the 64th round, 65536 (64*1024) features are reached. In the 65th round of training, the second output result obtained in the 65th round of training replaces the second output result obtained in the 1st round of training, and the second output result obtained in the 66th round of training replaces the second output result in the 2nd round of training, and so on, until the end of training. Therefore, the method for generating an image classification network in the embodiment of the present disclosure can be executed starting from the Nth round of training during the first training process, where the specific number of N needs to be determined based on the number of image samples in each round of training and the preset number of preset historical second output results.

[0132] In one embodiment, the second loss of a preset second loss function is determined based on the first output result of the current training and the historical second output result, including: determining the second loss of the second loss function based on the first feature of each sample image of the current round of training and the second feature of each sample image obtained in at least one round of historical training.

[0133] Specifically, for each sample image in this round of training, a dot multiplication operation can be performed on the first feature of each sample image and the second feature of each sample image obtained in at least one round of historical training to obtain a second loss for each sample image, and then the second losses of each image sample in this round of training are averaged to obtain the second loss of the second loss function.

[0134] For example, the formula of the second loss function can be shown in the following formula (2):

[0135]

[0136] in, The second loss characterizing the second loss function, log is the logarithmic function, exp is the exponential function with the natural constant e as the base, Z i is the image sample feature, Pos(i) is the sample feature set of the same type, Neg(i) is the sample feature set of different types, Z p is the sample feature of the same type as the sample image in the second historical output result, Z n is the sample feature of the second output result in history that is different from the sample pattern feature, T sup is the temperature parameter that controls the sharpness of the distribution.

[0137] It should be noted that, since temperature parameters usually have commonly used parameters, in this embodiment, the temperature parameters are not discussed in detail.

[0138] S105: Adjust parameters of the first image classification network based on the first loss and the second loss.

[0139] For example, after obtaining the first loss and the second loss, the parameters of the first image classification network can be adjusted according to the first loss and the second loss, so that the next round of training can be continued based on the first image classification network after adjusting the parameters. It can be understood that after each round of parameter adjustment, the performance of the first image classification network will converge in the direction of the loss function constraint.

[0140] S106, repeating multiple rounds of the training to obtain a trained first image classification network.

[0141] Exemplarily, as described above, by continuously iteratively training the first image classification network, the performance of the first image classification network will become stronger and stronger. Therefore, after repeating multiple rounds of the training, if the training results meet the preset requirements, the training can be stopped to obtain a trained first image classification network.

[0142] Among them, the total number of training times (such as 120,000 times) or the number of training rounds can be preset, and when the number of training times reaches the preset total number of training times or the number of training rounds reaches the preset total number of rounds, it is determined that the training result meets the preset requirements. Optionally, it is also possible to determine that the training result meets the preset requirements when the loss values ​​of the preset first loss function and the second loss function (i.e., the above-mentioned first loss and second loss) respectively reach the corresponding preset thresholds.

[0143] See also Figure 2 As shown, the method for generating an image classification network provided by the embodiment of the present disclosure adjusts the network parameters according to the first loss function and the second loss function at the same time, that is, the network training is performed by combining the traditional class center vector with contrast learning. This can not only shorten the distance between image samples of the same type, but also shorten the distance between image samples of the same type while shortening more similar image samples of the same type (such as 11 and 12 or 21 and 22). In this way, the goal of making similar features more compact can be achieved, which is beneficial to improving the image classification accuracy of the first image classification network.

[0144] To further improve the classification ability of the first image classification network, see Figure 3 As shown, the embodiment of the present disclosure also provides another method for generating an image classification network, including the following S301-S208:

[0145] S301, in each round of training, obtaining an image sample set for this round of training; the image sample set includes at least two sample images, and each of the sample images is annotated with a true category label of the sample image.

[0146] This step is similar to the aforementioned step S101 and will not be described again here.

[0147] S302, inputting the image sample set into a first image classification network and a second image classification network respectively, obtaining a first output result output by the first image classification network in this round of training and a second output result output by the second image classification network, wherein the second image classification network is obtained based on the first image classification network after adjusting parameters obtained in at least one completed round of training.

[0148] This step is similar to the aforementioned step S102 and will not be described again here.

[0149] S303: Determine a first loss of a preset first loss function based on the first output result obtained in this round of training and the true category label corresponding to each sample image.

[0150] This step is similar to the aforementioned step S103 and will not be described again here.

[0151] S304, based on the first output result of this round of training and the historical second output result, determine the second loss of a preset second loss function, wherein the second loss function represents the distance between the first output result and the sample image in the historical second output result whose similarity is greater than a preset threshold; the historical second output result includes the second output result obtained in at least one round of historical training before the current round of training.

[0152] This step is similar to the aforementioned step S104 and will not be described again here.

[0153] S305: Generate a virtual category label for the image sample set in the current round of training based on the second output result of the current round of training and the historical second output result.

[0154] Exemplarily, when generating the virtual category label of the image sample set in the current round of training based on the second output result of the current round of training and the historical second output result, the following (a) to (b) may be included:

[0155] (a) For each sample image in the current round of training, determine the similarity distribution between the second feature of the image sample in the current round of training and the second feature of each sample image in the historical second output result.

[0156] (b) Based on the similarity distribution, the second probability distribution of each sample image in the second historical output result is weighted to obtain the virtual category label of the image sample in the current round of training. Specifically, for each sample image in this training, the second feature of the image sample is multiplied by the second feature in the second historical output result to obtain the second operation result, and the similarity is calculated by a normalization function (softmax function), and then the second predicted probability distribution in the second historical output result is weighted by the similarity to obtain the virtual category label (also called soft label) of the image sample.

[0157] The form of the virtual category label is similar to that of the real category label mentioned above. The difference is that the virtual category label is a multidimensional data. Each dimension corresponds to a category, and the data of each dimension represents the probability value of the corresponding category. The data of one dimension in the virtual category label is large, representing the highest probability value of the category corresponding to the dimension, and the data of other dimensions are small and not all 0.

[0158] S306: Determine a third loss of a preset third loss function based on the difference between the first output result of this round of training and the virtual category label.

[0159] Specifically, the third loss of the third function can be determined based on the virtual category label of each sample image in the current round of training and the first predicted probability distribution of each sample image. That is, the third loss corresponding to the image sample can be determined based on the virtual category label of each sample image and the first predicted probability distribution of each sample image, and then the third losses corresponding to each sample image are averaged to obtain the third loss of the third function.

[0160] The third loss function is used to reduce the distance between the virtual category label of each sample image and the first predicted probability distribution. Optionally, the third loss function is a relative entropy loss function (also known as KL divergence) or a cross entropy loss function, which is not limited here.

[0161] S307: Adjust parameters of the first image classification network based on a weighted sum of the first loss, the second loss, and the third loss.

[0162] This step is different from the aforementioned step S105 in that parameters of the first image classification network are adjusted based on the first loss, the second loss and the third loss. Optionally, parameters of the first image classification network can be adjusted based on the weighted sum of the first loss, the second loss and the third loss, that is, the first image classification network is adjusted based on the losses of the three loss functions.

[0163] S308, repeat multiple rounds of the training to obtain a trained first image classification network.

[0164] This step is similar to the aforementioned step S106 and will not be described again here.

[0165] In the disclosed embodiment, during the training of the first image classification network, the first predicted probability distribution of similar image samples is constrained by a third loss function so that similar image samples predict similar probability distributions. That is, the features of similar samples are learned more compactly through distribution consistency regularization, which is further beneficial to improving the classification performance of the first image classification network.

[0166] See also Figure 4 As shown, in some implementations, an image classification method is also provided, and the image classification method includes the following S401-402:

[0167] S401, obtaining an image to be classified.

[0168] Exemplarily, the image may be an image captured by a camera device, or may be video data captured by a camera device and an image frame obtained by decoding the video data.

[0169] Among them, the images to be classified can be images in any scene, for example, images in an autonomous driving scene. By classifying the images in this scene, the environmental objects around the car can be determined. They can also be images in an autonomous mobile robot scene. For example, by classifying images taken by a household robot, the categories of objects in the robot's environment can be determined.

[0170] S402, inputting the image to be classified into an image classification network to obtain a classification result; the image classification network is obtained by the method for generating an image classification network described in any of the aforementioned embodiments.

[0171] The image classification network is also the first image classification network trained in the aforementioned embodiment, so that the accuracy of the classification result of the image to be classified can be improved.

[0172] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.

[0173] Based on the same technical concept, the embodiments of the present disclosure also provide a device for generating an image classification network corresponding to the method for generating an image classification network. Since the principle of solving the problem by the device in the embodiments of the present disclosure is similar to the method for generating an image classification network in the embodiments of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0174] Reference Figure 5 FIG. 5 is a schematic diagram of a device 500 for generating an image classification network provided by an embodiment of the present disclosure. The device 500 for generating an image classification network includes:

[0175] The sample acquisition module 501 is used to acquire, in each round of training, a set of image samples for the current round of training; the image sample set includes at least two sample images, each of which is annotated with a true category label of the sample image;

[0176] A result detection module 502 is used to input the image sample set into a first image classification network and a second image classification network respectively, to obtain a first output result output by the first image classification network in this round of training and a second output result output by the second image classification network, wherein the second image classification network is obtained based on the first image classification network after adjusting parameters obtained in at least one round of training that has been completed;

[0177] A first determination module 503 is used to determine a first loss of a preset first loss function based on a first output result obtained in this round of training and a true category label corresponding to each sample image;

[0178] A second determination module 504 is used to determine a second loss of a preset second loss function based on the first output result of the current round of training and the historical second output result, wherein the second loss function represents the distance between the first output result and the sample image whose similarity is greater than a preset threshold in the historical second output result; the historical second output result includes the second output result obtained in at least one round of historical training before the current round of training;

[0179] A parameter adjustment module 505, configured to adjust parameters of the first image classification network based on the first loss and the second loss;

[0180] The iterative training module 506 is used to repeat multiple rounds of the training to obtain a trained first image classification network.

[0181] In one possible implementation, see Figure 6 As shown, the apparatus further includes a label generation module 507 and a third determination module 508, wherein the label generation module 507 is used to:

[0182] Generate a virtual category label for the image sample set in the current round of training based on the second output result of the current round of training and the historical second output result;

[0183] The third determination module 508 is used for:

[0184] Determine a third loss of a preset third loss function based on a difference between the first output result of this round of training and the virtual category label;

[0185] The parameter adjustment module 505 is specifically used for:

[0186] Parameters of the first image classification network are adjusted based on a weighted sum of the first loss, the second loss, and the third loss.

[0187] In a possible implementation, the second image classification network is obtained by performing sliding average on the first image classification network after adjusting parameters obtained in the at least one completed round of training.

[0188] In a possible implementation, the first output result of the current round of training includes a first feature of each sample image of the current round of training and a first predicted probability distribution of each sample image of the current round of training, wherein the first predicted probability distribution represents the distribution of the probability that each sample image belongs to each of the preset multiple categories; the first determination module 503 is specifically used to:

[0189] Based on the first predicted probability distribution of each sample image in the current round of training and the true category label corresponding to each sample image in the current round of training, the first loss of the first loss function is determined.

[0190] In a possible implementation, the historical second output result includes the second feature of each sample image obtained in at least one round of historical training; the second determination module 504 is specifically used to:

[0191] Based on the first feature of each sample image in the current round of training and the second feature of each sample image in at least one historical training, the second loss of the second loss function is determined.

[0192] In a possible implementation, the first output result of the current round of training includes the first predicted probability distribution of each image of the current round of training, the second output result of the current round of training includes the second feature of each sample image of the current round of training, the historical second output result includes the second feature of each sample image output by the second image classification network in at least one historical round of training and the second predicted probability distribution of each sample image, the second predicted probability distribution characterizing the distribution of the probability that each sample image belongs to each category of the preset multiple categories; the label generation module 507 is specifically used to:

[0193] For each sample image in the current round of training, determine the similarity distribution between the second feature of the image sample in the current round of training and the second feature of each sample image in the historical second output result;

[0194] Based on the similarity distribution, weighted processing is performed on the second probability distribution of each sample image in the second historical output result to obtain a virtual category label of the image sample of the current round of training;

[0195] The third determination module 508 is specifically used for:

[0196] Based on the virtual category label of each sample image in the current round of training and the first predicted probability distribution of each sample image in the current round of training, the third loss of the third function is determined.

[0197] In a possible implementation, the apparatus further includes a result access module 509, and the result access module 509 is used to:

[0198] The historical second output result is read from the cache, wherein the number of second features included in the historical second output result in the cache is a fixed value.

[0199] In a possible implementation, the result access module 509 is further used to:

[0200] When the number of second features contained in the cache is less than the fixed value, adding the second output result obtained in the current round of training to the cache; or

[0201] When the number of second features contained in the cache is not less than the fixed value, the historical second output result with the earliest entry time in the cache is deleted, and the second output result obtained in the current round of training is added to the cache.

[0202] See also Figure 7 As shown, the embodiment of the present disclosure provides an image classification device 700, including:

[0203] An image acquisition module 701 is used to acquire an image to be classified;

[0204] The image classification module 702 is used to input the image to be classified into an image classification network to obtain a classification result; the image classification network is obtained by the method described in any of the above embodiments.

[0205] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.

[0206] Based on the same technical concept, the embodiment of the present disclosure also provides an electronic device. Figure 8 , which is a schematic diagram of the structure of an electronic device 800 provided in an embodiment of the present disclosure, including a processor 801, a memory 802, and a bus 803. The memory 802 is used to store execution instructions, including a memory 8021 and an external memory 8022; the memory 8021 is also called an internal memory, which is used to temporarily store the operation data in the processor 801 and the data exchanged with the external memory 8022 such as a hard disk. The processor 801 exchanges data with the external memory 8022 through the memory 8021.

[0207] In the embodiment of the present application, the memory 802 is specifically used to store the application code for executing the solution of the present application, and the execution is controlled by the processor 801. That is, when the electronic device 800 is running, the processor 801 communicates with the memory 802 through the bus 803, so that the processor 801 executes the application code stored in the memory 802, and then executes the method described in any of the above embodiments.

[0208] Among them, the memory 802 can be, but is not limited to, random access memory (Random Access Memory, RAM), read only memory (Read Only Memory, ROM), programmable read-only memory (Programmable Read-Only Memory, PROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, EPROM), electrically erasable read-only memory (Electric Erasable Programmable Read-Only Memory, EEPROM), etc.

[0209] The processor 801 may be an integrated circuit chip with signal processing capabilities. The above-mentioned processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The disclosed methods, steps and logic block diagrams in the embodiments of the present invention may be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0210] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 800. In other embodiments of the present application, the electronic device 800 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0211] The present disclosure also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the method for generating an image classification network in the above method embodiment are executed. The storage medium may be a volatile or non-volatile computer-readable storage medium.

[0212] The embodiments of the present disclosure also provide a computer program product, which carries a program code. The instructions included in the program code can be used to execute the steps of the method for generating an image classification network in the above method embodiment. For details, please refer to the above method embodiment, which will not be repeated here.

[0213] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is implemented as a computer storage medium. In another optional embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).

[0214] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.

[0215] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0216] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0217] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory, a random access memory, a magnetic disk or an optical disk.

[0218] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.

Claims

1. A method for generating an image classification network, characterized in that: include: In each round of training, an image sample set for this round of training is obtained; the image sample set includes at least two sample images, and each of the sample images is annotated with a true category label of each sample image; Inputting the image sample set into a first image classification network and a second image classification network respectively, obtaining a first output result output by the first image classification network in this round of training and a second output result output by the second image classification network, wherein the second image classification network is obtained based on the first image classification network after adjusting parameters obtained in at least one round of completed training; Determine a first loss of a preset first loss function based on a first output result obtained in this round of training and a true category label corresponding to each sample image; Based on the first output result of the current round of training and the historical second output result, determining a second loss of a preset second loss function, wherein the second loss function represents the distance between the first output result and the sample image whose similarity is greater than a preset threshold in the historical second output result; the historical second output result includes the second output result obtained in at least one round of historical training before the current round of training; Adjusting parameters of the first image classification network based on the first loss and the second loss; Repeat multiple rounds of the training to obtain a trained first image classification network.

2. The method according to claim 1, characterized in that Before adjusting the parameters of the first image classification network based on the first loss and the second loss, the method further includes: Generate a virtual category label for the image sample set in the current round of training based on the second output result of the current round of training and the historical second output result; Determine a third loss of a preset third loss function based on a difference between the first output result of this round of training and the virtual category label; The step of adjusting parameters of the first image classification network based on the first loss and the second loss includes: Parameters of the first image classification network are adjusted based on a weighted sum of the first loss, the second loss, and the third loss.

3. The method according to claim 1 or 2, characterized in that: The second image classification network is obtained by performing sliding average on the first image classification network after adjusting parameters obtained in at least one completed round of training.

4. The method according to claim 1, characterized in that: The first output result of the current round of training includes a first feature of each sample image of the current round of training and a first predicted probability distribution of each sample image of the current round of training, wherein the first predicted probability distribution represents a distribution of probabilities that each sample image belongs to each of a plurality of preset categories; The determining of the first loss of a preset first loss function based on the first output result of the current round of training and the true category label corresponding to each sample image includes: Based on the first predicted probability distribution of each sample image in the current round of training and the true category label corresponding to each sample image in the current round of training, the first loss of the first loss function is determined.

5. The method according to claim 4, characterized in that The historical second output result includes the second feature of each sample image obtained in at least one round of historical training; The determining, based on the first output result of the current round of training and the historical second output result, the second loss of the preset second loss function comprises: Based on the first feature of each sample image in the current round of training and the second feature of each sample image obtained in at least one round of historical training, the second loss of the second loss function is determined.

6. The method according to claim 2, characterized in that The first output result of the current round of training includes a first predicted probability distribution of each image of the current round of training, the second output result of the current round of training includes a second feature of each sample image of the current round of training, the historical second output result includes a second feature of each sample image output by the second image classification network in at least one historical round of training and a second predicted probability distribution of each sample image, wherein the second predicted probability distribution represents the distribution of the probability that each sample image belongs to each of a plurality of preset categories; The generating of the virtual category label of the image sample set in the current round of training based on the second output result of the current round of training and the historical second output result includes: For each sample image in the current round of training, determine the similarity distribution between the second feature of the image sample in the current round of training and the second feature of each sample image in the historical second output result; Based on the similarity distribution, weighted processing is performed on the second probability distribution of each sample image in the second historical output result to obtain a virtual category label of the image sample of the current round of training; The determining of the third loss of the preset third loss function based on the difference between the first output result of the current round of training and the virtual category label includes: Based on the virtual category label of each sample image in the current round of training and the first predicted probability distribution of each sample image in the current round of training, the third loss of the third loss function is determined.

7. The method according to claim 5 or 6, characterized in that: Before determining the second loss of the preset second loss function based on the first output result of the current round of training and the historical second output result, the method further includes: The historical second output result is read from the cache, wherein the number of second features included in the historical second output result in the cache is a fixed value.

8. The method according to claim 7, characterized in that When the number of second features contained in the cache is less than the fixed value, adding the second output result obtained in the current round of training to the cache; or When the number of second features contained in the cache is not less than the fixed value, the historical second output result with the earliest entry time in the cache is deleted, and the second output result obtained in the current round of training is added to the cache.

9. An image classification method, characterized in that: include: Get the image to be classified; Inputting the image to be classified into an image classification network to obtain a classification result; The image classification network is obtained by the method according to any one of claims 1 to 8.

10. A device for generating an image classification network, characterized in that: The device comprises: A sample acquisition module is used to acquire, in each round of training, a set of image samples for the current round of training; the image sample set includes at least two sample images, each of which is annotated with a true category label of the sample image; A result detection module is used to input the image sample set into a first image classification network and a second image classification network respectively, to obtain a first output result output by the first image classification network in this round of training and a second output result output by the second image classification network, wherein the second image classification network is obtained based on the first image classification network after adjusting parameters obtained in at least one round of training that has been completed; A first determination module, used to determine a first loss of a preset first loss function based on a first output result obtained in this round of training and a true category label corresponding to each sample image; A second determination module is used to determine a second loss of a preset second loss function based on the first output result of the current round of training and the historical second output result, wherein the second loss function represents the distance between the first output result and the sample image whose similarity is greater than a preset threshold in the historical second output result; the historical second output result includes the second output result obtained in at least one round of historical training before the current round of training; A parameter adjustment module, configured to adjust parameters of the first image classification network based on the first loss and the second loss; The iterative training module is used to repeat multiple rounds of the training to obtain a trained first image classification network.

11. An image classification device, characterized in that: The device comprises: An image acquisition module, used for acquiring images to be classified; An image classification module is used to input the image to be classified into an image classification network to obtain a classification result; the image classification network is obtained by the method described in any one of claims 1-8.

12. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the method for generating an image classification network as described in any one of claims 1 to 8 and / or the steps of the image classification method as described in claim 9 are performed.

13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, executes the steps of the method for generating an image classification network as described in any one of claims 1 to 8, and / or the steps of the image classification method as described in claim 9.

Citation Information

Patent Citations

  • Neural network training method, image classification system and related equipment

    CN111797893A

  • Network training and face living body detection method and device, equipment and storage medium

    CN113011387A