Image recognition model training method, device, equipment and storage medium
By determining the target classifier and calculating the classification loss in the image recognition model, the problem of low recognition performance of the image recognition model in multi-data joint training is solved, and the recognition accuracy and training effect are improved.
Patent Information
- Application Number
- CN202210590409.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-26
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2042-05-26
AI Technical Summary
In the scenario of jointly training an image recognition model with multiple data, due to the conflict of recognition goals between various image sample sets, the recognition performance of the image recognition model is not high enough and the training effect is suppressed.
By determining the target classifier set corresponding to the target sample subset from each classifier of the image recognition model, and based on the positive candidate region and negative candidate region corresponding to the image sample in the target sample subset, calculate the first classification loss and the first classification loss respectively. Binary classification loss is used to train the image recognition model to ensure that negative candidate areas are only effective in a subset of target samples to avoid target conflicts.
It improves the recognition accuracy of the image recognition model in a multi-data joint training scenario, solves the problem of suppressed training effects caused by target conflicts, and enriches negative information through the participation of positive candidate areas, further improving the recognition accuracy of the model.
Smart Images

Figure CN115115871B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of artificial intelligence technology, and in particular to a training method, apparatus, device and storage medium for an image recognition model. Background Art
[0002] With the development of artificial intelligence technology, its research and application in the field of image recognition are becoming more and more frequent.
[0003] At present, in scenarios involving joint training of image recognition models with multiple data, related technologies directly train the image recognition models through multiple image sample sets. However, due to the conflicts in recognition targets between the image sample sets, for example, the negative samples corresponding to a certain image sample set (such as anchor negative samples) are the positive samples of another image sample set (such as anchor positive samples), this produces a negative training effect on the image recognition model, suppresses the recognition performance of the image recognition model, and causes the recognition accuracy of the trained image recognition model to be insufficient. Summary of the invention
[0004] The embodiments of the present application provide a method, apparatus, device and storage medium for training an image recognition model, which can improve the recognition accuracy of the image recognition model. The technical solution may include the following contents.
[0005] According to one aspect of an embodiment of the present application, a method for training an image recognition model is provided, the method comprising:
[0006] Acquire an image sample set, wherein the image sample set includes a plurality of sample subsets, and there are differences between the recognition targets corresponding to the respective sample subsets;
[0007] For a target sample subset among the multiple sample subsets, determining a target classifier set corresponding to the target sample subset from the classifiers of the image recognition model; wherein the target classifiers in the target classifier set correspond to the recognition targets corresponding to the target sample subset;
[0008] For a target image sample in the target sample subset, determining a first classification loss corresponding to the target image sample based on each positive candidate region corresponding to the target image sample by each classifier; wherein the recognition target corresponding to the image sample is predicted to exist in the positive candidate region;
[0009] Determining a second classification loss corresponding to the target image sample based on each negative candidate region corresponding to the target image sample only by the target classifier in the target classifier set; wherein the identification target corresponding to the image sample is predicted to not exist in the negative candidate region;
[0010] Based on the first classification loss and the second classification loss respectively corresponding to each image sample in the image sample set, the image recognition model is trained to obtain the trained image recognition model, and each classifier in the trained image recognition model is used to identify the recognition target corresponding to the image sample set.
[0011] According to one aspect of an embodiment of the present application, a training device for an image recognition model is provided, the device comprising:
[0012] A sample set acquisition module, used to acquire an image sample set, wherein the image sample set includes a plurality of sample subsets, and there are differences between the recognition targets corresponding to the respective sample subsets;
[0013] A target classifier determination module is used to determine, for a target sample subset among the multiple sample subsets, a target classifier set corresponding to the target sample subset from the classifiers of the image recognition model; wherein the target classifiers in the target classifier set correspond to the recognition targets corresponding to the target sample subset;
[0014] A classification loss acquisition module is used to determine, for a target image sample in the target sample subset, a first classification loss corresponding to the target image sample based on each positive candidate region corresponding to the target image sample through each classifier; wherein the recognition target corresponding to the image sample is predicted to exist in the positive candidate region;
[0015] The classification loss acquisition module is further used to determine a second classification loss corresponding to the target image sample based on each negative candidate region corresponding to the target image sample only by the target classifier in the target classifier set; wherein the recognition target corresponding to the image sample is predicted to not exist in the negative candidate region;
[0016] The recognition model training module is used to train the image recognition model based on the first classification loss and the second classification loss respectively corresponding to each image sample in the image sample set to obtain the trained image recognition model, and each classifier in the trained image recognition model is used to identify the recognition target corresponding to the image sample set.
[0017] According to one aspect of an embodiment of the present application, a computer device is provided, which includes a processor and a memory, wherein a computer program is stored in the memory, and the computer program is loaded and executed by the processor to implement the above-mentioned image recognition model training method.
[0018] According to one aspect of an embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored. The computer program is loaded and executed by a processor to implement the above-mentioned image recognition model training method.
[0019] According to one aspect of the embodiments of the present application, a computer program product or a computer program is provided, the computer program product or the computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above-mentioned training method of the image recognition model.
[0020] The technical solution provided by the embodiments of the present application includes at least the following beneficial effects.
[0021] By determining the target classifier corresponding to the target sample subset from the classifiers corresponding to the image recognition model, and determining the classification loss of the negative candidate area under the target classifier based on the negative candidate area corresponding to the image samples in the target sample subset (such as anchor negative samples), the negative candidate area corresponding to the target sample subset does not participate in the training of classifiers other than the target classifier, so that the negative candidate area corresponding to the target sample subset is effective only in the target sample subset, which solves the problem in the related art that the training effect is suppressed due to the conflict of recognition targets between each image sample set, thereby improving the recognition accuracy of the image recognition model in the multi-data joint training scenario.
[0022] In addition, since the positive candidate regions corresponding to the image samples in the target sample subset (such as anchor positive samples) can participate in the training of all classifiers corresponding to the image recognition model, the negative information corresponding to the sample subsets outside the target sample subset is enriched, thereby further improving the recognition accuracy of the image recognition model in the multi-data joint training scenario. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0024] Figure 1 It is a schematic diagram of an implementation environment of a solution provided by an embodiment of the present application;
[0025] Figure 2 is a schematic diagram of a positive and negative candidate region acquisition network provided by an embodiment of the present application;
[0026] Figure 3 is a flowchart of a method for training an image recognition model provided by an embodiment of the present application;
[0027] Figure 4 is a schematic diagram of a classifier control code provided by an embodiment of the present application;
[0028] Figure 5 is a schematic diagram of the use of an image recognition model provided by an embodiment of the present application under multiple tasks;
[0029] Figure 6 is a block diagram of a training device for an image recognition model provided by one embodiment of the present application;
[0030] Figure 7 is a block diagram of a training device for an image recognition model provided by another embodiment of the present application;
[0031] Figure 8 It is a schematic diagram of the structure of a computer device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0032] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0033] 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.
[0034] 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.
[0035] Computer vision technology (CV) is a science that studies how to make machines "see". To put it more specifically, it refers to machine vision such as using cameras and computers to replace human eyes to identify and measure targets, and further perform graphic 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, OCR (Optical Character Recognition), 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.
[0036] 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 teaching learning.
[0037] The technical solution provided in the embodiments of the present application involves computer vision technology and machine learning technology of artificial intelligence. Computer vision technology is used to obtain positive candidate regions corresponding to image samples and candidate features corresponding to the positive candidate regions, as well as negative candidate regions and candidate features corresponding to the negative candidate regions. Machine learning technology is then used to train an image recognition model (such as a positive and negative candidate region acquisition network, a coordinate regression network, and a category regression network in the image recognition model) based on the positive candidate regions corresponding to the image samples and candidate features corresponding to the positive candidate regions, as well as the negative candidate regions and candidate features corresponding to the negative candidate regions, to obtain a trained image recognition model.
[0038] In the method provided in the embodiment of the present application, the execution subject of each step may be a computer device, which refers to an electronic device with data calculation, processing and storage capabilities. The computer device may be a terminal such as a PC (Personal Computer), a tablet computer, a smart phone, a wearable device, an intelligent robot, a vehicle-mounted device, etc.; it may also be a server. Among them, the server may be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services.
[0039] The image recognition model in the embodiment of the present application can be used for tasks such as image recognition, target detection, target recognition, image segmentation, etc., and the embodiment of the present application does not limit this. The technical solution provided in the embodiment of the present application is applicable to any scenario where the above-mentioned image recognition model needs to be used, such as target detection scenario, target recognition scenario, image segmentation scenario, image processing scenario, smart transportation scenario, assisted driving scenario, etc. The technical solution provided in the embodiment of the present application can improve the recognition accuracy of the image recognition model in the multi-data joint training scenario.
[0040] In some examples, when the image recognition model needs to be applicable to different target detection tasks, a subset of samples with annotation information of different recognition targets can be obtained for different target detection tasks, thereby obtaining an image sample set of the image recognition model. For example, the above-mentioned target detection tasks can be tasks such as clothing detection, person detection, vehicle detection, object detection, road element detection, etc. By adopting the technical solution provided in the embodiment of the present application, the image recognition model is jointly trained based on an image sample set including image samples with annotation information of different recognition targets, so as to obtain an image recognition model that can be used to detect different recognition targets.
[0041] In other examples, when the image recognition model needs to support the detection of newly added recognition targets, a sample subset with annotation information of the newly added recognition targets can be obtained for the newly added recognition targets. Using the technical solution provided in the embodiment of the present application, the image recognition model is jointly trained based on the original image sample set and the sample subset with annotation information of the newly added recognition targets, to obtain an image recognition model that can detect both the original recognition targets and the newly added recognition targets.
[0042] The following is a detailed description of the training method of the image recognition model provided in the embodiments of the present application.
[0043] Please refer to Figure 1 , which shows a schematic diagram of a solution implementation environment provided by an embodiment of the present application. The solution implementation environment may include a model training device 10 and a model using device 20.
[0044] The model training device 10 may be an electronic device such as a PC, a computer, a tablet computer, a server, an intelligent robot, a vehicle-mounted terminal, or other electronic devices with strong computing capabilities. The model training device 10 is used to train the image recognition model 30 .
[0045] In an embodiment of the present application, the image recognition model 30 is a neural network model that can be used for tasks such as image recognition, target detection, and image segmentation. Exemplarily, in an image recognition scenario, the image recognition model 30 can be used to identify faces, commodities, and the like. In a target detection scenario, the image recognition model 30 can be used to detect targets such as vehicles, people (real people or virtual characters, etc.), animals, and plants (such as trees). In an image segmentation scenario, the image recognition model 30 can be used to segment scenes, objects, roads, buildings, and the like in an image. The present application embodiment does not limit the tasks to which the image recognition model 30 can be applied. The image recognition model 30 in the embodiment of the present application can support detection tasks for different targets, and the image recognition model 30 can be obtained by jointly training a set of image samples including image samples with annotation information for different recognition targets, or a plurality of image sample sets with annotation information for different recognition targets, and the present application embodiment does not limit this.
[0046] Optionally, the model training device 10 can use machine learning to train the image recognition model 30 so that it has better performance.
[0047] The trained image recognition model 30 can be deployed in the model using device 20 for use to provide image recognition, target detection, image segmentation and other functions. The model using device 20 can be a terminal device such as a mobile phone, a computer, a smart TV, a multimedia player, a wearable device, a medical device, a vehicle terminal, or a server, which is not limited in the embodiment of the present application.
[0048] In some embodiments, Figure 1 As shown, the image recognition model 30 may include a positive and negative candidate region acquisition network 310 , a coordinate regression network 320 , and a category regression network 330 .
[0049] The positive and negative candidate region acquisition network 310 is used to obtain positive candidate regions and negative candidate regions corresponding to image samples based on image samples in an image sample set. The image sample set includes multiple sample subsets, and there are differences between the recognition targets corresponding to each sample subset. For example, different sample subsets can correspond to different recognition targets, and different recognition targets have different annotation information. In an embodiment of the present application, a candidate region refers to an area where a recognition target may exist. The recognition target refers to the target corresponding to the real annotation information, that is, the target that the image recognition model needs to recognize from the image sample, and different recognition tasks can correspond to different recognition targets. Exemplarily, taking the candidate region as an anchor (anchor point, also referred to as a candidate border, etc.) as an example, in an anchor-based scenario, the candidate region may refer to multiple anchors determined from an image sample according to a set rule, or may refer to multiple anchors determined from a feature map corresponding to an image sample according to a set rule. In an anchor-free scenario, the candidate region may refer to multiple anchors determined based on a key point or center corresponding to a certain target in a feature map, and the embodiment of the present application does not limit this. The embodiments of the present application do not limit the above-mentioned targets. For example, the target may refer to a specific person (such as student A and student B, etc.), a role, a vehicle, a plant, etc. The target may also refer to a certain type of person, a certain type of animal (such as cats and dogs), a certain type of vehicle, a certain type of plant, etc.
[0050] Optionally, in the anchor-based scenario, the positive and negative candidate region acquisition network 310 can be constructed based on FasterRCNN (Faster Region with CNN feature, a target detection neural network), SSD (Single ShotMultiBox Detector, a target detection neural network), YOLO (You Only Look Once, a target detection neural network), etc.; in the anchor-free scenario, the positive and negative candidate region acquisition network 310 can be constructed based on CornerNet, Grid RCNN, ExtremeNet, Sparse RCNN, etc.
[0051] For example, reference Figure 2 The positive and negative candidate region acquisition network 310 may include a data input layer 311 , a feature extraction layer 312 , a candidate feature extraction layer 313 , and a positive and negative sample division layer 314 .
[0052] Among them, the input of the data input layer 311 may include the image sample set corresponding to the image recognition model 30, the identifiers corresponding to multiple sample subsets in the image sample set, and the real annotation information corresponding to each image sample in the image sample set. The real annotation information may include real coordinate annotation information and real target annotation information. The real coordinate annotation information is used to indicate the real coordinates (i.e., position, area, etc.) of the identified target, and the real target annotation information is used to indicate the real category of the identified target. Exemplarily, when the annotation bounding box corresponding to the real target is a square box, the real coordinate annotation information corresponding to the real target can be represented by the coordinates of a pair of diagonal points or the center point + width*height or four sides of the square box corresponding to the real coordinates, and the real target annotation information corresponding to the real target can be represented by the name of the real target.
[0053] Optionally, the data input layer 311 can be used to generate classifier control codes corresponding to multiple sample subsets, which are used to determine the participation status of each classifier in the image recognition model during the training process. Exemplarily, the data input layer 311 determines the recognition targets corresponding to the n sample subsets based on the identification of the n sample subsets, and then determines the classifier control codes corresponding to the n sample subsets in combination with the classifier distribution corresponding to the image recognition model 30 (for example, one recognition target corresponds to one binary classifier). Optionally, the classifier control code can be one-dimensional data of the number of classifiers*1.
[0054] The feature extraction layer 312 is used to extract features from image samples to obtain feature maps corresponding to the image samples. Exemplarily, the feature extraction layer 312 can be constructed based on ResNet-50 (a convolutional network with 50 layers) and FPN (Feature Pyramid Networks). ResNet50 is used to extract features from image samples to obtain a multi-scale feature map sequence, which includes multiple intermediate feature maps of different scales obtained during the feature extraction process. Multiple intermediate feature maps of different scales in the multi-scale feature map sequence are fused through FPN to obtain a feature map corresponding to the image sample.
[0055] Among them, ResNet-50 can also be replaced by VGGNet (Visual Geometry Group Net, deep learning network), Resnet-101, etc.
[0056] Optionally, before extracting features from the image samples, the image samples may be preprocessed. Exemplarily, the image samples may be scaled to a set scale to obtain an adjusted image sample, and then feature extraction may be performed on the adjusted image sample through the feature extraction layer 312. The set scale may be adaptively set and adjusted according to actual use requirements. For example, take a set scale of 900*600 pixels as an example. In proportion, the image sample is scaled to an adjusted image sample with a long side of 900 pixels and a short side of 600 pixels, and then feature extraction may be performed on the adjusted image sample through the feature extraction layer 312. Wherein, in the case where the pixels on the long side or the short side are insufficient, zero padding may be performed. When using the image recognition model obtained in this way, the input image may be first scaled to the corresponding set scale, and then input into the image recognition model.
[0057] The candidate feature extraction layer 313 can be a neural network, which can be used to generate candidate regions on the above-mentioned feature map and obtain candidate features corresponding to each candidate region. Among them, the candidate region is used to indicate the area where the recognition target may exist, such as the above-mentioned anchor, candidate border, etc. The candidate features are used to characterize the predicted target and predicted coordinates corresponding to the candidate region. The predicted target refers to the prediction result of the image recognition model for the recognition target, and the predicted coordinates refer to the coordinate prediction result of the image recognition model for the recognition target.
[0058] Exemplarily, the candidate feature extraction layer 313 may include a candidate region generation sublayer and a candidate feature extraction sublayer. The candidate region generation sublayer generates multiple candidate regions at each point on the feature map according to the set rules. The candidate feature extraction sublayer is used to extract features from each candidate area respectively to obtain candidate features corresponding to each candidate area. For example, the size of the feature map is h*w, and each point on the feature map generates 9 candidate regions (the sizes of each candidate region are different), then the feature map corresponds to 9*h*w candidate regions. In some examples, the candidate feature extraction sublayer can be a RoiAlign layer (i.e., Region of Interest Align layer), and the candidate feature is a Roi feature.
[0059] The positive and negative sample division layer 314 is used to divide the candidate regions corresponding to the image samples to obtain a positive candidate region set and a negative candidate region set corresponding to the image samples. The positive candidate region set may include one or more positive candidate regions, and the negative candidate region set may include one or more negative candidate regions. The input of the positive and negative sample division layer 314 may include the real annotation information, candidate regions and candidate features corresponding to the image samples. Exemplarily, the positive and negative sample division layer 314 determines the predicted coordinates corresponding to the candidate region based on the candidate features corresponding to the candidate region, and then traverses the real coordinates corresponding to the real annotation information to determine the real coordinates that the predicted coordinates are most likely to correspond to. If the degree of coincidence between the predicted coordinates and the real coordinates that the predicted coordinates are most likely to correspond to meet the positive sample condition (such as greater than the first threshold value described below), the candidate region is determined as a positive candidate region; if the degree of coincidence between the predicted coordinates and the real coordinates that the predicted coordinates are most likely to correspond to meet the negative sample condition (such as less than the second threshold value described below), the candidate region is determined as a negative candidate region. The recognition target corresponding to the image sample is predicted to exist in the positive candidate region, and the recognition target corresponding to the image sample is predicted to not exist in the negative candidate region.
[0060] The coordinate regression network 320 is used to obtain the coordinate loss corresponding to the image sample, and the coordinate loss is used to characterize the difference between the predicted coordinates and the true coordinates. The input of the coordinate regression network 320 may include candidate features corresponding to each positive candidate region, and the coordinate regression network 320 obtains the coordinate loss corresponding to the image sample based on the candidate features corresponding to each positive candidate region and the true coordinates most likely corresponding to each positive candidate region through the coordinate loss function. Optionally, a Giou (Generalized Intersection over Union) Loss function, a SmoothL1 function, etc. can be used as a coordinate loss function.
[0061] The category regression network 330 includes multiple classifiers, each classifier corresponds to a recognition target. For example, a binary classifier is set for each recognition target. The category regression network 330 is used to obtain the classification loss corresponding to each classifier in the image recognition model, and the classification loss is used to characterize the difference between the predicted target and the real target. In an embodiment of the present application, the classification loss may include a first classification loss and a second classification loss, and the first classification loss is used to characterize the difference between the predicted target and the real target corresponding to each positive candidate region in the positive candidate region set; the second classification loss is used to characterize the difference between the predicted target and the real target corresponding to each negative candidate region in the negative candidate region set. Optionally, the category regression network 330 can use Sigmoid Focal Loss function, BCE (Binary CrossEntropy, binary cross entropy) Loss function, etc. to calculate the classification loss.
[0062] Exemplarily, for each positive candidate region, the category regression network 330 can determine, based on the classifier control code, which classifiers each positive candidate region needs to participate in the classification loss acquisition process corresponding to, and based on the classifier control code, determine which classifiers (such as the target classifier below) each negative candidate region needs to participate in the classification loss acquisition process corresponding to. For example, for each classifier, based on the candidate features corresponding to each positive candidate region corresponding to the image sample, the first classification loss corresponding to the image sample is obtained. For each target classifier, based on the candidate features corresponding to each negative candidate region corresponding to the image sample, the second classification loss corresponding to the image sample is obtained. Among them, each sample subset corresponds to its own target classifier set in the image recognition model 30, and the target classifier corresponding to the target sample subset corresponds to the recognition target corresponding to the target sample subset.
[0063] The above introduces the network architecture of the image recognition model. The following will introduce the training method of the image recognition model.
[0064] Please refer to Figure 3 , which shows a flow chart of a training method for an image recognition model provided by an embodiment of the present application. The execution subject of each step of the method can be the model training device introduced above. The method can include the following steps (301-305).
[0065] Step 301 : obtaining an image sample set, where the image sample set includes a plurality of sample subsets, and there are differences between the recognition targets corresponding to the respective sample subsets.
[0066] The technical solution provided in the embodiment of the present application is applicable to the scenario of joint training of multiple data, that is, the image recognition model is jointly trained through multiple sample subsets in the image sample set to obtain a trained image recognition model, and the trained image recognition model can be used to identify the recognition target corresponding to the image sample set. The image recognition model in the embodiment of the present application can be used for tasks such as image recognition, target detection, and image segmentation, which is the same as the above-mentioned embodiment. The parts not described in the embodiment of the present application can refer to the above-mentioned embodiment, and will not be repeated here.
[0067] Exemplarily, taking target detection as an example, assume that the image sample set includes three sample subsets, the first sample subset corresponds to clothing detection, the second sample subset corresponds to vehicle detection, and the third sample subset corresponds to pedestrian detection. The image recognition model obtained by jointly training the three sample subsets is suitable for the three tasks of clothing detection, vehicle detection and pedestrian detection.
[0068] Optionally, each sample subset may correspond to a different recognition target, and there may be partial overlap between the recognition targets corresponding to each sample subset, which is not limited in the present embodiment. Among them, the recognition target can be set and adjusted according to actual use requirements. For example, the recognition target may refer to a specific person (such as student A and student B, etc.), a role, a vehicle, a plant, etc. The recognition target may also refer to a certain type of person, a certain type of animal (such as cats and dogs), a certain type of vehicle, a certain type of plant, etc.
[0069] The multiple sample subsets may be from the same scene or from different scenes. For example, when the multiple sample subsets are from the same video, the multiple sample subsets may correspond to different characters respectively.
[0070] Step 302, for a target sample subset among multiple sample subsets, determine a target classifier set corresponding to the target sample subset from each classifier of the image recognition model; wherein the target classifier in the target classifier set corresponds to the recognition target corresponding to the target sample subset.
[0071] Each classifier of the image recognition model corresponds one-to-one to the recognition target corresponding to the image sample set. Optionally, a classifier can be set for each recognition target corresponding to the image sample set. In the case where the recognition targets corresponding to multiple sample subsets do not overlap, the number of classifiers corresponding to the image recognition model is equal to the sum of the number of recognition targets corresponding to the multiple sample subsets. For example, sample subset A corresponds to recognition target 1 and recognition target 2, and sample subset B corresponds to recognition target 3 and recognition target 4, then the image recognition model has a total of 4 classifiers. In the case where there is partial overlap between the recognition targets corresponding to multiple sample subsets, the number of classifiers in the image recognition model is equal to the number of recognition targets after deduplication. For example, sample subset A corresponds to recognition target 1 and recognition target 2, and sample subset B corresponds to recognition target 1 and recognition target 3, then the image recognition model has a total of 3 classifiers.
[0072] The target sample subset may refer to any sample subset of a plurality of sample subsets, and the target sample subset may correspond to one or more identification targets. The target classifier set includes a classifier corresponding to the target sample subset, that is, the target classifier refers to a classifier corresponding to the identification target corresponding to the target sample subset. Optionally, the target sample subset also corresponds to a non-target classifier set, and the non-target classifiers in the non-target classifier set correspond to the identification targets corresponding to the image sample set except the identification targets corresponding to the target sample subset. The non-target classifier set includes classifiers other than the target classifier in each classifier, that is, the non-target classifier refers to a classifier other than the target classifier. For example, there are sample subset A and sample subset B. For sample subset A, the classifiers corresponding to sample subset A constitute the target classifier set corresponding to sample subset A, and the classifiers corresponding to sample subset B constitute the non-target classifier set corresponding to sample subset A. Optionally, the target classifier set and the non-target classifier set corresponding to the target sample subset can be determined based on the classifier control code under the positive candidate region corresponding to the target sample subset.
[0073] In one example, the process of acquiring the target classifier set can be as follows: obtain the classifier control code corresponding to the target sample subset, and the classifier control code is used to determine the participation status of each classifier of the image recognition model in the classification loss acquisition process; according to the classifier control code, determine the target classifier set from the classifiers of the image recognition model; wherein the classifier control code is determined based on the recognition target corresponding to the image sample set and the classifier distribution corresponding to the image recognition model.
[0074] Optionally, the classifier control code may include a first element and a second element, the first element and the second element are different, and the element corresponding to the classifier control code corresponds one-to-one to the classifier in the image recognition model. The classifier corresponding to the first element may be determined as a target classifier, and the target classifier may be set to a participating state; the classifier corresponding to the second element may be determined as a non-target classifier, and the non-target classifier may be set to a non-participating state; wherein the non-target classifier refers to a classifier other than the target classifier in each classifier.
[0075] For example, reference Figure 4 , suppose that the target sample subset in the image sample set corresponds to recognition target 1, recognition target 2 and recognition target 3, and there are 5 different recognition targets corresponding to the image sample set, and the image recognition model corresponds to 5 classifiers. The target sample subset can correspond to classifier 1, classifier 2 and classifier 3 among the 5 classifiers. For example, take the first element as 1 and the second element as 0 as an example. Since the positive candidate region corresponding to the image sample participates in the training of all classifiers, for the target sample subset, the classifier control code corresponding to the positive candidate region can be set to [1, 1, 1, 1, 1]. Since the negative candidate region corresponding to the image sample only participates in the training of the target classifier corresponding to the target sample subset, for the target sample subset, the classifier control code corresponding to the negative candidate region can be set to [1, 1, 1, 0, 0]. Among them, 1 indicates that the corresponding classifier participates in the training, and 0 indicates that the corresponding classifier does not participate in the training of the negative candidate region corresponding to the image sample.
[0076] Optionally, after determining the positive candidate regions and negative candidate regions of the target image sample, a classifier control code may be generated. Exemplarily, a classifier control code is set for each negative candidate region to indicate which classifiers each negative candidate region needs to participate in the classification loss acquisition process. For each positive candidate region, since it can participate in the classification loss acquisition process corresponding to any classifier, the classifier control code may not be set additionally, or the default setting may be a classifier control code in which all elements are the first element.
[0077] In this way, the classifier control code can make the positive candidate area in a certain sample subset effective in other sample subsets, and the negative candidate area in a certain sample subset effective only in this sample subset, thereby solving the problem of suppressed training effect caused by conflicts in recognition targets between sample subsets, and thus improving the recognition accuracy of the image recognition model in the multi-data joint training scenario.
[0078] Step 303, for the target image samples in the target sample subset, determine the first classification loss corresponding to the target image samples based on the positive candidate regions corresponding to the target image samples through various classifiers; wherein the identified target corresponding to the image sample is predicted to exist in the positive candidate regions.
[0079] The target image sample may refer to any image sample in the target sample subset. The first classification loss is used to characterize the difference between the predicted target and the real target corresponding to each positive candidate region. The positive candidate region and the negative candidate region in the embodiment of the present application are the same as those described in the above embodiment. For the contents not described in this embodiment, please refer to the above embodiment, which will not be repeated here.
[0080] In an example, the positive and negative sample division layer 314 in the above embodiment may be used to complete the acquisition of the positive candidate region and the negative candidate region, and the specific content thereof may be as follows:
[0081] 1. Based on the real annotation information corresponding to the target image sample, a real coordinate set corresponding to the target image sample is obtained, and the real coordinate set includes the real coordinates of each recognized target corresponding to the target image sample.
[0082] The real marking information includes the real coordinate marking information and the real target marking information corresponding to the identified target. Optionally, the real coordinates corresponding to each identified target can be determined based on the real coordinate annotation information corresponding to each identified target in the real coordinate information.
[0083] 2. For a target candidate region among multiple candidate regions corresponding to the target image sample, determine the predicted coordinates corresponding to the target candidate region based on the candidate features corresponding to the target candidate region; wherein the candidate region is used to indicate a possible distribution area of the identified target corresponding to the image sample in the image sample.
[0084] The target candidate region may refer to any candidate region among multiple candidate regions. For example, based on the feature map at the h*w scale corresponding to the target image sample, 9*h*w candidate regions are obtained, and then feature extraction is performed on the 9*h*w candidate regions to obtain candidate features corresponding to the 9*h*w candidate regions. Logistic regression is performed on the candidate features corresponding to the target candidate region among the 9*h*w candidate regions to obtain the predicted coordinates corresponding to the target candidate region. The candidate features are used to characterize the predicted target and predicted coordinates corresponding to the candidate region.
[0085] 3. Calculate the predicted coordinates corresponding to the target candidate area with each real coordinate in the real coordinate set, and obtain the degree of fit between the predicted coordinates corresponding to the target candidate area and each real coordinate; wherein the degree of fit is used to characterize the degree of fit between the predicted coordinates and the real coordinates.
[0086] For example, taking the IoU value as an example, the predicted coordinates corresponding to the target candidate area are calculated with each real coordinate in the real coordinate set corresponding to the target image sample through the IoU value calculation formula to obtain the IoU value of the target candidate area at each real coordinate.
[0087] 4. If the maximum matching degree value corresponding to the target candidate region is greater than the first threshold, the target candidate region is determined as a positive candidate region.
[0088] The first threshold can be set and adjusted according to actual usage requirements, such as 0.5, 0.6, 0.7, etc. The larger the first threshold is, the better the quality of the positive candidate region is.
[0089] For example, the maximum IoU value is determined from the IoU values of the target candidate area at each real coordinate. The real coordinate corresponding to the maximum IoU value is the real coordinate that the target candidate area is most likely to correspond to, and the predicted target corresponding to the target candidate area is most likely to be the real target corresponding to the real coordinate. If the maximum IoU value is greater than 0.5, the target candidate area is determined as a positive candidate area. Optionally, the real annotation information corresponding to the maximum IoU value can be determined as the real annotation information corresponding to the target candidate area.
[0090] 5. If the maximum matching degree value corresponding to the target candidate region is less than the second threshold, the target candidate region is determined as a negative candidate region.
[0091] The second threshold can be set and adjusted according to actual use requirements, such as 0.3, 0.4, etc. The smaller the first threshold, the better the quality of the negative candidate region. The first threshold is greater than the second threshold.
[0092] For example, if the maximum IoU value is less than 0.4, the target candidate region is determined as a negative candidate region.
[0093] Optionally, for the positive candidate region, the corresponding first classification loss includes two parts, one part corresponds to the target classifier corresponding to the current sample subset, and the other part corresponds to the non-target classifier corresponding to other sample subsets outside the current sample subset.
[0094] In an example, the specific process of obtaining the first classification loss can be as follows:
[0095] 1. Based on the candidate features corresponding to each positive candidate region, obtain the predicted target of each positive candidate region under each classifier.
[0096] For example, for a first classifier among multiple classifiers, through the first classifier, based on the candidate features corresponding to each positive candidate region, the predicted targets of each positive candidate region under the first classifier can be obtained. The first classifier may refer to any classifier among the classifiers.
[0097] 2. For the first target classifier in the target classifier set corresponding to the target sample subset, based on the predicted targets of each positive candidate region under the first target classifier and the real targets corresponding to each positive candidate region, determine the classification loss of each positive candidate region under the first target classifier.
[0098] The first target classifier may refer to any target classifier in the target classifier set.
[0099] For example, for a target positive candidate region among multiple positive candidate regions, the classification loss of the target positive candidate region under the first target classifier is determined through a Sigmoid Focal Loss function based on the predicted target of the target positive candidate region under the first target classifier and the true target corresponding to the target positive candidate region.
[0100] 3. The sum of the classification losses of each positive candidate region under the first target classifier is determined as the classification loss corresponding to the first target classifier.
[0101] 4. For the first non-target classifier in the non-target classifier set corresponding to the target sample subset, determine the classification loss of each positive candidate region under the first non-target classifier based on the predicted target of each positive candidate region under the first non-target classifier and the second labeling information corresponding to each positive candidate region; wherein the second labeling information is used to indicate that the predicted target corresponding to the positive candidate region is not the identification target corresponding to the sample subset outside the target sample subset.
[0102] The first non-target classifier may refer to any non-target classifier in the non-target classifier set. For example, for a target positive candidate region in each positive candidate region, the classification loss of the target positive candidate region under the first non-target classifier is determined by a Sigmoid Focal Loss function based on the predicted target of the target positive candidate region under the first non-target classifier and the second annotation information corresponding to the target positive candidate region.
[0103] Among them, the second annotation information can be determined according to the identification target corresponding to the target sample subset corresponding to the positive candidate area. For example, sample subset 1 corresponds to two identification targets A and B, and sample subset 2 corresponds to two identification targets C and D. For the positive candidate area corresponding to sample subset 1, it is highly likely to be A or B, not C or D. Therefore, in the non-target classifier calculation scenario, the real targets corresponding to the positive candidate area can be set to 0 to indicate that the target corresponding to the positive candidate area is not C or D.
[0104] 5. The sum of the classification losses of each positive candidate region under the first non-target classifier is determined as the classification loss corresponding to the first non-target classifier.
[0105] 6. Based on the classification losses corresponding to each target classifier in the target classifier set and the classification losses corresponding to each non-target classifier in the non-target classifier set, determine the first classification loss corresponding to the target image sample.
[0106] Optionally, the sum of the classification losses corresponding to each target classifier and the classification losses corresponding to each non-target classifier can be determined as the first classification loss corresponding to the target image sample.
[0107] Step 304, determining a second classification loss corresponding to the target image sample based on each negative candidate region corresponding to the target image sample only by the target classifier in the target classifier set; wherein the identification target corresponding to the image sample is predicted to not exist in the negative candidate region.
[0108] Among them, the second classification loss is used to characterize the difference between the predicted target and the true target corresponding to each negative candidate region. The non-target classifier in the non-target classifier set does not participate in the acquisition process of the second classification loss. Optionally, the non-target classifier can directly not classify the negative candidate region to achieve the acquisition of the negative candidate region not participating in the second classification loss. The non-target classifier can also classify the negative candidate region, but the obtained predicted target does not participate in the acquisition of the second classification loss, so as to achieve the acquisition process of the negative candidate region not participating in the second classification loss.
[0109] In one example, the process of obtaining the second classification loss can be as follows:
[0110] 1. Set the labeling information corresponding to each negative candidate region as the first labeling information, where the first labeling information is used to indicate that the predicted target corresponding to the negative candidate region is not the recognized target corresponding to the target sample subset.
[0111] For example, suppose that sample subset 1 corresponds to two recognition targets A and B, and sample subset 2 corresponds to two recognition targets C and D. For the negative candidate region corresponding to sample subset 1, it is highly likely not to be A and B. Therefore, when obtaining the classification loss corresponding to the negative candidate region, the true targets corresponding to the negative candidate region can be set to 0 to indicate that the targets corresponding to the negative candidate region are not A and B. Since it is uncertain whether the predicted target corresponding to the negative candidate region is C or D, the negative candidate region corresponding to sample subset 1 does not participate in the training of the target classifier corresponding to sample subset 2.
[0112] 2. For the first target classifier in the target classifier set, based on the candidate features corresponding to each negative candidate region, determine the predicted target of each negative candidate region under the first target classifier; wherein the candidate features are used to characterize the predicted target and predicted coordinates corresponding to the candidate region.
[0113] The first target classifier may refer to any target classifier in the target classifier set. For example, for a target negative candidate region among multiple negative candidate regions, the first target classifier may be used to classify the target negative candidate region based on the candidate features corresponding to the target negative candidate region to obtain a predicted target of the target negative candidate region under the first target classifier.
[0114] 3. Based on the predicted targets of each negative candidate region under the first target classifier and the first annotation information, determine the classification loss of each negative candidate region under the first target classifier.
[0115] For example, for a target negative candidate region in each negative candidate region, the classification loss of the target negative candidate region under the first target classifier is determined by a Sigmoid Focal Loss function based on the predicted target of the target negative candidate region under the first target classifier and the first annotation information.
[0116] 4. The sum of the classification losses of each negative candidate region under the first target classifier is determined as the classification loss corresponding to the first target classifier.
[0117] 5. Based on the classification losses corresponding to the target classifiers in the target classifier set, determine the second classification loss corresponding to the target image sample.
[0118] Optionally, the sum of the classification losses respectively corresponding to the target classifiers in the target classifier set may be determined as the second classification loss corresponding to the target image sample.
[0119] Optionally, the first category loss and the second category loss may be obtained simultaneously or in a sequential order, which is not limited in the embodiment of the present application.
[0120] Step 305, based on the first classification loss and the second classification loss respectively corresponding to each image sample in the image sample set, the image recognition model is trained to obtain a trained image recognition model, and each classifier in the trained image recognition model is used to identify the recognition target corresponding to the image sample set.
[0121] Optionally, the remaining image samples are processed respectively using the same method as the target image samples, so as to obtain the first classification loss and the second classification loss corresponding to the remaining image samples respectively.
[0122] In one example, the image recognition model may also correspond to a coordinate loss, which is used to characterize the difference between the predicted coordinates and the true coordinates. The process of obtaining the coordinate loss may be as follows:
[0123] The true coordinates corresponding to the positive candidate region at the maximum degree of fit are determined as the true coordinates corresponding to the positive candidate region; based on the candidate features corresponding to each positive candidate region, the predicted coordinates corresponding to each positive candidate region are determined; based on the predicted coordinates and the true coordinates corresponding to each positive candidate region, the coordinate loss corresponding to the target image sample is determined, and the coordinate loss is used to characterize the difference between the predicted coordinates and the true coordinates.
[0124] For example, for the target positive candidate region, the Giou Loss function is used to determine the sub-coordinate loss corresponding to the target positive candidate region based on the predicted coordinates and the true coordinates corresponding to the target positive candidate region, and the sum of the sub-coordinate losses corresponding to each positive candidate region is determined as the coordinate loss corresponding to the target image sample.
[0125] In one example, the training process of the image recognition model can be as follows: based on the coordinate loss corresponding to each image sample, the coordinate regression network in the image recognition model is trained, based on the first classification loss and the second classification loss corresponding to each image sample, the category regression network in the image recognition model is trained, and based on the coordinate loss, the first classification loss and the second classification loss corresponding to each image sample, the remaining network in the image recognition model is trained to obtain a trained image recognition model.
[0126] Among them, the category regression network includes each classifier of the image recognition model. The remaining network in the image recognition model refers to the network other than the category regression network and the coordinate regression network, such as the above-mentioned positive and negative candidate area acquisition network 310. For the target classifier in the category regression network, the target classifier is trained based on the first classification loss and the second classification loss corresponding to the image sample, and for the non-target classifier in the category regression network, the non-target classifier is trained based on the first classification loss corresponding to the image sample. With the goal of minimizing the coordinate loss, the first classification loss and the second classification loss, the image recognition model is iteratively trained to obtain a trained image recognition model.
[0127] Optionally, during the use of the trained image recognition model, it is only necessary to input the input image into the trained image recognition model to obtain the coordinate prediction results output by the coordinate regression network and the target prediction results output by each classifier. The target prediction result with the largest probability value among the target prediction results can be determined as the final target prediction result.
[0128] To summarize, the technical solution provided by the embodiments of the present application determines the target classifier corresponding to the target sample subset from the classifiers corresponding to the image recognition model, and determines the classification loss of the negative candidate region under the target classifier based on the negative candidate region corresponding to the image samples in the target sample subset (such as anchor negative samples) through the target classifier, so that the negative candidate region corresponding to the target sample subset does not participate in the training of classifiers other than the target classifier, thereby achieving that the negative candidate region corresponding to the target sample subset is effective only in the target sample subset, solving the problem in the related art that the training effect is suppressed due to the conflict of recognition targets between the image sample sets, thereby improving the recognition accuracy of the image recognition model in the multi-data joint training scenario.
[0129] In addition, since the positive candidate regions corresponding to the image samples in the target sample subset (such as anchor positive samples) can participate in the training of all classifiers corresponding to the image recognition model, the negative information corresponding to the sample subsets outside the target sample subset is enriched, thereby further improving the recognition accuracy of the image recognition model in the multi-data joint training scenario.
[0130] In an exemplary embodiment, taking the use of an image recognition model to detect characters in a video as an example, a training method for the image recognition model is introduced, which may include the following content.
[0131] For the target video, in the initial stage, the image recognition model only needs to detect characters A, B, C, and D (i.e., the above-mentioned recognition targets). For characters A, B, C, and D, a set of image samples with real annotation information is compiled based on the target video 1. As the business deepens, new recognition targets are required: characters E, F, and G. For characters E, F, and G, a set of image samples with real annotation information is compiled based on the target video 2.
[0132] Among them, the image sample set 1 does not carry the real annotation information for the characters E, F and G, and the image sample set 2 does not carry the real annotation information for the characters A, B, C and D.
[0133] In the new training process, image sample set 1 and image sample set 2 can be used as sample subset 1 and sample subset 2 in the image sample set corresponding to the image recognition model, so that the image recognition model can be jointly trained based on image sample set 1 and image sample set 2. The specific content can be as follows:
[0134] The image recognition model is reset to have 7 binary classifiers, which correspond to character A, character B, character C, character D, character E, character F and character G respectively.
[0135] For image sample set 1, the classifier control code corresponding to the positive candidate region can be set to [1, 1, 1, 1, 1, 1], and the classifier control code corresponding to the negative candidate region can be set to [1, 1, 1, 1, 0, 0, 0]. For image sample set 2, the classifier control code corresponding to the positive candidate region can be set to [1, 1, 1, 1, 1, 1, 1], and the classifier control code corresponding to the negative candidate region can be set to [0, 0, 0, 0, 1, 1, 1].
[0136] For the positive candidate regions in the image sample set 1, we can clearly know their corresponding recognition targets (i.e., character A or character B or character C or character D), so the positive candidate regions in the image sample set 1 can participate in the training of all binary classifiers. For the negative candidate regions in the image sample set 1, we only know that they cannot be character A, character B, character C, and character D, but we are not sure whether they are character E, character F, or character G. Therefore, the negative candidate regions in the image sample set 1 only participate in the training of the binary classifier corresponding to the image sample set 1. This idea also applies to the image sample set 2.
[0137] The following will take image sample set 1 as an example to illustrate the training process of the image recognition model.
[0138] For the target image sample in the image sample set 1, the positive candidate region set and the negative candidate region set corresponding to the target image sample are obtained through the image recognition model. The positive candidate region set includes multiple positive candidate regions, and the negative candidate region set includes multiple negative candidate regions.
[0139] For binary classifiers 1-4 corresponding to characters A, B, C, and D, respectively, based on the candidate features and true annotation information corresponding to each positive candidate region in the positive candidate region set, the positive classification loss under binary classifiers 1-4 is obtained. For binary classifiers 5-7 corresponding to characters E, F, and G, respectively, based on the candidate features and second annotation information corresponding to each positive candidate region in the positive candidate region set, the positive classification loss under binary classifiers 5-7 is obtained. Based on the positive classification loss under binary classifiers 1-4 and the positive classification loss under binary classifiers 5-7, the first classification loss corresponding to the target image sample is determined.
[0140] According to the classifier control code corresponding to the negative candidate region, the binary classifiers 1-4 corresponding to the characters A, B, C and D are set to a participating state, and the binary classifiers 5-7 corresponding to the characters E, F and G are set to a non-participating state. Based on the candidate features and the first annotation information corresponding to each negative candidate region in the negative candidate region set, the negative classification loss under the binary classifiers 1-4 is obtained, and based on the negative classification loss under the binary classifiers 1-4, the second classification loss corresponding to the target image sample is determined.
[0141] Based on the candidate features and true coordinates of each positive candidate region in the positive candidate region set, the coordinate loss corresponding to the target image sample is obtained.
[0142] The coordinate regression network in the image recognition model is trained based on the coordinate loss, the binary classifiers 1-4 are trained based on the positive classification loss and negative classification loss under the binary classifiers 1-4, and the binary classifiers 5-7 are trained based on the positive classification loss under the binary classifiers 5-7. The image recognition model is jointly iteratively trained based on the image samples in the image sample set 1 and the image sample set 2 to obtain a trained image recognition model. The trained image recognition model can be used to detect character A, character B, character C, character D, character E, character F, and character G.
[0143] In another example, refer to Figure 5The image recognition model is applied to the traffic scene. After the image recognition model is jointly trained by the image sample set corresponding to the detection tasks supporting trains and tracks, and the image sample set corresponding to the detection tasks supporting the sky, signboards, and signposts, the obtained image recognition model can detect trains, tracks, the sky, signboards, and signposts. For example, the image recognition model can identify trains, tracks, the sky, signboards, and signposts from the input pattern 501.
[0144] To summarize, the technical solution provided by the embodiments of the present application determines the target classifier corresponding to the target sample subset from the classifiers corresponding to the image recognition model, and determines the classification loss of the negative candidate region under the target classifier based on the negative candidate region corresponding to the image samples in the target sample subset (such as anchor negative samples) through the target classifier, so that the negative candidate region corresponding to the target sample subset does not participate in the training of classifiers other than the target classifier, thereby achieving that the negative candidate region corresponding to the target sample subset is effective only in the target sample subset, solving the problem in the related art that the training effect is suppressed due to the conflict of recognition targets between the image sample sets, thereby improving the recognition accuracy of the image recognition model in the multi-data joint training scenario.
[0145] In addition, since the positive candidate regions corresponding to the image samples in the target sample subset (such as anchor positive samples) can participate in the training of all classifiers corresponding to the image recognition model, the negative information corresponding to the sample subsets outside the target sample subset is enriched, thereby further improving the recognition accuracy of the image recognition model in the multi-data joint training scenario.
[0146] The following are device embodiments of the present application, which can be used to execute the method embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments of the present application.
[0147] Please refer to Figure 6 , which shows a block diagram of a training device for an image recognition model provided by an embodiment of the present application. The device can be used to implement the training method of the above-mentioned image recognition model. The device 600 may include: a sample set acquisition module 601, a target classifier determination module 602, a classification loss acquisition module 603 and a recognition model training module 604.
[0148] The sample set acquisition module 601 is used to acquire an image sample set, wherein the image sample set includes a plurality of sample subsets, and there are differences between the recognition targets corresponding to the respective sample subsets.
[0149] The target classifier determination module 602 is used to determine, for a target sample subset among the multiple sample subsets, a target classifier set corresponding to the target sample subset from the classifiers of the image recognition model; wherein the target classifiers in the target classifier set correspond to the recognition targets corresponding to the target sample subset.
[0150] The classification loss acquisition module 603 is used to determine, for the target image samples in the target sample subset, the first classification loss corresponding to the target image samples based on the positive candidate regions corresponding to the target image samples through the respective classifiers; wherein the identified target corresponding to the image sample is predicted to exist in the positive candidate regions.
[0151] The classification loss acquisition module 603 is also used to determine the second classification loss corresponding to the target image sample based on each negative candidate area corresponding to the target image sample only through the target classifier in the target classifier set; wherein, the identification target corresponding to the image sample is predicted to not exist in the negative candidate area.
[0152] The recognition model training module 604 is used to train the image recognition model based on the first classification loss and the second classification loss respectively corresponding to each image sample in the image sample set to obtain the trained image recognition model, and each classifier in the trained image recognition model is used to identify the recognition target corresponding to the image sample set.
[0153] In an exemplary embodiment, the classification loss acquisition module 603 is used to:
[0154] respectively setting the labeling information corresponding to each negative candidate region as first labeling information, where the first labeling information is used to indicate that the predicted target corresponding to the negative candidate region is not the identified target corresponding to the target sample subset;
[0155] For a first target classifier in the target classifier set, based on candidate features corresponding to each negative candidate region, respectively, determining a predicted target of each negative candidate region under the first target classifier; wherein the candidate features are used to characterize a predicted target and a predicted coordinate corresponding to the candidate region;
[0156] Determine, based on the predicted targets of each negative candidate region under the first target classifier and the first labeling information, the classification loss of each negative candidate region under the first target classifier;
[0157] Determine the sum of the classification losses of the negative candidate regions under the first target classifier as the classification loss corresponding to the first target classifier;
[0158] Based on the classification losses respectively corresponding to the target classifiers in the target classifier set, a second classification loss corresponding to the target image sample is determined.
[0159] In an exemplary embodiment, the target classifier determination module 602 is used to:
[0160] Obtaining a classifier control code corresponding to the target sample subset, wherein the classifier control code is used to determine the participation status of each classifier of the image recognition model in the training process;
[0161] Determining the target classifier set and the non-target classifier set from the classifiers of the image recognition model according to the classifier control code;
[0162] The classifier control code is determined based on the recognition target corresponding to the image sample set and the classifier distribution corresponding to the image recognition model.
[0163] In an exemplary embodiment, the classifier control code includes a first element and a second element, the first element and the second element are different, and the element corresponding to the classifier control code corresponds one-to-one to the classifier in the image recognition model; the target classifier determination module 602 is further used to:
[0164] Obtaining a classifier control code corresponding to the target sample subset, wherein the classifier control code is used to determine the participation status of each classifier of the image recognition model in the classification loss acquisition process;
[0165] According to the classifier control code, the target classifier set is determined from the classifiers of the image recognition model; wherein the classifier control code is determined based on the recognition target corresponding to the image sample set and the classifier distribution corresponding to the image recognition model.
[0166] In an exemplary embodiment, the classification loss acquisition module 603 is further used to:
[0167] Based on the candidate features respectively corresponding to the positive candidate regions, obtaining the predicted targets of the positive candidate regions under the classifiers respectively;
[0168] For a first target classifier in the target classifier set corresponding to the target sample subset, based on the predicted targets of each positive candidate region under the first target classifier and the real targets corresponding to each positive candidate region, determining the classification loss of each positive candidate region under the first target classifier;
[0169] Determine the sum of the classification losses of the positive candidate regions under the first target classifier as the classification loss corresponding to the first target classifier;
[0170] For a first non-target classifier in the non-target classifier set corresponding to the target sample subset, based on the predicted targets of the respective positive candidate regions under the first non-target classifier and the second labeling information corresponding to the respective positive candidate regions, determining the classification loss of the respective positive candidate regions under the first non-target classifier; wherein the second labeling information is used to indicate that the predicted target corresponding to the positive candidate region is not the identification target corresponding to the sample subset outside the target sample subset;
[0171] Determine the sum of the classification losses of the positive candidate regions under the first non-target classifier as the classification loss corresponding to the first non-target classifier;
[0172] Based on the classification losses respectively corresponding to each target classifier in the target classifier set and the classification losses respectively corresponding to each non-target classifier in the non-target classifier set, a first classification loss corresponding to the target image sample is determined.
[0173] In an exemplary embodiment, Figure 7 As shown, the device 600 further includes: a real coordinate acquisition module 605 , a predicted coordinate acquisition module 606 , a matching value acquisition module 607 , a positive sample acquisition module 608 and a negative sample acquisition module 609 .
[0174] The real coordinate acquisition module 605 is used to acquire the real coordinate set corresponding to the target image sample based on the real annotation information corresponding to the target image sample, and the real coordinate set includes the real coordinates of each recognized target corresponding to the target image sample.
[0175] The predicted coordinate acquisition module 606 is used to determine the predicted coordinates corresponding to a target candidate area among multiple candidate areas corresponding to the target image sample based on the candidate features corresponding to the target candidate area; wherein the candidate area is used to indicate the possible distribution area of the identified target corresponding to the image sample in the image sample.
[0176] The matching value acquisition module 607 is used to calculate the predicted coordinates corresponding to the target candidate area with each real coordinate in the real coordinate set, and obtain the matching degree values between the predicted coordinates corresponding to the target candidate area and each real coordinate; wherein the matching degree value is used to characterize the matching degree between the predicted coordinates and the real coordinates.
[0177] The positive sample acquisition module 608 is configured to determine the target candidate region as the positive candidate region if the maximum matching degree value corresponding to the target candidate region is greater than a first threshold.
[0178] The negative sample acquisition module 609 is configured to determine the target candidate region as the negative candidate region if the maximum matching degree value corresponding to the target candidate region is less than a second threshold; wherein the first threshold is greater than the second threshold.
[0179] In an exemplary embodiment, Figure 7 As shown, the device 600 further includes: a real coordinate determination module 610 and a coordinate loss acquisition module 611.
[0180] The real coordinate determination module 610 is used to determine the real coordinates corresponding to the positive candidate region at the maximum matching degree value as the real coordinates corresponding to the positive candidate region.
[0181] The predicted coordinate acquisition module 606 is further configured to determine the predicted coordinates corresponding to each of the positive candidate regions based on the candidate features corresponding to each of the positive candidate regions.
[0182] The coordinate loss acquisition module 611 is used to determine the coordinate loss corresponding to the target image sample based on the predicted coordinates and the real coordinates corresponding to each positive candidate area, and the coordinate loss is used to characterize the difference between the predicted coordinates and the real coordinates.
[0183] In an exemplary embodiment, the recognition model training module 604 is used to:
[0184] Based on the coordinate losses corresponding to the respective image samples, the coordinate regression network in the image recognition model is trained; based on the first classification loss and the second classification loss corresponding to the respective image samples, the category regression network in the image recognition model is trained; and based on the coordinate loss, the first classification loss and the second classification loss corresponding to the respective image samples, the remaining network in the image recognition model is trained to obtain the trained image recognition model;
[0185] Wherein, the category regression network includes each classifier of the image recognition model.
[0186] To summarize, the technical solution provided by the embodiments of the present application determines the target classifier corresponding to the target sample subset from the classifiers corresponding to the image recognition model, and determines the classification loss of the negative candidate region under the target classifier based on the negative candidate region corresponding to the image samples in the target sample subset (such as anchor negative samples) through the target classifier, so that the negative candidate region corresponding to the target sample subset does not participate in the training of classifiers other than the target classifier, thereby achieving that the negative candidate region corresponding to the target sample subset is effective only in the target sample subset, solving the problem in the related art that the training effect is suppressed due to the conflict of recognition targets between the image sample sets, thereby improving the recognition accuracy of the image recognition model in the multi-data joint training scenario.
[0187] In addition, since the positive candidate regions corresponding to the image samples in the target sample subset (such as anchor positive samples) can participate in the training of all classifiers corresponding to the image recognition model, the negative information corresponding to the sample subsets outside the target sample subset is enriched, thereby further improving the recognition accuracy of the image recognition model in the multi-data joint training scenario.
[0188] It should be noted that the device provided in the above embodiment, when implementing its functions, is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.
[0189] Please refer to Figure 8 , which shows a schematic diagram of the structure of a computer device provided by an embodiment of the present application. The computer device can be any electronic device with data calculation, processing and storage functions, and the computer device can be implemented as Figure 1 The model training device 10 and / or the model using device 20 in the implementation environment of the illustrated solution may specifically include the following contents.
[0190] The computer device 800 includes a central processing unit (such as a CPU (Central Processing Unit), a GPU (Graphics Processing Unit) and an FPGA (Field Programmable Gate Array)) 801, a system memory 804 including a RAM (Random-Access Memory) 802 and a ROM (Read-Only Memory) 803, and a system bus 805 connecting the system memory 804 and the central processing unit 801. The computer device 800 also includes a basic input / output system (Input Output System, I / O system) 806 for helping various devices in the server to transmit information, and a large-capacity storage device 807 for storing an operating system 813, application programs 814 and other program modules 815.
[0191] In some embodiments, the basic input / output system 806 includes a display 808 for displaying information and an input device 809 such as a mouse and a keyboard for user inputting information. The display 808 and the input device 809 are connected to the central processing unit 801 via an input / output controller 810 connected to the system bus 805. The basic input / output system 806 may also include an input / output controller 810 for receiving and processing inputs from a plurality of other devices such as a keyboard, a mouse, or an electronic stylus. Similarly, the input / output controller 810 also provides output to a display screen, a printer, or other types of output devices.
[0192] The mass storage device 807 is connected to the central processing unit 801 via a mass storage controller (not shown) connected to the system bus 805. The mass storage device 807 and its associated computer readable medium provide non-volatile storage for the computer device 800. That is, the mass storage device 807 may include a computer readable medium (not shown) such as a hard disk or a CD-ROM (Compact Disc Read-Only Memory) drive.
[0193] Without loss of generality, the computer-readable medium may include computer storage media and communication media. Computer storage media include volatile and non-volatile, removable and non-removable media implemented by any method or technology for storing information such as computer-readable instructions, data structures, program modules or other data. Computer storage media include RAM, ROM, EPROM (Erasable Programmable Read-Only Memory), EEPROM (Electrically Erasable Programmable Read-Only Memory), flash memory or other solid-state storage technology, CD-ROM, DVD (Digital Video Disc) or other optical storage, cassettes, tapes, disk storage or other magnetic storage devices. Of course, those skilled in the art will know that the computer storage medium is not limited to the above. The above-mentioned system memory 804 and mass storage device 807 can be collectively referred to as memory.
[0194] According to the embodiment of the present application, the computer device 800 can also be connected to a remote computer on the network through a network such as the Internet. That is, the computer device 800 can be connected to the network 812 through the network interface unit 811 connected to the system bus 805, or the network interface unit 811 can be used to connect to other types of networks or remote computer systems (not shown).
[0195] The memory also includes a computer program, which is stored in the memory and configured to be executed by one or more processors to implement the above-mentioned training method of the image recognition model.
[0196] In an exemplary embodiment, a computer-readable storage medium is also provided, wherein a computer program is stored in the storage medium, and when the computer program is executed by a processor, the training method of the above-mentioned image recognition model is implemented.
[0197] Optionally, the computer readable storage medium may include: ROM (Read-Only Memory), RAM (Random-Access Memory), SSD (Solid State Drives) or optical disks, etc. Among them, the random access memory may include ReRAM (Resistance Random Access Memory) and DRAM (Dynamic Random Access Memory).
[0198] In an exemplary embodiment, a computer program product or a computer program is also provided, wherein the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above-mentioned training method of the image recognition model.
[0199] It should be noted that the information (including but not limited to the subject's device information, subject's personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.) and signals involved in this application are all authorized by the subject or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions. For example, the image samples, videos, real annotation information, etc. involved in this application are all obtained with full authorization.
[0200] It should be understood that the "multiple" mentioned in this article refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. In addition, the step numbers described in this article only illustrate a possible execution sequence between the steps. In some other embodiments, the above steps may not be executed in the order of the numbers, such as two steps with different numbers are executed at the same time, or two steps with different numbers are executed in the opposite order to the diagram. The embodiments of the present application are not limited to this.
[0201] The above description is only an exemplary embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.
Claims
1. A training method for an image recognition model, characterized in that: The method comprises: Acquire an image sample set, wherein the image sample set includes a plurality of sample subsets, and there are differences between the recognition targets corresponding to the respective sample subsets; For a target sample subset among the multiple sample subsets, determining a target classifier set corresponding to the target sample subset from the classifiers of the image recognition model; wherein the target classifiers in the target classifier set correspond to the recognition targets corresponding to the target sample subset; For a target image sample in the target sample subset, determining a first classification loss corresponding to the target image sample based on each positive candidate region corresponding to the target image sample by each classifier; wherein the recognition target corresponding to the image sample is predicted to exist in the positive candidate region; respectively setting the annotation information corresponding to each negative candidate region corresponding to the target image sample as the first annotation information, wherein the negative candidate region is predicted to contain no recognition target corresponding to the image sample, and the first annotation information is used to indicate that the predicted target corresponding to the negative candidate region is not the recognition target corresponding to the target sample subset; For a first target classifier in the target classifier set, based on candidate features corresponding to each negative candidate region, respectively, determining a predicted target of each negative candidate region under the first target classifier, wherein the candidate features are used to characterize a predicted target and a predicted coordinate corresponding to the candidate region; Determine, based on the predicted targets of each negative candidate region under the first target classifier and the first labeling information, the classification loss of each negative candidate region under the first target classifier; Determine the sum of the classification losses of the negative candidate regions under the first target classifier as the classification loss corresponding to the first target classifier; Determining a second classification loss corresponding to the target image sample based on the classification losses respectively corresponding to the target classifiers in the target classifier set; Based on the first classification loss and the second classification loss respectively corresponding to each image sample in the image sample set, the image recognition model is trained to obtain the trained image recognition model, and each classifier in the trained image recognition model is used to identify the recognition target corresponding to the image sample set.
2. The method according to claim 1, characterized in that Determining a target classifier set corresponding to the target sample subset from the classifiers of the image recognition model includes: Obtaining a classifier control code corresponding to the target sample subset, wherein the classifier control code is used to determine the participation status of each classifier of the image recognition model in the classification loss acquisition process; Determining the target classifier set from the classifiers of the image recognition model according to the classifier control code; The classifier control code is determined based on the recognition target corresponding to the image sample set and the classifier distribution corresponding to the image recognition model.
3. The method according to claim 2, characterized in that The classifier control code includes a first element and a second element, the first element and the second element are different, and the elements corresponding to the classifier control code correspond one-to-one to the classifiers in the image recognition model; Determining the target classifier set from the classifiers of the image recognition model according to the classifier control code includes: Determine the classifier corresponding to the first element as the target classifier, and set the target classifier to a participating state; The classifier corresponding to the second element is determined as a non-target classifier, and the non-target classifier is set to a non-participating state; wherein the non-target classifier refers to a classifier other than the target classifier among the classifiers.
4. The method according to claim 1, characterized in that: The determining, by the respective classifiers and based on the respective positive candidate regions corresponding to the target image samples, a first classification loss corresponding to the target image samples comprises: Based on the candidate features respectively corresponding to the positive candidate regions, obtaining the predicted targets of the positive candidate regions under the classifiers respectively; For a first target classifier in the target classifier set corresponding to the target sample subset, based on the predicted targets of each positive candidate region under the first target classifier and the real targets corresponding to each positive candidate region, determining the classification loss of each positive candidate region under the first target classifier; Determine the sum of the classification losses of the positive candidate regions under the first target classifier as the classification loss corresponding to the first target classifier; For a first non-target classifier in the non-target classifier set corresponding to the target sample subset, based on the predicted targets of the respective positive candidate regions under the first non-target classifier and the second labeling information corresponding to the respective positive candidate regions, determining the classification loss of the respective positive candidate regions under the first non-target classifier; wherein the second labeling information is used to indicate that the predicted target corresponding to the positive candidate region is not the identification target corresponding to the sample subset outside the target sample subset; Determine the sum of the classification losses of the positive candidate regions under the first non-target classifier as the classification loss corresponding to the first non-target classifier; Based on the classification losses respectively corresponding to each target classifier in the target classifier set and the classification losses respectively corresponding to each non-target classifier in the non-target classifier set, a first classification loss corresponding to the target image sample is determined.
5. The method according to claim 1, characterized in that The method further comprises: Based on the real annotation information corresponding to the target image sample, a real coordinate set corresponding to the target image sample is acquired, wherein the real coordinate set includes the real coordinates of each recognized target corresponding to the target image sample; For a target candidate region among the multiple candidate regions corresponding to the target image sample, determining a predicted coordinate corresponding to the target candidate region based on a candidate feature corresponding to the target candidate region; wherein the candidate region is used to indicate a possible distribution area of the identified target corresponding to the image sample in the image sample; Calculating the predicted coordinates corresponding to the target candidate region with each real coordinate in the real coordinate set, respectively, to obtain the matching degree values between the predicted coordinates corresponding to the target candidate region and each real coordinate; wherein the matching degree values are used to represent the matching degree between the predicted coordinates and the real coordinates; If the maximum matching degree value corresponding to the target candidate region is greater than a first threshold, the target candidate region is determined as the positive candidate region; If the maximum matching degree value corresponding to the target candidate region is less than a second threshold, the target candidate region is determined as the negative candidate region; The first threshold is greater than the second threshold.
6. The method according to claim 5, characterized in that The method further comprises: Determine the real coordinates corresponding to the positive candidate region at the maximum matching degree value as the real coordinates corresponding to the positive candidate region; Determining predicted coordinates corresponding to each of the positive candidate regions based on the candidate features corresponding to each of the positive candidate regions; Based on the predicted coordinates and the real coordinates corresponding to each of the positive candidate regions, a coordinate loss corresponding to the target image sample is determined, where the coordinate loss is used to characterize the difference between the predicted coordinates and the real coordinates.
7. The method according to any one of claims 1 to 6, characterized in that: The training of the image recognition model based on the first classification loss and the second classification loss respectively corresponding to each image sample in the image sample set to obtain the trained image recognition model comprises: Based on the coordinate losses respectively corresponding to the image samples, the coordinate regression network in the image recognition model is trained; based on the first classification loss and the second classification loss respectively corresponding to the image samples, the category regression network in the image recognition model is trained; and based on the coordinate loss, the first classification loss and the second classification loss respectively corresponding to the image samples, the remaining network in the image recognition model is trained to obtain the trained image recognition model; Wherein, the category regression network includes each classifier of the image recognition model.
8. A training device for an image recognition model, characterized in that: The device comprises: A sample set acquisition module, used to acquire an image sample set, wherein the image sample set includes a plurality of sample subsets, and there are differences between the recognition targets corresponding to the respective sample subsets; A target classifier determination module is used to determine, for a target sample subset among the multiple sample subsets, a target classifier set corresponding to the target sample subset from the classifiers of the image recognition model; wherein the target classifiers in the target classifier set correspond to the recognition targets corresponding to the target sample subset; A classification loss acquisition module is used to determine, for a target image sample in the target sample subset, a first classification loss corresponding to the target image sample based on each positive candidate region corresponding to the target image sample through each classifier; wherein the recognition target corresponding to the image sample is predicted to exist in the positive candidate region; The classification loss acquisition module is further used to set the annotation information corresponding to each negative candidate region corresponding to the target image sample as the first annotation information, wherein the negative candidate region predicts that there is no recognition target corresponding to the image sample, and the first annotation information is used to indicate that the predicted target corresponding to the negative candidate region is not the recognition target corresponding to the target sample subset; for the first target classifier in the target classifier set, based on the candidate features corresponding to each negative candidate region, the predicted targets of each negative candidate region corresponding to the target image sample under the first target classifier are determined, and the candidate features are used to characterize the predicted targets and predicted coordinates corresponding to the candidate region; based on the predicted targets of each negative candidate region under the first target classifier and the first annotation information, the classification loss of each negative candidate region under the first target classifier is determined; the sum of the classification losses of each negative candidate region under the first target classifier is determined as the classification loss corresponding to the first target classifier; based on the classification losses corresponding to the target classifiers in the target classifier set, the second classification loss corresponding to the target image sample is determined; The recognition model training module is used to train the image recognition model based on the first classification loss and the second classification loss respectively corresponding to each image sample in the image sample set to obtain the trained image recognition model, and each classifier in the trained image recognition model is used to identify the recognition target corresponding to the image sample set.
9. A computer device, characterized in that: The computer device includes a processor and a memory, wherein a computer program is stored in the memory, and the computer program is loaded and executed by the processor to implement the training method of the image recognition model as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which is loaded and executed by a processor to implement the training method of the image recognition model as described in any one of claims 1 to 7.
11. A computer program product, characterized in that The computer program product includes a computer program, which is stored in a computer-readable storage medium. The processor reads and executes the computer program from the computer-readable storage medium to implement the training method of the image recognition model as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Multi-target tracking method and device, computer device and computer storage medium
CN109886998A
Model training method and device for pedestrian re-identification, model identification method and device for pedestrian re-identification and medium
CN111027442A
