Image recognition model training method and device, electronic equipment and storage medium

By performing tuple sampling and loss function optimization on the image recognition model, the generalization problem of existing models in image difference scenarios is solved, and the recognition accuracy and sensitivity are improved.

CN116994023BActive Publication Date: 2026-07-21TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
TENCENT TECHNOLOGY (SHENZHEN) CO LTD
Filing Date
2022-11-29
Publication Date
2026-07-21

AI Technical Summary

Technical Problem

Existing image recognition models struggle to adapt to the differences in images during actual deployment when training on small or long-tailed training sets, resulting in poor recognition accuracy and reliability, and affecting the model's generalization performance.

Method used

By performing tuple sampling on multiple sample images to obtain sample tuples, the model loss is determined using classification index data and category labels to measure the similarity and difference between sample images of the same and different categories, and the model is trained to reduce the distance between features of the same category and the distance between features of different categories, thereby reducing the dependence on binary label classification loss.

Benefits of technology

It significantly improves the accuracy of image recognition and the generalization performance of the model, especially in the recognition of difficult images, enhancing the classification accuracy and sensitivity of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116994023B_ABST
    Figure CN116994023B_ABST
Patent Text Reader

Abstract

The application provides an image recognition model training method and device, electronic equipment and storage medium, relates to the technical field of artificial intelligence, and the method comprises the following steps: acquiring a plurality of sample images and category labels of the sample images; performing multivariate group sampling on the plurality of sample images to obtain a plurality of sample multivariate groups; inputting each sample multivariate group into a preset recognition model to obtain classification index data of each sample image; based on the classification index data and the category labels, determining the model loss corresponding to each sample multivariate group respectively, the model loss is used to measure the similarity between the classification index data of the same category sample images in the sample multivariate group, the difference between the classification index data of the different category sample images, and the accuracy of the classification index data; training the preset recognition model based on the model loss to obtain a target image recognition model, which significantly improves the recognition accuracy and model generalization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, and in particular to an image recognition model training method, apparatus, electronic device, and storage medium. Background Technology

[0002] With the development of artificial intelligence technology, image recognition models are being applied in various fields, such as security, intelligent transportation, industrial inspection, and medical testing. Existing image recognition models, when performing classification tasks, typically rely on training constrained by manually generated binary labels. In scenarios with small or long-tailed training sets, the resulting models can fit the training dataset well. However, in actual deployments, for images that differ significantly from the training samples or for difficult images, the accuracy and reliability of image recognition are poor, affecting the model's generalization performance and application effectiveness. Summary of the Invention

[0003] This application provides an image recognition model training method, apparatus, device, and storage medium, which can significantly improve the recognition accuracy, reliability, and generalization of the image recognition model.

[0004] On the one hand, this application provides an image recognition model training method, the method comprising:

[0005] Obtain multiple sample images and their category labels;

[0006] Perform tuple sampling on the multiple sample images to obtain multiple sample tuples;

[0007] Each of the sample tuples is input into a preset recognition model to obtain the classification index data of each sample image in each sample tuple;

[0008] Based on the classification index data and the category labels, the model loss corresponding to each of the sample tuples is determined. The model loss is used to measure the similarity between the classification index data of sample images of the same category in the sample tuple, the difference between the classification index data of sample images of different categories in the sample tuple, and the accuracy of the classification index data.

[0009] The preset recognition model is trained based on the model loss to obtain the target image recognition model.

[0010] On the other hand, an image recognition model training device is provided, the device comprising:

[0011] Sample acquisition module: used to acquire multiple sample images and the category labels of the sample images;

[0012] Sample sampling module: used to perform tuple sampling on the multiple sample images to obtain multiple sample tuples;

[0013] Classification and recognition module: used to input each of the sample tuples into a preset recognition model to obtain classification index data for each sample image in each of the sample tuples;

[0014] Loss determination module: used to determine the model loss corresponding to each of the sample tuples based on the classification index data and the category labels. The model loss is used to measure the similarity between the classification index data of sample images of the same category in the sample tuple, the difference between the classification index data of sample images of different categories in the sample tuple, and the accuracy of the classification index data.

[0015] Model training module: used to train the preset recognition model based on the model loss to obtain the target image recognition model.

[0016] On the other hand, a computer device is provided, the device including a processor and a memory, the memory storing at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by the processor to implement the image recognition model training method as described above.

[0017] On the other hand, a computer-readable storage medium is provided, wherein at least one instruction or at least one program is stored therein, the at least one instruction or the at least one program being loaded and executed by a processor to implement the image recognition model training method as described above.

[0018] On the other hand, a server is provided, which includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by the processor to implement the image recognition model training method described above.

[0019] On the other hand, a terminal is provided, which includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded and executed by the processor to implement the image recognition model training method described above.

[0020] On the other hand, a computer program product or computer program is provided, which includes computer instructions that, when executed by a processor, implement the image recognition model training method as described above.

[0021] The image recognition model training method, apparatus, device, storage medium, server, terminal, computer program, and computer program product provided in this application have the following technical effects:

[0022] The technical solution of this application obtains multiple sample images and their category labels; performs tuple sampling on the multiple sample images to obtain a sample tuple input containing multiple sample images, and performs recognition processing on each sample tuple to obtain classification index data for each sample image in each sample tuple; then uses the classification index data and category labels as measurement parameters for model training, and determines the model loss corresponding to each sample tuple to measure the similarity between classification index data of sample images of the same category in the sample tuple, the difference between classification index data of sample images of different categories in the sample tuple, and the accuracy of classification index data. Based on the model loss, model training can be performed, which can guide model training with classification accuracy, similarity within the same category, and difference between different categories as training objectives. This reduces the intra-class feature distance of images of the same category and widens the feature distance between different categories while constraining classification, improves the distribution compactness of features of the same category, reduces the over-reliance on binary label classification loss in the training process, and thus significantly improves the accuracy of image recognition and the generalization performance of the model. Attached Figure Description

[0023] To more clearly illustrate the technical solutions and advantages in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0024] Figure 1 This is a schematic diagram of an application environment provided in an embodiment of this application;

[0025] Figure 2 This is a flowchart illustrating an image recognition model training method provided in an embodiment of this application;

[0026] Figure 3 This application provides a set of examples of normal industrial images and defective industrial images.

[0027] Figure 4 This is a flowchart illustrating another image recognition model training method provided in an embodiment of this application;

[0028] Figure 5 This is a flowchart illustrating another image recognition model training method provided in an embodiment of this application;

[0029] Figure 6 This is a schematic flowchart of an image recognition method provided in an embodiment of this application;

[0030] Figure 7 This is a schematic diagram illustrating the principle framework of image recognition model training provided in an embodiment of this application;

[0031] Figure 8 This is a schematic diagram illustrating the principle framework of an image recognition method provided in an embodiment of this application;

[0032] Figure 9 This is a schematic diagram of the framework of an image recognition model training device provided in an embodiment of this application;

[0033] Figure 10 This is a hardware structure block diagram of an electronic device for an image recognition model training method provided in an embodiment of this application. Detailed Implementation

[0034] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0035] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or server that comprises a series of steps or sub-modules is not necessarily limited to those steps or sub-modules explicitly listed, but may include other steps or sub-modules not explicitly listed or inherent to such processes, methods, products, or devices.

[0036] Before providing a further detailed description of the embodiments of this application, the nouns and terms involved in the embodiments of this application will be explained, and the nouns and terms involved in the embodiments of this application shall be interpreted as follows.

[0037] Artificial intelligence (AI) is the theory, methods, technology, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that attempts to understand the essence of intelligence and produce a new kind of intelligent machine that can react in a way similar to human intelligence. AI studies the design principles and implementation methods of various intelligent machines, enabling them to possess the functions of perception, reasoning, and decision-making.

[0038] Artificial intelligence (AI) is a comprehensive discipline encompassing a wide range of fields, including both hardware and software technologies. Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies primarily include computer vision, speech processing, natural language processing, and machine learning / deep learning.

[0039] Computer vision (CV) is the science that studies how to enable machines to "see." More specifically, it refers to machine vision, which uses cameras and computers to replace human eyes in recognizing and measuring targets, and then performs image processing to create images more suitable for human observation or transmission to instruments. As a scientific discipline, computer vision studies related theories and technologies, attempting to build artificial intelligence systems capable of extracting information from images or multidimensional data. Computer vision technologies typically include image processing, image recognition, image semantic understanding, image retrieval, OCR, video processing, video semantic understanding, video content / behavior recognition, 3D object reconstruction, 3D technology, virtual reality, augmented reality, simultaneous localization and mapping (SLAM), and common biometric recognition technologies such as facial recognition and fingerprint recognition.

[0040] In recent years, with the research and progress of artificial intelligence technology, computer vision technology has been increasingly widely used in cloud applications. For example, computer vision technology can be used to improve work efficiency in fields such as industrial defect detection, security guard systems, intelligent transportation, and target detection.

[0041] Taking industrial defect detection as an example, industrial defect detection refers to the quality inspection of industrial products during the manufacturing process. Traditional industrial inspection is generally carried out by inspection workers through manual visual inspection. In recent years, with the rise of AI technology, AI inspection based on machine vision can significantly improve the accuracy of inspection and save labor costs. The input of this technology is an image taken of the surface of the industrial product, and the output is the confidence level of the image as a defect image.

[0042] Traditional machine vision-based industrial defect inspection algorithms extract features from input images manually, including gradient and texture features. Based on these features, an SVM classifier (or a tree-based classifier) ​​is trained to classify the image as defective. This approach has two problems: first, manual features have poor generalization ability, often extracting harmful features that confuse the subsequent classifier for diverse video data; second, feature extraction and classifier training are performed independently, resulting in high training costs. Recent advancements have proposed using CNNs to address these issues. The original image is directly fed into a CNN network structure for feature extraction, followed by classification using fully connected layers. Model training is then performed end-to-end using a softmax loss function. This process eliminates the need for manual feature design; the model automatically learns the most suitable features for the current classification task during training, and the entire process is end-to-end, eliminating the need for separate training for feature extraction and classification. However, this CNN-based whole-image classification still has some problems. The distribution of defective images may be diverse, but CNNs are trained using only binary artificial labels of 0 or 1. The training set contains a limited number of defective images. The trained model can fit the training dataset well, but in the actual deployment stage, if defective images not collected in the training set are encountered, the output of the CNN is likely to have problems. The current model only fits the training set well, but its generalization ability is often poor.

[0043] In view of this, embodiments of this application provide an image recognition model training method. This method involves sampling multiple sample images in multiple tuples to obtain a sample tuple input containing multiple sample images. Each sample tuple is then processed for recognition to obtain classification index data for each sample image within that tuple. The classification index data and class labels are then used as parameters for model training. The model loss for each sample tuple is determined to measure the similarity between classification index data of sample images of the same class within the tuple, the difference between classification index data of sample images of different classes within the tuple, and the accuracy of the classification index data. Based on this model loss, model training is performed. This method guides model training with classification accuracy, similarity within the same class, and difference between different classes as training objectives. This reduces the intra-class feature distance of images of the same class while increasing the feature distance between images of different classes, improving the compactness of the distribution of similar features, and reducing the over-reliance on binary label classification loss during training. Ultimately, this significantly improves the accuracy of image recognition and the generalization performance of the model.

[0044] The solutions provided in this application involve artificial intelligence technologies such as machine learning / deep learning and computer vision, which are specifically illustrated through the following embodiments.

[0045] Please see Figure 1 , Figure 1 This is a schematic diagram of an application environment provided in an embodiment of this application, such as... Figure 1 As shown, the application environment may include at least terminal 01 and server 02. In practical applications, terminal 01 and server 02 can be directly or indirectly connected via wired or wireless communication, and this application does not impose any restrictions on this.

[0046] In this application embodiment, server 02 can be an independent physical server, a server cluster or 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 communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.

[0047] Specifically, cloud technology refers to a hosting technology that unifies hardware, software, and network resources within a wide area network (WAN) or local area network (LAN) to achieve data computation, storage, processing, and sharing. Cloud technology can be applied to various fields, such as medical cloud, cloud IoT, cloud security, cloud education, cloud conferencing, AI cloud services, cloud applications, cloud calling, and cloud social networking. Based on the cloud computing business model, cloud technology distributes computing tasks across a resource pool composed of numerous computers, enabling various application systems to obtain computing power, storage space, and information services as needed. The network providing these resources is called the "cloud." From the user's perspective, the resources in the "cloud" are infinitely scalable, readily available, on-demand, expandable, and pay-as-you-go. As a provider of basic cloud computing capabilities, a cloud resource pool (referred to as a cloud platform, generally called IaaS (Infrastructure as a Service)) platform is established, deploying various types of virtual resources within the pool for external customers to choose from. The cloud resource pool mainly includes: computing devices (virtualized machines containing operating systems), storage devices, and network devices.

[0048] Based on logical function, a PaaS (Platform as a Service) layer can be deployed on top of the IaaS layer, and a SaaS (Software as a Service) layer can be deployed on top of the PaaS layer. Alternatively, SaaS can be deployed directly on top of IaaS. PaaS is a platform for running software, such as databases and web containers. SaaS refers to various types of business software, such as web portals and bulk SMS senders. Generally speaking, SaaS and PaaS are upper layers compared to IaaS.

[0049] Specifically, the server 02 mentioned above may include physical devices, such as network communication submodules, processors, and memory, and may also include software running on the physical devices, such as applications.

[0050] Specifically, terminal 01 may include physical devices such as smartphones, desktop computers, tablets, laptops, digital assistants, augmented reality (AR) / virtual reality (VR) devices, smart voice interaction devices, smart home appliances, smart wearable devices, and in-vehicle terminal devices, and may also include software running on the physical devices, such as applications.

[0051] In this embodiment, terminal 01 can send image recognition instructions and images to be recognized to server 02, so that server 02 can perform corresponding image recognition operations. Server 02 can deploy a target image recognition model to provide image recognition services; and can be used to acquire multiple sample images and category labels of the sample images, and deploy a preset recognition model, using sample tuples sampled from multiple sample images as input to the preset recognition model, and category labels as the expected output. The preset recognition model is then constrained by a model loss used to measure the similarity between classification index data of sample images of the same category in the sample tuple, the difference between classification index data of sample images of different categories in the sample tuple, and the accuracy of the classification index data, to obtain the target image recognition model. Specifically, server 02 can also be used to store training sample sets and model training data, etc.

[0052] Furthermore, it is understandable that Figure 1 The example shown is merely an application environment for an image recognition model training method. This application environment may include more or fewer nodes, and this application does not impose any limitations on it.

[0053] The application environment involved in this application embodiment, or the terminal 01 and server 02 in the application environment, can be a distributed system formed by connecting clients and multiple nodes (any form of computing device accessing the network, such as servers and user terminals) through network communication. The distributed system can be a blockchain system, which can provide the aforementioned image recognition model training service and data storage service, etc.

[0054] The following describes an image recognition model training method based on the aforementioned application environment. This application's embodiments can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, and assisted driving. Please refer to... Figure 2 , Figure 2 This is a flowchart illustrating an image recognition model training method provided in an embodiment of this application. This specification provides method operation steps as shown in the embodiments or flowcharts, but based on conventional or non-inventive labor, more or fewer operation steps may be included. The order of steps listed in the embodiments is merely one possible execution order among many and does not represent the only execution order. In actual system or server products, the method can be executed sequentially according to the embodiments or drawings, or in parallel (e.g., in a parallel processor or multi-threaded processing environment). Specifically, as... Figure 2 As shown, the method may include the following steps S201-S209.

[0055] S201: Obtain multiple sample images and their category labels.

[0056] In this embodiment, multiple sample images may include images of at least two categories. When images of two categories are included, the category label can be a binary label, representing whether the sample image is a positive or negative sample image, and whether the sample image contains an identified target object, such as representing whether the sample image is a normal or abnormal image. Taking industrial defect detection as an example, the sample image can be a photograph of an industrial product; a positive sample image can be an image of a normal product without defects, and a negative sample image can be an image of an abnormal product containing defects. Please refer to... Figure 3 , Figure 3 A set of sample images from an industrial defect detection scenario is shown. Figure 3 The left image is a normal image without defects, the middle image is an abnormal image containing significant industrial defects, and the right image is an abnormal image containing minor industrial defects. Clearly, the difference between the right image and the normal image is too small. When trained solely on binary labels for classification loss, the model struggles to acquire sufficient knowledge to distinguish the category of this type of image. This application combines multiple loss dimensions to guide model training, improving the recognition accuracy for difficult examples like the one on the right.

[0057] In some embodiments, for sample images of a small proportion of a category among multiple sample images, such as defective product images, image augmentation processing can be performed. Augmentation processing may include, but is not limited to, image rotation, cropping, scaling, color conversion, or cropping and stitching.

[0058] S203: Perform tuple sampling on multiple sample images to obtain multiple sample tuples.

[0059] In some embodiments, multiple sample images can be randomly sampled to obtain multiple sample tuples containing a preset number of sample images. The preset number of sample images includes sample images corresponding to at least one category label. The preset number can be a positive integer greater than or equal to 3, preferably a positive integer greater than or equal to 2^n, where n is the number of category labels, such as 2 for binarized labels. Based on the random sampling method, a single sample tuple can include only one category label sample image, or it can include sample images of multiple categories of category labels, such as including both positive and negative samples. Thus, by forming multiple types of sample tuples based on random sampling, the model training can be diversified, which is beneficial for improving the robustness and generalization performance of the model.

[0060] In other embodiments, the tuple sampling method may specifically include: classifying multiple sample images based on category labels to obtain at least two sample image sets, where the sample images in the sample image sets have the same category label, and classifying them based on image category, such as under binary labels, to obtain two sample image sets; then sampling from each of the at least two sample image sets to obtain multiple sample tuples, where each sample tuple includes sample images corresponding to at least two category labels. Specifically, sampling is performed from each sample image set to obtain a sample tuple formed by sample images with multiple category labels. In one embodiment, two or more sample images can be randomly selected from the sample image set for each category label. By ensuring the comprehensiveness of the categories in each sample tuple, it is beneficial to improve the comprehensiveness and diversity of the model's loss information representation, thereby improving the model training effect.

[0061] In some embodiments, during the sampling process of multiple sample images, sample images corresponding to categories with a smaller proportion of images are sampled with replacement. For example, category labels characterize whether a sample image is a normal image or an abnormal image. During random sampling, if an abnormal image is collected from the sample tuple, the abnormal image is returned to the sample training set. In the process of first classifying images and then sampling from each sample image set, the sample image set of abnormal images is repeatedly collected using the sample image set of normal images as the quantity standard, until the images in the sample image set of normal images are extracted. This enables the reuse and combination of abnormal images, increases the utilization rate of abnormal images, and alleviates the long-tail sample problem.

[0062] S205: Input each sample tuple into the preset recognition model to obtain the classification index data of each sample image in each sample tuple.

[0063] In this embodiment of the application, the preset recognition model may include a feature extractor and a classifier. The feature extractor may be built based on a deep neural network, including but not limited to a convolutional neural network (CNN), and the classifier may be built based on a fully connected network and a softmax layer.

[0064] In practical applications, for each sample multivariate set, each sample image in the multivariate set is input into the feature extractor of a predefined recognition model to extract features from the sample images. Then, based on the classifier of the predefined recognition model, the sample image features are classified and recognized to obtain classification index data for each sample image in the multivariate set. Specifically, using the sample multivariate set as a single input and the category label of the sample images in the multivariate set as the expected output, the classification index data for each sample image is obtained. The classification index data may include, but is not limited to, the confidence level of the sample image belonging to a category represented by a category label, such as the confidence level of belonging to an anomalous image. The higher the confidence level, the greater the probability that the sample image is an anomalous image, and vice versa. Specifically, the confidence level can be represented based on a confidence probability value.

[0065] Specifically, the number of sample images in the sample tuple is B, such as Figure 7 With B=4, these sample images, after passing through a preset recognition model, output classification index data p for each sample image. i p i =f(x) i ;θ)i∈[1,2,…,B];where θ represents the model parameters of the preset recognition model, i is the encoded identifier of the sample image, p i It is a two-dimensional vector, with the two dimensions representing classification index data (such as confidence probability value) for whether the current sample image is a normal image or an abnormal image (defective image).

[0066] Understandably, in a single iteration of training, a single sample tuple can be used as the iteration sample size for loss calculation, or a partial or complete sample tuple obtained from multiple sample images in the training set can be used as the sample size for a single iteration to calculate the total loss.

[0067] S207: Based on the classification index data and category labels, determine the model loss corresponding to each sample tuple.

[0068] Specifically, the model loss measures the similarity of classification metrics among images of the same class within a sample tuple, the differences in classification metrics among images of different classes within the same sample tuple, and the accuracy of the classification metrics. Thus, the model loss, expressed through multidimensional information, guides model parameter updates and learning. While maintaining classification constraints, it narrows the intra-class feature distance between images of the same class and widens the feature distance between different classes, increasing the compactness of the distribution of similar features. This reduces the over-reliance on binary label classification loss during training, thereby significantly improving the accuracy of image recognition and the model's generalization performance. For example, in industrial defect detection scenarios, by ensuring correct model classification, it further narrows the distance between defect images in the feature space, making their feature distribution more compact, improving the accuracy and sensitivity of defect image detection, and significantly increasing the detection accuracy of images with minor defects.

[0069] In practical applications, please refer to Figure 4 S207 may include S301-S305.

[0070] S301: For each sample tuple in each sample tuple, calculate the classification loss based on the category label and classification index data to obtain the first loss corresponding to the sample tuple.

[0071] Specifically, the classification supervision loss is calculated using category labels as supervision, resulting in a first loss that measures the accuracy of the classification result. This first loss can be calculated using, but is not limited to, cross-entropy, KL divergence loss, and JS divergence loss. For example, the cross-entropy loss is calculated as follows, where L... supervised As the first loss, y i Characterizing p i The corresponding category label.

[0072] L supervised =-[y i *logp i +(1-y i )*log(1-p i for i∈B

[0073] S303: For each sample tuple, based on the category label, calculate the similarity between classification index data of sample images of the same category in the sample tuple and the difference between classification index data of sample images of different categories, and obtain the second loss and the third loss accordingly.

[0074] Specifically, based on category labels, images of the same type in a sample tuple can be identified, and then the classification index data of the images of the same type can be statistically calculated to express the loss information of similarity within the same type and difference between different types.

[0075] For specific embodiments, please refer to Figure 5 S303 may include S401-S407.

[0076] S401: Based on the category label, the classification index data of the same category sample images in the sample tuple are averaged to obtain the first standard index data corresponding to each category.

[0077] Specifically, the averaging process here may include, but is not limited to, calculating the arithmetic mean or weighted arithmetic mean of classification index data for sample images of the same category. The first standard index data is used to characterize the within-class distribution center of the classification index data for sample images of the same category.

[0078] S403: For each category, average the classification index data of the sample images of other categories in the sample tuple except for the current category to obtain the second standard index data corresponding to each category.

[0079] For example, if the normal image category is taken as the current category, the classification index data of the abnormal images are averaged to obtain the second standard index data; or, if there are a first category, a second category, and a third category, taking the first category as the current category, the classification index data of the sample images of the second and third categories are averaged to obtain the second standard index data. The averaging process here is similar to S401 and will not be described again.

[0080] S405: Determine the distance information between the classification index data of sample images of the same category in the sample tuple and the first standard index data corresponding to the category, and obtain the second loss.

[0081] Specifically, the second loss characterizes the similarity between classification index data of sample images of the same category. It can be calculated by performing index distribution calculation on sample images with the same category label (such as normal images) based on the classification index data and the first standard index data. Index distribution calculation includes, but is not limited to, summation of absolute differences, summation of squared differences, and summation of squared differences. In one embodiment, the second loss can be calculated using the following formula, where L... pull This indicates the second loss. This indicates that the first standard indicator data corresponding to category k is found in B sample images, specifically the arithmetic mean (e.g., the mean confidence probability value) of the classification indicator data of the sample images of category k.

[0082]

[0083] S407: Determine the distance information between the classification index data of sample images of the same category in the sample tuple and the second standard index data corresponding to the category, and obtain the third loss.

[0084] Specifically, the third loss can characterize the feature differences between sample images of different categories in a sample tuple. Based on classification index data and first standard index data, the inter-class distance of the classification index data for sample images with different category labels (such as normal images) can be calculated to obtain the third loss.

[0085] Inter-class distance calculation includes, but is not limited to, summing the absolute values ​​of the differences between the current class's classification index data and the second standard index data, summing the squared differences, and summing the squared differences. In one embodiment, the third loss can be calculated using the following formula, where L push Indicates the third loss. This represents the second standard indicator data corresponding to category k among the B sample images. Specifically, it is the arithmetic mean (e.g., the mean confidence probability value) of the classification indicator data of sample images of other categories besides category k. For example, if the current category is a normal image, then... y is the arithmetic mean of the classification index data for abnormal images. j The class labels of sample images of other classes besides class k in the sample tuple.

[0086]

[0087] In this way, the second loss "brings" the probability values ​​of the same category in the same batch closer together, and the third loss "distances" samples that are not of the same category, making the feature distribution of difficult data such as defective data more compact, reducing the classification difficulty of difficult data, and improving the application effect and generalization of the model.

[0088] It should be noted that L push and L pull The specific calculation method is not limited to the absolute value loss mentioned above, and can also use L2 loss, etc.

[0089] S305: The first loss, second loss, and third loss are fused and calculated to obtain the model loss corresponding to the sample tuple.

[0090] Specifically, the first loss, second loss, and third loss are weighted and summed to obtain the model loss. Thus, by combining multi-dimensional loss information that expresses classification accuracy, intra-class feature distance, and inter-class feature distance for learning and training, the model training effect is significantly improved, accuracy is optimized, and the dependence on sample class labels is reduced. In one embodiment, the model loss L can be calculated based on the following formula, where α and β are balancing parameters used to adjust the proportion of the two losses.

[0091] L = L pull +αL push +βL supervised

[0092] S209: Train a preset recognition model based on model loss to obtain a target image recognition model.

[0093] In this embodiment, gradient backpropagation is performed on the preset recognition model based on the model loss to update the model parameters and obtain an updated preset recognition model. Then, based on the updated preset recognition model, the above steps S201 to S207 are repeated to obtain an updated model loss. The model parameters are then updated again based on the updated model loss until the training termination condition is met. The training termination condition can be reaching the required number of iterations or the difference in model loss between adjacent iterations meeting a preset difference condition, etc. The model parameters obtained from the iterations that meet the training termination condition are determined as target parameters, thereby obtaining the target image recognition model.

[0094] Based on the above scheme, taking industrial defect detection as an example, the principle framework of the image recognition model training method in this application is as follows: Figure 7 As shown, the sample tuple is used as the input to the preset recognition model. Figure 7 The example sample tuple includes 2 defective images (first row) and 2 normal images (second row). Feature extraction and classification are performed, outputting classification index data p1, p2, p3, and p4 for sample images 1-4 to represent the probability value of each sample being a defective sample. Based on the category labels of sample images 1-4, the first loss for each sample image is calculated. At the same time, the classification index data of samples of the same category (p1 and p2 are of the same category, p3 and p4 are of the same category) are brought closer (solid arrows in the figure) to calculate the second loss. The classification index data of samples of different categories are far apart (dashed arrows in the figure) to calculate the third loss. This is used to make the intra-class feature differences more compact and the inter-class feature differences more distant. The classification loss optimizes the model so that the classification result is close to the same as the category label, which makes the features of different defects more compactly distributed while being sensitively classifiable. After training, the target image recognition model is obtained.

[0095] Based on some or all of the above implementation methods, in some embodiments, after inputting the sample tuple into a preset recognition model, the sample image features of each sample image are obtained. Accordingly, after S203, the method further includes: calculating the feature distance distribution of intra-class sample image features for sample images of the same category in the sample tuple to obtain a fourth loss, the fourth loss representing the feature distribution divergence between sample images of the same category; calculating the feature distance distribution of inter-class sample image features for sample images of different categories in the sample tuple to obtain a fifth loss, the fifth loss representing the feature distribution divergence between sample images of the same category.

[0096] Specifically, for the sample image features of each category of sample images, the intra-class center of each sample image feature is determined, and then the feature distance between each sample image feature and the intra-class center is calculated. Then, the absolute values ​​of the feature distances corresponding to each sample image feature are summed to obtain the fourth loss. The intra-class center can be obtained using existing clustering algorithms, and this application does not impose any specific limitations. The feature distance can be calculated by Euclidean distance, Manhattan distance, or cosine similarity distance, etc., and is not limited here.

[0097] Specifically, for the sample image features of each category of sample images, the feature distance between each sample image feature of the current category and the intra-class center of other categories in the sample tuple is calculated, and the absolute values ​​of each calculated feature distance are summed to obtain the feature distance sum with the intra-class center of other categories. The negative of the feature distance sum is then used to obtain the fifth loss.

[0098] Accordingly, in some embodiments, the model loss in S207 can be obtained by weighted summation of the first loss, the second loss, the third loss, the fourth loss, and the fifth loss. The overall parameters of the model are adjusted using this model loss. By adding feature distance measurement, it is beneficial to improve the parameter optimization effect of the feature extractor and further optimize the inter-class distribution differences and intra-class distribution compactness of the features extracted by the feature extractor.

[0099] In other embodiments, the first loss, second loss, and third loss can be weighted and summed to obtain the first model loss, and the first loss, second loss, third loss, fourth loss, and fifth loss can be weighted and summed to obtain the second model loss. The model parameters of the classifier and other models other than the feature extractor are adjusted by the first model loss, and the model parameters of the feature extractor are adjusted based on the second model loss. In this way, the feature extractor is updated and guided in a targeted manner by combining feature distance measurement and other loss information, which is more conducive to the optimization of feature extraction, decoupling the gradient influence between the feature extractor and the classifier, and optimizing the model training effect.

[0100] Based on some or all of the above implementation methods, in some embodiments, after inputting the sample tuple into a preset recognition model, sample image features of each sample image are obtained for classification and recognition. At the same time, image reconstruction operations are performed on the sample image features through the image reconstruction branch in the preset recognition model, such as deconvolution, unpooling, and upsampling operations, to obtain the reconstructed image corresponding to each sample image. The reconstructed image and the corresponding sample image are input into another pre-trained feature extraction network to obtain the first feature of the sample image and the second feature of the reconstructed image. Accordingly, after S203, the method further includes: for each sample image in the sample tuple, image difference calculation is performed based on the sample image and the reconstructed image corresponding to the sample image to obtain image difference data. The image difference data of each sample image are summed to obtain a sixth loss, which is used to characterize the overall degree of difference between the sample image and its reconstructed image.

[0101] In some embodiments, the feature mean and feature standard deviation can be calculated based on multiple sample images or a large image dataset. Then, a sixth loss is calculated based on the obtained feature mean, feature standard deviation, first feature, and second feature. In one embodiment, the sixth loss can be a perceptual loss, and its expression can be as follows: Where x and These represent the sample image and the reconstructed image corresponding to the sample image, respectively. μ is the average value of features pre-calculated based on multiple sample images or a large dataset, σ is the standard deviation of features pre-calculated based on multiple sample images or a large dataset, and f(x) represents the first feature of sample image x; in, Represents the reconstructed image The second feature. Thus, the distance between image features obtained from the same feature extraction network is used to obtain the reconstruction loss, which helps to ensure noise reduction while avoiding the loss of detailed information in image feature extraction, and is beneficial to the recognition accuracy of difficult data such as slightly defective images.

[0102] Accordingly, in some embodiments, the model loss of S207 can be obtained by weighted summation of the first loss, the second loss, the third loss and the sixth loss. The overall parameters of the model are adjusted with this model loss. By adding the reconstruction loss measure, it is beneficial to optimize the parameters of the feature extractor and reduce the loss of detailed information in feature extraction.

[0103] In other embodiments, the first loss, the second loss, and the third loss can be weighted and summed to obtain the first model loss, and the first loss, the second loss, the third loss, and the sixth loss can be weighted and summed to obtain the third model loss. The model parameters of the classifier and other models other than the feature extractor are adjusted by the first model loss, and the model parameters of the feature extractor are adjusted based on the third model loss. In this way, the feature extractor is updated in a targeted manner by combining the reconstruction loss measurement and other loss information, and the feature extraction effect is deeply optimized.

[0104] In other embodiments, the model loss in S207 can be obtained by weighted summation of the first loss, second loss, third loss, fourth loss, fifth loss, and sixth loss. The overall parameters of the model are adjusted using this model loss, and the model training effect is optimized synergistically by adding feature distance measurement and reconstruction loss measurement.

[0105] In other embodiments, the first loss, second loss, and third loss can be weighted and summed to obtain the first model loss, and the first loss, second loss, third loss, fourth loss, fifth loss, and sixth loss can be weighted and summed to obtain the fourth model loss. The model parameters of the classifier and other models other than the feature extractor are adjusted by the first model loss, and the model parameters of the feature extractor are adjusted based on the fourth model loss. In this way, the feature extractor is updated and guided in a targeted manner by combining feature distance measurement, reconstruction loss measurement, and other loss information, which is more conducive to the optimization of feature extraction, decouples the gradient influence between feature distance measurement, reconstruction loss measurement and classifier, and optimizes the model training effect.

[0106] Based on some or all of the above embodiments, please refer to the embodiments of this application. Figure 6 The method may also include:

[0107] 501: Obtain the image to be recognized;

[0108] 503: Input the image to be recognized into the target image recognition model, perform image recognition processing on the image to be recognized, and obtain the classification recognition result of the image to be recognized. The classification recognition result represents the category label to which the image to be recognized belongs.

[0109] Specifically, after deploying the target image recognition model, a single image to be recognized is input. After feature extraction and classification, its corresponding classification index data is obtained, and its category is determined, thus yielding the classification result. For example, in industrial defect detection, please refer to [reference needed]. Figure 8 The classification index data is the defect confidence score. If the defect confidence score is greater than the preset confidence score Z, it indicates that the image to be identified is a defective image; otherwise, it is a normal image. Z can be, for example, 0.5. Based on the target image recognition model obtained by the method of this application, the following applies: Figure 3The defect confidence score for the normal image output in the left image is 0.05, the defect confidence score for the middle image is 0.95, and the defect confidence score for the right image is 0.90. In recognition applications, only a single image needs to be input, and a threshold is used to generate a judgment for dismissal. There is no need for multi-branch feature extraction or tuple input, thus avoiding the time-consuming model deployment and classification recognition.

[0110] In summary, the model training method proposed in this application, based on tuples as input and combined with model loss representing multidimensional information, performs classification and recognition training. Besides supervised training using classification labels, it also improves the classification accuracy of difficult examples and enhances model generalization by narrowing the feature distance within the same class and widening the feature distance between different classes. This results in a more compact feature distribution for similar data and a sparser feature distribution for different classes. For industrial defect detection tasks, the proposed solution can accurately detect the degree of defects in input images, demonstrating excellent performance in detecting images with minor defects.

[0111] This application also provides an image recognition model training device 600, such as... Figure 9 As shown, Figure 9 The diagram shows a structural schematic of an image recognition model training device provided in an embodiment of this application. The device may include the following modules.

[0112] Sample acquisition module 10: Used to acquire multiple sample images and the category labels of the sample images;

[0113] Sample sampling module 20: used to perform tuple sampling on multiple sample images to obtain multiple sample tuples;

[0114] Classification and recognition module 30: used to input each sample tuple into a preset recognition model to obtain classification index data for each sample image in each sample tuple;

[0115] Loss determination module 40: Based on classification index data and category labels, it determines the model loss corresponding to each sample tuple. The model loss is used to measure the similarity between classification index data of sample images of the same category in the sample tuple, the difference between classification index data of sample images of different categories in the sample tuple, and the accuracy of classification index data.

[0116] Model training module 50: used to train a preset recognition model based on model loss to obtain a target image recognition model.

[0117] In some embodiments, the loss determination module 40 may include:

[0118] First loss calculation unit: used to calculate the classification loss for each sample tuple based on the category label and classification index data, and obtain the first loss corresponding to the sample tuple.

[0119] The second loss calculation unit is used to calculate the similarity between classification index data of sample images of the same category and the difference between classification index data of sample images of different categories in each sample tuple based on the category label, and obtain the second loss and the third loss accordingly.

[0120] Loss fusion unit: used to fuse the first loss, second loss and third loss to obtain the model loss corresponding to the sample tuple.

[0121] In some embodiments, the second loss calculation unit includes:

[0122] The first standard calculation subunit is used to average the classification index data of the same category sample images in the sample tuple based on the category label, so as to obtain the first standard index data corresponding to each category.

[0123] The second standard calculation subunit is used to average the classification index data of the sample images of other categories in the sample tuple, except for the current category, for each category, to obtain the second standard index data corresponding to each category.

[0124] The first loss calculation subunit is used to determine the distance information between the classification index data of sample images of the same category in the sample tuple and the first standard index data corresponding to the category, and to obtain the second loss.

[0125] The second loss calculation subunit is used to determine the distance information between the classification index data of sample images of the same category in the sample tuple and the second standard index data corresponding to the category, and to obtain the third loss.

[0126] In some embodiments, the loss fusion unit may specifically be used to: weight and sum the first loss, the second loss, and the third loss to obtain the model loss.

[0127] In some embodiments, the classification and recognition module 30 may be specifically used to: input each sample image in each sample multivariate into the feature extractor of the preset recognition model for each sample multivariate, extract features from the sample image to obtain sample image features; and classify and recognize the sample image features based on the classifier of the preset recognition model to obtain classification index data for each sample image in the sample multivariate.

[0128] In some embodiments, the sample sampling module 20 may include a first sampling unit: used to randomly sample multiple sample images to obtain multiple sample tuples including a preset number of sample images, wherein the preset number of sample images includes sample images corresponding to at least one category label.

[0129] In some embodiments, the sample sampling module 20 may include:

[0130] Image classification unit: used to classify multiple sample images based on category labels to obtain at least two sample image sets, where the sample images in the sample image sets have the same category label;

[0131] The second sampling unit is used to sample from at least two sample image sets to obtain multiple sample tuples, each of which includes sample images corresponding to at least two category labels.

[0132] In some embodiments, the apparatus further includes:

[0133] Image acquisition module: used to acquire the image to be recognized;

[0134] Image recognition module: It is used to input the image to be recognized into the target image recognition model, perform image recognition processing on the image to be recognized, and obtain the classification recognition result of the image to be recognized. The classification recognition result represents the category label to which the image to be recognized belongs.

[0135] It should be noted that the above-described device embodiments and method embodiments are based on the same implementation methods.

[0136] This application provides an image recognition model training device. The scheduling device can be a terminal or a server, including a processor and a memory. The memory stores at least one instruction or at least one program. The at least one instruction or at least one program is loaded and executed by the processor to implement the image recognition model training method provided in the above method embodiments.

[0137] Memory can be used to store software programs and modules. The processor executes these stored software programs and modules to perform various functional applications and train image recognition models. Memory can primarily include a program storage area and a data storage area. The program storage area stores the operating system, application programs required for functionality, etc.; the data storage area stores data created based on device usage, etc. Furthermore, memory can include high-speed random access memory (RAM) and non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, memory can also include a memory controller to provide the processor with access to the memory.

[0138] The methods and embodiments provided in this application can be executed in electronic devices such as mobile terminals, computer terminals, servers, or similar computing devices. Figure 10 This is a hardware structure block diagram of an electronic device for an image recognition model training method provided in an embodiment of this application. For example... Figure 10 As shown, the electronic device 900 can vary significantly due to different configurations or performance. It may include one or more Central Processing Units (CPUs) 910 (CPUs 910 may include, but are not limited to, microprocessors such as MCUs or programmable logic devices such as FPGAs), a memory 930 for storing data, and one or more storage media 920 (e.g., one or more mass storage devices) for storing application programs 923 or data 922. The memory 930 and storage media 920 may be temporary or persistent storage. The program stored in the storage media 920 may include one or more modules, each module including a series of instruction operations on the electronic device. Furthermore, the CPU 910 may be configured to communicate with the storage media 920 and execute a series of instruction operations in the storage media 920 on the electronic device 900. The electronic device 900 may also include one or more power supplies 960, one or more wired or wireless network interfaces 950, one or more input / output interfaces 940, and / or one or more operating systems 921, such as Windows Server. TM Mac OS X TM Unix TM Linux™, FreeBSD™, etc.

[0139] The input / output interface 940 can be used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the electronic device 900. In one example, the input / output interface 940 includes a network interface controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the input / output interface 940 may be a radio frequency (RF) module for wireless communication with the Internet.

[0140] Those skilled in the art will understand that Figure 10 The structure shown is for illustrative purposes only and does not limit the structure of the electronic device described above. For example, the electronic device 900 may also include... Figure 10 The more or fewer components shown, or having the same Figure 10 The different configurations shown.

[0141] Embodiments of this application also provide a computer-readable storage medium, which can be disposed in an electronic device to store at least one instruction or at least one program related to implementing an image recognition model training method in the method embodiment. The at least one instruction or the at least one program is loaded and executed by the processor to implement the image recognition model training method provided in the above method embodiment.

[0142] Optionally, in this embodiment, the storage medium may be located at at least one of the multiple network servers in a computer network. Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.

[0143] According to one aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the methods provided in the various alternative implementations described above.

[0144] As can be seen from the embodiments of the image recognition model training method, apparatus, device, server, terminal, storage medium, and program product provided in this application, the technical solution of this application obtains multiple sample images and category labels of the sample images; performs tuple sampling on the multiple sample images to obtain a sample tuple input containing multiple sample images, and performs recognition processing on each sample tuple to obtain classification index data for each sample image in each sample tuple; then uses the classification index data and category labels as measurement parameters for model training, and determines the model loss corresponding to each sample tuple respectively, so as to measure the similarity between classification index data of sample images of the same category in the sample tuple, the difference between classification index data of sample images of different categories in the sample tuple, and the accuracy of classification index data, and then performs model training based on the model loss. It can guide model training with classification accuracy, similarity within the same category, and difference between different categories as training objectives, thereby reducing the intra-class feature distance of images of the same category and increasing the feature distance between different categories while constraining classification, improving the distribution compactness of features of the same category, reducing the excessive dependence on binary label classification loss in the training process, and thus significantly improving the accuracy of image recognition and the generalization performance of the model.

[0145] It should be noted that the order of the embodiments described above is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. Furthermore, the above description focuses on specific embodiments of this application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps described in the claims can be performed in a different order than that shown in the embodiments and still achieve the desired results. Additionally, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired results. In some implementations, multitasking and parallel processing are also possible or may be advantageous.

[0146] The various embodiments in this application are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the device, equipment, and storage medium embodiments are basically similar to the method embodiments, so the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0147] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware, or by a program instructing the relevant hardware to implement them. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.

[0148] The above are merely preferred embodiments of this application and are not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.

Claims

1. A method for training an image recognition model, characterized in that, The method includes: Obtain multiple sample images and their category labels; Perform tuple sampling on the multiple sample images to obtain multiple sample tuples; Each of the sample tuples is input into a preset recognition model to obtain the classification index data of each sample image in each sample tuple; Based on the classification index data and the category labels, the model loss corresponding to each of the sample tuples is determined. The model loss measures the similarity of classification index data among sample images of the same category within the sample tuple, the difference in classification index data among sample images of different categories within the sample tuple, and the accuracy of the classification index data. The model loss includes a second loss and a third loss. The method for obtaining the second loss and the third loss includes: based on the category labels, averaging the classification index data of sample images of the same category within the sample tuple to obtain the first standard index data corresponding to each category. The first standard index data is used to represent... The following steps are taken: First, the intra-class distribution center of the classification index data for sample images of the same category is identified. Second, for each category, the classification index data of sample images of other categories in the sample tuple (excluding the current category) is averaged to obtain the second standard index data corresponding to each category. Third, the distance information between the classification index data of sample images of the same category in the sample tuple and the first standard index data corresponding to the category is determined to calculate the index distribution of the classification index data, thus obtaining the second loss. Finally, the distance information between the classification index data of sample images of the same category in the sample tuple and the second standard index data corresponding to the category is determined to obtain the third loss. The preset recognition model is trained based on the model loss to obtain the target image recognition model.

2. The method according to claim 1, characterized in that, The step of determining the model loss for each of the sample tuples based on the classification index data and the category labels includes: For each of the sample tuples, a classification loss is calculated based on the category label and the classification index data to obtain the first loss corresponding to the sample tuple. For each sample tuple, based on the category label, the similarity between classification index data of sample images of the same category in the sample tuple and the difference between classification index data of sample images of different categories are calculated respectively, and the second loss and the third loss are obtained accordingly. The first loss, the second loss, and the third loss are fused together to obtain the model loss corresponding to the sample tuple.

3. The method according to claim 2, characterized in that, The fusion calculation of the first loss, the second loss, and the third loss to obtain the model loss corresponding to the sample tuple includes: The first loss, the second loss, and the third loss are weighted and summed to obtain the model loss.

4. The method according to any one of claims 1-3, characterized in that, The step of inputting each of the sample tuples into a preset recognition model to obtain classification index data for each sample image in each sample tuple includes: For each of the sample multivariate groups, each sample image in the sample multivariate group is input into the feature extractor of the preset recognition model to extract features from the sample image and obtain sample image features; and the sample image features are classified and recognized based on the classifier of the preset recognition model to obtain classification index data for each sample image in the sample multivariate group.

5. The method according to any one of claims 1-3, characterized in that, The step of performing tuple sampling on the multiple sample images to obtain multiple sample tuples includes: Random sampling is performed on the multiple sample images to obtain multiple sample tuples, each containing a preset number of sample images, wherein the preset number of sample images includes sample images corresponding to at least one category label.

6. The method according to any one of claims 1-3, characterized in that, The step of performing tuple sampling on the multiple sample images to obtain multiple sample tuples includes: Based on the category labels, the multiple sample images are classified to obtain at least two sample image sets, wherein the sample images in the sample image sets have the same category labels; Samples are taken from the at least two sample image sets to obtain the plurality of sample tuples, wherein the sample tuples include sample images corresponding to at least two category labels.

7. The method according to any one of claims 1-3, characterized in that, The method further includes: Acquire the image to be recognized; The image to be identified is input into the target image recognition model, and image recognition processing is performed on the image to be identified to obtain the classification recognition result of the image to be identified. The classification recognition result represents the category label to which the image to be identified belongs.

8. An image recognition model training device, characterized in that, The device includes: Sample acquisition module: used to acquire multiple sample images and the category labels of the sample images; Sample sampling module: used to perform tuple sampling on the multiple sample images to obtain multiple sample tuples; Classification and recognition module: used to input each of the sample tuples into a preset recognition model to obtain classification index data for each sample image in each of the sample tuples; The loss determination module is used to determine the model loss corresponding to each of the sample tuples based on the classification index data and the category labels. The model loss measures the similarity of classification index data between sample images of the same category in the sample tuple, the difference in classification index data between sample images of different categories in the sample tuple, and the accuracy of the classification index data. The model loss includes a second loss and a third loss. The method for obtaining the second loss and the third loss includes: averaging the classification index data of sample images of the same category in the sample tuple based on the category labels to obtain the first standard index data corresponding to each category. The first standard index data is used to characterize the intra-class distribution center of the classification index data of sample images of the same category; for each category, the classification index data of sample images of other categories in the sample tuple (excluding the current category) are averaged to obtain the second standard index data corresponding to each category; the distance information between the classification index data of sample images of the same category in the sample tuple and the first standard index data corresponding to the category is determined to obtain the second loss; the distance information between the classification index data of sample images of the same category in the sample tuple and the second standard index data corresponding to the category is determined to obtain the third loss. Model training module: used to train the preset recognition model based on the model loss to obtain the target image recognition model.

9. The apparatus according to claim 8, characterized in that, The loss determination module includes: First loss calculation unit: for each of the sample tuples, the classification loss is calculated based on the category label and the classification index data to obtain the first loss corresponding to the sample tuple; The second loss calculation unit is used to calculate the similarity between classification index data of sample images of the same category and the difference between classification index data of sample images of different categories in each sample tuple based on the category label, and obtain the second loss and the third loss accordingly. Loss fusion unit: used to fuse the first loss, the second loss and the third loss to obtain the model loss corresponding to the sample tuple.

10. The apparatus according to claim 9, characterized in that, The loss fusion unit is specifically used for: The first loss, the second loss, and the third loss are weighted and summed to obtain the model loss.

11. The apparatus according to any one of claims 8-10, characterized in that, The classification and recognition module is specifically used for: For each of the sample multivariate groups, each sample image in the sample multivariate group is input into the feature extractor of the preset recognition model to extract features from the sample image and obtain sample image features; and the sample image features are classified and recognized based on the classifier of the preset recognition model to obtain classification index data for each sample image in the sample multivariate group.

12. The apparatus according to any one of claims 8-10, characterized in that, The sample sampling module includes a first sampling unit, used for: Random sampling is performed on the multiple sample images to obtain multiple sample tuples, each containing a preset number of sample images, wherein the preset number of sample images includes sample images corresponding to at least one category label.

13. The apparatus according to any one of claims 8-10, characterized in that, The sample sampling module includes: Image classification unit: used to classify the plurality of sample images based on the category labels to obtain at least two sample image sets, wherein the sample images in the sample image sets have the same category labels; The second sampling unit is used to sample from the at least two sample image sets respectively to obtain the plurality of sample tuples, wherein the sample tuples include sample images corresponding to at least two category labels.

14. The apparatus according to any one of claims 8-10, characterized in that, The device further includes: Image acquisition module: used to acquire the image to be recognized; Image recognition module: used to input the image to be recognized into the target image recognition model, perform image recognition processing on the image to be recognized, and obtain the classification recognition result of the image to be recognized, wherein the classification recognition result represents the category label to which the image to be recognized belongs.

15. A computer-readable storage medium, characterized in that, The storage medium stores at least one instruction or at least one program segment, which is loaded and executed by a processor to implement the image recognition model training method as described in any one of claims 1-7.

16. A computer device, characterized in that, The device includes a processor and a memory, the memory storing at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by the processor to implement the image recognition model training method as described in any one of claims 1-7.

17. A computer program product, characterized in that, The computer program product includes computer instructions that, when executed by a processor, implement the image recognition model training method as described in any one of claims 1-7.