Target detection model training method, target detection method and device
By distilling knowledge on the object detection model, the knowledge of the basic model is extracted on the incremental model, and combining playback data and new data samples, the problem of low-frequency object recognition rate and slow model iteration is solved, and multiple implementations are achieved high recognition rate and rapid iteration of types of targets.
Patent Information
- Application Number
- CN202211104862.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-09
- Publication Date
- 2024-12-10
- Estimated Expiration
- 2042-09-09
AI Technical Summary
During the training process, the existing object detection model has low frequency of certain types of targets, resulting in insufficient data volume, resulting in low recognition rate. The existing scheme needs to mix old data and new data to retrain the model, resulting in slow model iteration. And it is impossible to guarantee the high recognition rate of the new model on the old data.
Training the basic model by obtaining the image samples collected in the first time period, and using the training sample set containing the playback data samples and new data samples to distil the basic model knowledge, extracting knowledge on the incremental model, realizing rapid model iteration, and using Playback data samples maintain high recognition rates on old data and use new data samples to improve recognition rates in new data.
The recognition rate guarantee for a variety of different frequency targets is achieved, and the recognition rate of old data is maintained by rapidly iterating the model, while improving the recognition rate of new data is solved, which solves the problems of slow model iteration and low recognition rate.
Smart Images

Figure CN117036843B_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 target detection model training method, a target detection method and a device. Background Art
[0002] In recent years, the target detection model based on deep learning has developed rapidly. The existing target detection model is based on the target detection algorithm of deep learning, which can achieve a high recognition accuracy of the target through learning a large amount of data.
[0003] In practical applications, due to the low frequency of certain types of targets, the amount of data of this type of target in the training sample data is small, which ultimately leads to a low recognition rate of the model for targets with insufficient data. Moreover, as time goes by, low-frequency target data slowly accumulates to obtain more data (i.e., new data). The existing solution still needs to mix the previously collected data (old data) with the new data to retrain the model, which not only slows down the model iteration but also cannot guarantee that the new model still has a high recognition rate on the old data. Summary of the invention
[0004] The present application provides a target detection model training method, a target detection method and a device, which can help ensure the model's recognition rate for targets with a variety of different occurrence frequencies.
[0005] In a first aspect, an embodiment of the present application provides a method for training a target detection model, comprising:
[0006] Acquire a first training sample set, where the first training sample set includes first image samples collected in a first time period;
[0007] Training the machine learning model according to the first training sample set to obtain a basic model;
[0008] Acquire a second training sample set, the second training sample set comprising second image samples, the second image samples comprising playback data samples obtained by sampling the first image samples and new data samples collected in a second time period with an appearance frequency lower than a preset value;
[0009] Inputting the second image sample into the basic model to obtain a first feature vector of the second image sample;
[0010] Inputting the second image sample into an incremental model to obtain a second feature vector of the second image sample, wherein the incremental model and the basic model have the same model structure;
[0011] Determining a knowledge distillation loss according to the first feature vector and the second feature vector;
[0012] According to the detection loss and the knowledge distillation loss, the parameters of the incremental model are adjusted to obtain the target detection model.
[0013] In a second aspect, an embodiment of the present application provides a target detection method, including:
[0014] Acquire the image to be detected;
[0015] The image to be detected is input into a target detection model to obtain a target detection result of the image to be detected, wherein the target detection model is trained according to the method of the first aspect.
[0016] In a third aspect, an embodiment of the present application provides a target detection model training device, comprising:
[0017] An acquisition unit, configured to acquire a first training sample set, wherein the first training sample set includes first image samples collected in a first time period;
[0018] A training unit, configured to train the machine learning model according to the first training sample set to obtain a basic model;
[0019] The acquisition unit is further used to acquire a second training sample set, the second training sample set includes a second image sample, the second image sample includes a playback data sample obtained by sampling the first image sample and a new data sample collected in a second time period with an occurrence frequency lower than a preset value;
[0020] The basic model is used to input the second image sample to obtain a first feature vector of the second image sample;
[0021] An incremental model, used for inputting the second image sample to obtain a second feature vector of the second image sample, wherein the incremental model has the same model structure as the basic model;
[0022] A determining unit, configured to determine a knowledge distillation loss according to the first feature vector and the second feature vector;
[0023] A parameter updating unit is used to adjust the parameters of the incremental model according to the detection loss and the knowledge distillation loss to obtain the target detection model.
[0024] In a fourth aspect, an embodiment of the present application provides a target detection device, including:
[0025] An acquisition unit, used for acquiring an image to be detected;
[0026] The target detection model is used to input the image to be detected and obtain the target detection result of the image to be detected, wherein the target detection model is trained according to the method of the first aspect.
[0027] In a fifth aspect, an embodiment of the present application provides an electronic device, comprising: a processor and a memory, the memory being used to store a computer program, the processor being used to call and run the computer program stored in the memory, and executing the method of the first aspect or the second aspect.
[0028] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores computer instructions. When the computer instructions are read and executed by a processor of a computer device, the computer device executes the method of the first aspect or the second aspect mentioned above.
[0029] In a seventh aspect, an embodiment of the present application provides a computer program product or a computer program, the computer program product or the computer program including computer instructions, the computer instructions being 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 method of the first aspect or the second aspect.
[0030] Through the above technical solution, the embodiment of the present application uses a training sample set containing playback data samples and new data samples to perform knowledge distillation on the basic model based on the basic model obtained by training the first image sample collected in the first time period, and extracts the knowledge contained in the basic model to the incremental model to achieve rapid model iteration. In addition, the embodiment of the present application can help maintain the high recognition rate of the model for the target on the old data through the playback data samples, and can help improve the model's recognition rate for the target in the new data through the new data samples, thereby helping to ensure the model's recognition rate for targets with a variety of different frequencies of occurrence. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 A schematic diagram of the system architecture of the solution of an embodiment of the present application;
[0032] Figure 2 is a schematic flow chart of a target detection model training method according to an embodiment of the present application;
[0033] Figure 3 A schematic diagram of a network architecture of a training model according to an embodiment of the present application;
[0034] Figure 4 is a schematic flow chart of another method for training a model according to an embodiment of the present application;
[0035] Figure 5 is a schematic diagram of the structure of a global context module according to an embodiment of the present application;
[0036] Figure 6 is a schematic flow chart of another method for training a model according to an embodiment of the present application;
[0037] Figure 7 is a schematic flow chart of a target detection method according to an embodiment of the present application;
[0038] Figure 8 is a schematic block diagram of a target detection model according to an embodiment of the present application;
[0039] Fig. 9 is a schematic diagram of a device for training a model according to an embodiment of the present application;
[0040] Fig.10 is a schematic block diagram of a target detection device according to an embodiment of the present application;
[0041] Fig.11 is a schematic block diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0042] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0043] It should be understood that in the embodiment of the present application, "B corresponding to A" means that B is associated with A. In one implementation, B can be determined based on A. However, it should also be understood that determining B based on A does not mean determining B based only on A, and B can also be determined based on A and / or other information.
[0044] In the description of the present application, unless otherwise specified, "at least one" means one or more, and "plurality" means two or more than two. In addition, "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, where A and B can be singular or plural. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple.
[0045] It should also be understood that the first, second, etc. descriptions appearing in the embodiments of the present application are only used for illustration and distinction of the description objects, without any distinction of order, nor do they indicate any special limitation on the number of devices in the embodiments of the present application, and cannot constitute any limitation on the embodiments of the present application.
[0046] It should also be understood that the specific features, structures or characteristics related to the embodiments in the specification are included in at least one embodiment of the present application. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner.
[0047] In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or device that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such process, method, product, or device.
[0048] The embodiments of the present application are applied to the field of artificial intelligence technology.
[0049] Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making.
[0050] 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.
[0051] With the research and advancement of artificial intelligence technology, artificial intelligence technology has been studied and applied in many fields, such as common smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, unmanned driving, automatic driving, drones, robots, smart medical care, smart customer service, etc. I believe that with the development of technology, artificial intelligence technology will be applied in more fields and play an increasingly important role.
[0052] The embodiments of the present application may involve computer vision (CV) technology in artificial intelligence technology. Computer vision is a science that studies how to make machines "see". To put it more concretely, 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 instrument 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 multidimensional data. Computer vision technology generally includes image processing, image recognition, image semantic understanding, image retrieval, OCR, video processing, video semantic understanding, video content / behavior recognition, three-dimensional object reconstruction, 3D technology, virtual reality, augmented reality, simultaneous positioning and map construction, and other technologies, as well as common biometric recognition technologies such as face recognition and fingerprint recognition.
[0053] The embodiments of the present application may also involve machine learning (ML) in artificial intelligence technology. ML is a multi-disciplinary cross-discipline involving probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other disciplines. It specializes in 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 fields of artificial intelligence. Machine learning and deep learning generally include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and learning by teaching.
[0054] Deep Learning (DL) is a branch of machine learning. It is an algorithm that attempts to use multiple processing layers containing complex structures or composed of multiple nonlinear transformations to perform high-level abstraction of data. Deep learning is to learn the inherent laws and representation levels of training sample data. The information obtained in the learning process is of great help in the interpretation of data such as text, images and sounds. The ultimate goal of deep learning is to enable machines to have analytical learning capabilities like humans and to be able to recognize data such as text, images and sounds. Deep learning is a complex machine learning algorithm that has achieved results in speech and image recognition that far exceed previous related technologies.
[0055] Figure 1 Schematic diagram of a system architecture involved in an embodiment of the present application. Figure 1 As shown, the system architecture may include a user device 101 , a data collection device 102 , a training device 103 , an execution device 104 , a database 105 and a content library 106 .
[0056] The data acquisition device 102 is used to read training data from the content library 106 and store the read training data in the database 105. The training data involved in the embodiment of the present application includes image samples and annotation information of image samples, such as defective image samples and defect annotation information of lithium batteries.
[0057] The training device 103 trains the machine learning model based on the training data maintained in the database 105. The target detection model obtained by the training device 103 can effectively identify the target in the image. For example, the target detection model for detecting lithium battery defects can effectively identify lithium battery defects in the image. The target detection model obtained by the training device 103 can be applied to different systems or devices.
[0058] In addition, refer to Figure 1 The execution device 104 is configured with an I / O interface 107 for data exchange with external devices. For example, the image to be detected sent by the user device 101 is received through the I / O interface. The calculation module 109 in the execution device 104 processes the input image using the trained target detection model, outputs the target detection result, such as the classification result and the annotation box, and sends the corresponding result to the user device 101 through the I / O interface.
[0059] The user equipment 101 may include a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted terminal, a mobile internet device (MID) or other terminal devices.
[0060] The execution device 104 may be a server.
[0061] Exemplarily, the server may be a computing device such as a rack server, a blade server, a tower server or a cabinet server, etc. The server may be an independent server or a server cluster composed of multiple servers.
[0062] In this embodiment, the execution device 104 is connected to the user device 101 through a network. The network can be a wireless or wired network such as an intranet, the Internet, the Global System of Mobilecommunication (GSM), Wideband Code Division Multiple Access (WCDMA), 4G network, 5G network, Bluetooth, Wi-Fi, or a call network.
[0063] It should be noted that Figure 1It is only a schematic diagram of a system architecture provided by an embodiment of the present application. The positional relationship between the devices, components, modules, etc. shown in the figure does not constitute any limitation. In some embodiments, the data acquisition device 102 and the user device 101, the training device 103 and the execution device 104 can be the same device. The database 105 can be distributed on one server or on multiple servers, and the content library 106 can be distributed on one server or on multiple servers.
[0064] In practical applications, the target detection model is based on the target detection algorithm of deep learning, which can achieve a high recognition accuracy of the target through learning a large amount of data. However, due to the low frequency of certain types of targets, the amount of data of this type of target in the training sample data is small, which ultimately leads to a low recognition rate of the model for targets with insufficient data. Moreover, as time goes by, these low-frequency target data slowly accumulate and obtain more data (i.e., new data). The existing solution still needs to mix the previously collected data (old data) with the new data to retrain the model, which not only slows down the model iteration but also cannot guarantee that the new model still has a high recognition rate on the old data.
[0065] In view of this, the embodiments of the present application provide a target detection model training method, a target detection method and a device, which can help ensure the model's recognition rate for targets with a variety of different occurrence frequencies.
[0066] Specifically, a first training sample set is first obtained, including a first image sample collected in a first time period, and a machine learning model is trained according to the first training sample set to obtain a basic model; then a second training sample set is obtained, including a second image sample, wherein the second image sample includes a playback data sample obtained by sampling the first image sample and a new data sample collected in the second time period and having an occurrence frequency lower than a preset value, and the second image sample is input into the basic model and an incremental model having the same structure as the basic model, and a first feature vector of the second image sample is obtained based on the basic model, and a second feature vector of the second image sample is obtained based on the incremental model; finally, a knowledge distillation loss is determined according to the first feature vector and the second feature vector, and parameters of the incremental model are adjusted according to the knowledge distillation loss to obtain the target detection model.
[0067] Therefore, based on the basic model obtained by training the first image sample collected in the first time period, the embodiment of the present application uses a training sample set including playback data samples and new data samples to perform knowledge distillation on the basic model, extract the knowledge contained in the basic model to the incremental model, and achieve fast model iteration. In addition, the embodiment of the present application can help maintain the high recognition rate of the model for the target on the old data through playback data samples, and can help improve the model's recognition rate for the target in the new data through new data samples, thereby helping to ensure the model's recognition rate for targets with multiple different frequencies of occurrence.
[0068] The embodiments of the present application can be used in defect detection scenarios for lithium batteries. Specifically, lithium batteries generally have a variety of defects in the actual production process. If defective products flow into the market, the battery charging and discharging may be unstable at best, or leak and explode at worst. At present, factories generally use manual sampling, which has low detection efficiency, poor results and cannot conduct full inspection. In order to improve the accuracy and detection efficiency of mobile phone lithium battery defect detection, lithium batteries can be inspected for defects using automated visual defect detection equipment. The automated visual defect detection equipment includes a target detection model, which can achieve a high recognition accuracy by learning from a large amount of defect data.
[0069] For example, there are 7 types of defects in mobile phone lithium batteries, 5 of which are high-frequency defects (frequently occurring, such as defects with a frequency greater than the first preset value), including foreign matter, pits, scratches, wrinkles, and bad tabs, etc. The remaining 2 are low-frequency defects (very low frequency defects, such as defects with a frequency less than the second preset value), including corrosion and pressure injuries. If learning is based on a large amount of defect data collected over a period of time, the target detection model can identify the 5 types of high-frequency defects with high accuracy, while the remaining 2 types of defects are prone to low recognition rates due to the small amount of data and data imbalance during target detection model training.
[0070] The technical solution of the embodiment of the present application includes two stages of model training. The first stage: use a large amount of defect annotation data collected in the first time period to train the deep learning-based target detection model to obtain a basic model. The model can identify 5 types of high-frequency defects with high accuracy, but may have a low recognition rate for 2 types of low-frequency defects. The second stage: accumulate and collect new data on 2 types of low-frequency defects over time, use the playback data of the first stage and the new data of the second stage to perform knowledge distillation on the basic model obtained in the first stage, extract the knowledge contained in the basic model to the incremental model, and achieve rapid model iteration to obtain an incremental model. Among them, the use of playback data samples in the second stage can help the incremental model maintain a high recognition rate for high-frequency defects, and the use of new data samples of low-frequency defects that are continuously accumulated and collected can help improve the model's recognition rate for low-frequency defects, thereby helping to ensure the model's recognition rate for defects with a variety of different frequencies of occurrence.
[0071] The technical solution provided by the embodiments of the present application is described below in conjunction with the accompanying drawings.
[0072] Figure 2 2 shows a schematic flow chart of a target detection model training method 200 according to an embodiment of the present application. The method 200 can be executed by any electronic device with data processing capability, for example, the electronic device can be implemented as a server, and for example, the electronic device can be implemented as a Figure 1 The training device 103 is not limited in this application.
[0073] In some embodiments, the electronic device may include (e.g., deploy) a network architecture of a training model for executing the target detection model training method 200. Figure 3 A schematic diagram of a network architecture 300 of a training model is shown, which can be used to perform the method 200. Figure 3 As shown, the network architecture 300 includes a sample acquisition module 310, a basic model 320, an incremental model 330, a knowledge distillation module 340 and a parameter update module 350. Optionally, the basic module 320 may further include a first backbone network 321, a first neck network 322, a first detection head 323 and a first global context module 324, and the incremental model 330 may further include a second backbone network 331, a second neck network 332, a second detection head 333 and a second global context module 334. Figure 3 The network architecture 300 describes the various steps of the method 200.
[0074] like Figure 2As shown, method 200 includes steps 210 to 270. Among them, steps 210 to 220 are the first stage of model training, the purpose of which is to train the basic model; steps 230 to 270 are the second stage of model training, the purpose of which is to train the incremental model. The basic model can also be called a basic detector (basedetector), and the incremental model can also be called an incremental detector (incrementaldetector), which is not limited in this application.
[0075] 210 , obtain a first training sample set, where the first training sample set includes first image samples collected in a first time period.
[0076] For example, see Figure 3 The first training sample set can be obtained by the sample acquisition module 310. The first training sample set is used to train the basic model and can also be called initial data (Origin data).
[0077] In some embodiments, the annotation information of the first image sample includes an annotation box and a target instance category. For example, for each image represented as x, the target instance category is y. c , the box is y b .
[0078] As an example, in the application scenario of mobile phone lithium battery defect detection, the first image sample collected in the first time period contains a large amount of lithium battery defect data, including 5 types of high-frequency defect data and 2 types of low-frequency defect data.
[0079] 220. Train the machine learning model according to the first training sample set to obtain a basic model.
[0080] Specifically, the basic model, that is, the basic target detection model, can flexibly select existing deep learning-based target detection models, such as FasterRCNN, FCOS or VFnet, without limitation.
[0081] As an example, Figure 3 As shown, the basic model 320 framework may include three key structures: the first backbone network (Backbone) First Neck Network (Neck) and the first detection head The backbone network is used for feature extraction, such as ResNet50 and Swin-Transformer; the neck network is used to perform multi-scale fusion and enhancement of the extracted features to obtain better features, and the feature pyramid network (FPN) is generally used; the detection head is used for category prediction and box regression, and outputs the classification results and box-related information of the area of interest.
[0082] The basic model inputs image x, and the output prediction results include the predicted category and box The formula is as follows:
[0083]
[0084] In this step, a large amount of labeled data in the first training sample set (such as boxes and corresponding target instance categories) can be used to perform fully supervised training on the target detection model. By calculating the error loss between the true value annotation and the model prediction result, the model parameters are iteratively updated to obtain the basic target detection model, i.e., the basic model.
[0085] Through the above steps 210 and 220, the first stage basic model training can be achieved. The trained basic model can achieve target detection with a high recognition rate. For example, in the application scenario of mobile phone lithium battery defect detection, the first stage basic model training and reasoning can be performed through a large amount of lithium battery defect data, so that mobile phone lithium battery defect detection with a high recognition rate can be achieved.
[0086] At the same time, as time goes by, more data can be gradually accumulated for iterative training of the second-stage incremental model to further improve the target recognition rate. The iterative training process of the second-stage incremental model is described in detail in steps 230 to 270 below.
[0087] 230 , obtaining a second training sample set, where the second training sample set includes second image samples, where the second image samples include playback data samples obtained by sampling the first image samples and new data samples collected in a second time period and having an occurrence frequency lower than a preset value.
[0088] For example, see Figure 3 The second training sample set can be obtained by the sample acquisition module 310. The second training sample set is used to train the incremental model.
[0089] Among them, the new data samples, i.e., new data (newdata), can be more data with a frequency lower than the preset value (i.e., low-frequency type) that are gradually accumulated and collected over time after the first stage. For example, for mobile phone lithium battery defect data, the new data can be 2 types of low-frequency defect data (such as corrosion and crushing) that are continuously collected after the first stage.
[0090] The playback data sample, i.e., the playback data (replaydata), is sampled from the initial data collected in the first stage. Exemplarily, the sampling rate can be set to n%, i.e., n% of the data is sampled from the initial data. As a specific example, n%=30% can be set. The sampling method can be uniform sampling according to the category, i.e., the number of samples on each category is the same.
[0091] In the embodiment of the present application, the training sample set of the second stage is determined by combining new data and playback data. On the one hand, it can increase the number of data samples with low frequency in the training samples, thereby alleviating the problem of poor recognition ability of the model for target types with few samples due to the imbalance of the number of samples. On the other hand, the playback data can also prevent the problem of the model forgetting and causing the target recognition performance to deteriorate on the initial data, that is, prevent the model from overfitting to the new data and forgetting the characteristics of the initial data. In addition, by sampling part of the initial data to obtain playback data for model training, the model training iteration process can be accelerated.
[0092] Specifically, the annotation information of the second image sample is similar to the annotation information of the first image sample, and reference may be made to the above description, which will not be repeated herein.
[0093] 240, input the second image sample into the basic model to obtain a first feature vector of the second image sample.
[0094] Here, the basic model is the basic target detection model trained in step 220, that is, the model trained in the first stage.
[0095] In some embodiments, see Figure 4 After the second image sample is input into the basic model, the first feature vector of the second image sample and the first prediction result can be obtained.
[0096] 401, input the second image sample into the first backbone network to obtain a plurality of first feature maps of different resolutions of the second image sample.
[0097] Specifically, the first backbone network may include a convolutional layer for extracting features of an input image. Exemplarily, the extracted features are generally divided by stage, namely C1, C2, C3, C4, C5, C6, C7, etc., where the number is the same as the stage number, representing the number of times the resolution is halved. For example, C2 represents the feature map output by stage 2, with a resolution of 1 / 4 of the input image, and C5 represents the feature map output by stage 5, with a resolution of 1 / 32 of the input image. Figure 3 For the basic model 320 in , the first feature map output by the first backbone network can be expressed as:
[0098] 402, input the multiple first feature maps with different resolutions into a first neck network to obtain a first fusion feature.
[0099] Exemplarily, the first neck network may be FPN. In step 402, the features of different resolutions generated in step 401 may be used as inputs of the first neck network, and the fused features may be output. Specifically, the first neck network (such as FPN) may fuse shallow features with high resolution and deep features with rich semantic information to generate a feature pyramid with strong semantic information at all scales.
[0100] For example, FPN performs downsampling operation on the features of layer 2, and upsampling operation on the features of layer 4 so that they have the same size, and then performs addition operation (adding corresponding elements) on the processed layer 2 and the processed layer 4, and inputs the obtained result into layer 5. Since low-level features can provide more accurate location information, and multiple downsampling and upsampling operations cause errors in the positioning information of the deep network, by accumulating the processed low-level features and the processed high-level features, the low-level features and the high-level features can be combined to fuse the feature information of multiple layers.
[0101] In some embodiments, for Figure 3 For the basic model 320 in , the first fusion feature can be expressed as:
[0102] 403 , input the first fusion feature into the first detection head to obtain a first prediction result of the second image sample.
[0103] Exemplarily, the first detection head can be implemented as two fully connected network layers, connecting the corresponding classification layer and regression layer. Here, the first prediction result includes the category prediction result (i.e., the output of the classification layer, such as the above-mentioned prediction category ) and box regression results (i.e. the output of the regression layer, such as the box frame above ). For example, for Figure 3 For the basic model 320 in , the first prediction result output by the first detection head can be expressed as:
[0104] 404 , input the first fusion feature into a first global context module to obtain a first relationship between different categories of the second image sample.
[0105] Specifically, the first global context module can obtain the relationship between at least two strongly correlated targets in the first fusion feature (i.e., at least two targets that are likely to appear at the same time), and mutually enhance the features of the strongly correlated targets, thereby improving the recognition rate of the targets. Figure 3 In the basic model 320, the first relationship between different categories of the second image sample output by the first global context module can be expressed as:
[0106] Figure 5 A schematic diagram of the structure of the first global context module is shown. The input feature X is processed by three 1×1×1 convolutional layers to obtain features X1, X2 and X3 respectively, and then the features X1 and X2 are matrix multiplied to calculate the feature similarity of features X1 and X2 to obtain the correlation matrix A of features X1 and X2. Then, feature X3 is weighted and reorganized using matrix A as a weight. At this time, if feature X3 is strongly correlated with feature X1 (i.e., they have a strong similarity), the strongly correlated feature will be further enhanced to obtain feature Y. Feature Y is further input into a 1×1×1 convolutional layer for adaptive adjustment, and further summed with feature X to obtain feature Z, i.e., the first relationship between different categories of the second image sample output by the first global context module. Here, summing feature Y with feature X can not only ensure the stability of feature extraction (i.e., ensure that the feature transformation of feature Z and feature X is not too large), but also use feature Y to achieve the purpose of feature enhancement.
[0107] In the embodiment of the present application, the first feature vector of the second image sample may include at least one of a first fusion feature, a first relationship between different categories of the second image sample, and a first prediction result.
[0108] 250, input the second image sample into the incremental model to obtain a second feature vector of the second image sample.
[0109] The incremental model, namely the incremental object detection model, has the same model structure as the basic model, except that the model weights are different. Figure 3 , the incremental model 330 framework can also include three key structures: the second backbone network f θ 331. First Neck Network (Neck)θ 332 and the first detection head (Detectionheads) h θ 333. Similarly, the incremental model inputs image x and outputs the prediction result including the predicted category and box The formula is as follows:
[0110]
[0111] In some embodiments, see Figure 6 After the second image sample is input into the incremental model, a second feature vector and a second prediction result of the second image sample can be obtained.
[0112] 601, input a second image sample into a second backbone network to obtain a plurality of second feature maps of different resolutions of the second image sample.
[0113] for Figure 3 For the incremental model 330 in , the second feature map output by the second backbone network can be expressed as: θ (x).
[0114] 602, input the plurality of second feature maps with different resolutions into a second neck network to obtain a second fusion feature.
[0115] In some embodiments, for Figure 3 For the incremental model 330 in , the second fusion feature can be expressed as: θ (f θ (x)).
[0116] 603, input the second fusion feature into the second detection head to obtain a second prediction result of the second image sample.
[0117] For example, for Figure 3 For the incremental model 330 in , the second prediction result can be expressed as:
[0118] 604 , input the second fusion feature into a second global context module to obtain a second relationship between different categories of the second image sample.
[0119] for Figure 3 In the incremental model 330, the second global context module output can be expressed as: N θ (g θ (f θ (x))).
[0120] Specifically, the incremental model 330 and the basic model 320 have the same model structure, and the processing process of each module in the incremental model 330 is similar to the processing process of each module in the basic model 330, and reference may be made to the above description.
[0121] In the embodiment of the present application, the second feature vector of the second image sample may include at least one of a second fusion feature, a second relationship between different categories of the second image sample, and a second prediction result.
[0122] It should be noted that, in the embodiment of the present application, the first feature vector corresponds to the second feature vector, which are feature data output by the same module in the basic model and the incremental model, respectively. For example, if the first feature vector contains the first fusion feature, then the second feature vector contains the second fusion feature; if the first feature vector contains the first relationship between different categories of the second image sample, then the second feature vector contains the second relationship between different categories of the second image sample; if the first feature vector contains the first prediction result, then the second feature vector contains the second prediction result.
[0123] 260 , determining a knowledge distillation loss based on the first eigenvector and the second eigenvector.
[0124] Knowledge distillation loss L know , that is, the error between the first eigenvector and the second eigenvector of the second image sample.
[0125] For example, in Figure 3 The knowledge distillation module 340 may determine the knowledge distillation loss L according to the first feature vector and the second feature vector of the second image sample. know See also Figure 3 At least one of the first fused features output by the first neck network 322 of the basic model 320, the first prediction result output by the first detection head 323, and the first relationship between at least two categories of the second image sample output by the first global context module 324 can be input to the knowledge distillation module 340, and at least one of the second fused features output by the second neck network 332 of the incremental model 330, the second prediction result output by the second detection head 333, and the second relationship between at least two categories of the second image sample output by the second global context module 334 can be input to the knowledge distillation module 340.
[0126] Optionally, the knowledge distillation module 340 may determine the feature distillation loss L according to the first fusion feature and the second fusion feature. feat , that is, the feature error between the base model and the incremental model. Feature distillation loss L featFeature distillation can be implemented to make the feature response of the incremental model as close as possible to the feature response of the basic model. Feature distillation can maintain the feature consistency between the incremental model and the basic model and prevent the incremental model from forgetting the feature vector of the initial data.
[0127] For example, the characteristic distillation loss L feat It can be expressed as the following formula:
[0128]
[0129] Among them, l2 is the L2 distance function.
[0130] Optionally, the knowledge distillation module 340 may determine the global context distillation loss L according to the first relationship between at least two categories of the second image sample and the second relationship between at least two categories of the second image sample. cont , which is the global context feature error between the base model and the incremental model. Global context distillation loss L cont Global context distillation can be implemented to make the global context features of the incremental model as close as possible to the global context features of the base model. Global context distillation can maintain the consistency of the inter-class relationship between the incremental model and the base model, and prevent the incremental model from forgetting the relationship between multiple categories of the initial data.
[0131] For example, the characteristic distillation loss L feat It can be expressed as the following formula:
[0132]
[0133] Among them, l2 is the L2 distance function.
[0134] Optionally, the knowledge distillation module 340 determines the prediction result distillation loss L according to the first prediction result and the second prediction result of the second image sample. pred , that is, the prediction error between the base model and the incremental model. Prediction result distillation loss L pred Prediction result distillation can be achieved to make the prediction results of the incremental model as close as possible to the prediction results of the basic model. Prediction result distillation can maintain the consistency of the prediction results of the incremental model and the basic model, and prevent the incremental model from forgetting the prediction results of the initial data.
[0135] For example, the prediction result loss L pred It can be expressed as the following formula:
[0136]
[0137] In some embodiments, the knowledge distillation loss L know The characteristic distillation loss L can be included feat, global context distillation loss L cont And the predicted distillation loss L pred At least one of .
[0138] In some embodiments, the detection loss may also be determined based on the labeling information of the second image sample and the second prediction result.
[0139] Among them, the detection loss L det , that is, when the incremental model is fully supervised by using the annotation information of the second image sample (i.e., the box and the corresponding target instance category), the prediction result of the incremental model is And the true value of the second image sample of the input {y c ,y b} error.
[0140] 270, based on the knowledge distillation loss, the parameters of the incremental model are adjusted to obtain the target detection model.
[0141] Specifically, knowledge distillation is performed on the basic model according to the knowledge distillation loss, the knowledge contained in the basic model is extracted to the incremental model, and the parameters of the incremental model are adjusted to obtain the target detection model, thereby achieving fast model iteration.
[0142] In some embodiments, the parameters of the incremental model can be adjusted according to the knowledge distillation loss and the detection loss to obtain the target detection model. Figure 3 , in determining the detection loss L det and knowledge distillation loss L know Afterwards, the parameter updating module 350 can be configured based on the detection loss L det and knowledge distillation loss L know , using the gradient descent algorithm, update the parameters of each network module in the incremental model until the training stop condition is met. The incremental model determined by satisfying the training stop condition is output as the target detection model.
[0143] Therefore, based on the basic model obtained by training the first image sample collected in the first time period, the embodiment of the present application uses a training sample set including playback data samples and new data samples to perform knowledge distillation on the basic model, extract the knowledge contained in the basic model to the incremental model, and achieve fast model iteration. In addition, the embodiment of the present application can help maintain the high recognition rate of the model for the target on the old data through playback data samples, and can help improve the model's recognition rate for the target in the new data through new data samples, thereby helping to ensure the model's recognition rate for targets with multiple different frequencies of occurrence.
[0144] Figure 7 FIG. 7 is a schematic flow chart of a method 700 for target detection provided by an embodiment of the present application. Figure 7 As shown, method 700 includes steps 710 and 720 .
[0145] 710, obtaining an image to be detected.
[0146] Exemplarily, the image to be inspected may be a defect image of a lithium battery.
[0147] 720, input the image to be detected into the target detection model to obtain the target detection result of the image to be detected, wherein the target detection model is trained according to the target detection model training method provided in the embodiment of the present application.
[0148] Exemplarily, the target detection module can be trained based on a large number of defect image samples of lithium batteries. Specifically, it can be trained based on the target detection model training method 200 described above. Accordingly, the target detection result includes the lithium battery defect type and the defect annotation box.
[0149] See also Figure 8 , the image to be detected can be input into the target detection model 800, the backbone network f θ 810, Neck Network θ 820 and detection head h θ 830 processes the image to be detected in turn to obtain the detection result of the image to be detected, including the predicted category and the box frame. Among them, the target detection model 800 can be Figure 3 An example of a trained incremental model 330 in .
[0150] Therefore, based on the basic model obtained by training the first image sample collected in the first time period, the embodiment of the present application uses a training sample set including playback data samples and new data samples to perform knowledge distillation on the basic model, extract the knowledge contained in the basic model to the incremental model, and achieve fast model iteration. In addition, the embodiment of the present application can help maintain the high recognition rate of the model for the target on the old data through playback data samples, and can help improve the model's recognition rate for the target in the new data through new data samples, thereby helping to ensure the model's recognition rate for targets with multiple different frequencies of occurrence.
[0151] The specific implementation modes of the present application are described in detail above in conjunction with the accompanying drawings. However, the present application is not limited to the specific details in the above implementation modes. Within the technical concept of the present application, the technical solution of the present application can be subjected to a variety of simple modifications, and these simple modifications all belong to the protection scope of the present application. For example, the various specific technical features described in the above specific implementation modes can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present application will not further explain various possible combinations. For another example, the various different implementation modes of the present application can also be arbitrarily combined, and as long as they do not violate the ideas of the present application, they should also be regarded as the contents disclosed in the present application.
[0152] It should also be understood that in the various method embodiments of the present application, the size of the sequence number of the above-mentioned processes does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application. It should be understood that these sequence numbers can be interchanged where appropriate, so that the embodiments of the present application described can be implemented in an order other than those shown or described.
[0153] The above describes the method embodiment of the present application in detail. Figures 9 to 11 , describe in detail the device embodiments of the present application.
[0154] Fig. 9 is a schematic block diagram of the target detection model training device 900 of the embodiment of the present application. Fig. 9 As shown, the target detection model training device 900 may include an acquisition unit 910, a training unit 920, a basic model 930, an incremental model 940, a determination unit 950 and a parameter updating unit 960.
[0155] An acquiring unit 910 is configured to acquire a first training sample set, where the first training sample set includes first image samples collected in a first time period;
[0156] A training unit 920, configured to train a machine learning model according to the first training sample set to obtain a basic model;
[0157] The acquisition unit 910 is further configured to acquire a second training sample set, the second training sample set comprising a second image sample, the second image sample comprising a playback data sample obtained by sampling the first image sample and a new data sample collected in a second time period with an occurrence frequency lower than a preset value;
[0158] The basic model 930 is used to input the second image sample to obtain a first feature vector of the second image sample;
[0159] An incremental model 940, used for inputting the second image sample to obtain a second feature vector of the second image sample, wherein the incremental model has the same model structure as the basic model;
[0160] A determining unit 950, configured to determine a knowledge distillation loss according to the first feature vector and the second feature vector;
[0161] The parameter updating unit 960 is used to adjust the parameters of the incremental model according to the knowledge distillation loss to obtain the target detection model.
[0162] In some embodiments, the basic model 930 includes a first backbone network, a first neck network, and a first detection head, and the incremental model 940 includes a second backbone network, a second neck network, and a second detection head.
[0163] In some embodiments, the basic model 930 is specifically used to:
[0164] Inputting the second image sample into the first backbone network to obtain a plurality of first feature maps of different resolutions of the second image sample;
[0165] Inputting the plurality of first feature maps with different resolutions into the first neck network to obtain a first fused feature, wherein the first feature vector includes the first fused feature;
[0166] The incremental model 940 is specifically used for:
[0167] Inputting the second image sample into the second backbone network to obtain a plurality of second feature maps of different resolutions of the second image sample;
[0168] The multiple second feature maps with different resolutions are input into the second neck network to obtain a second fused feature, wherein the second feature vector includes the second fused feature.
[0169] In some embodiments, the determining unit 950 is specifically configured to:
[0170] A feature distillation loss is determined according to the first fusion feature and the second fusion feature, wherein the knowledge distillation loss includes the feature distillation loss.
[0171] In some embodiments, the base model 930 further includes a first global context module, and the incremental model further includes a second global context module;
[0172] The basic model 930 is specifically used for:
[0173] Inputting the second image sample into the first backbone network to obtain a plurality of first feature maps of different resolutions of the second image sample;
[0174] Inputting the plurality of first feature maps with different resolutions into the first neck network to obtain a first fusion feature;
[0175] Inputting the first fused feature into the first global context module to obtain a first relationship between different categories of the second image sample, wherein the first feature vector includes the first relationship between different categories of the second image sample;
[0176] The incremental model 940 is specifically used for:
[0177] Inputting the second image sample into the second backbone network to obtain a plurality of second feature maps of different resolutions of the second image sample;
[0178] Inputting the plurality of second feature maps with different resolutions into the second neck network to obtain a second fusion feature;
[0179] The second fused feature is input into the second global context module to obtain a second relationship between different categories of the second image samples, wherein the second feature vector includes the second relationship between different categories of the second image samples.
[0180] In some embodiments, the determining unit 950 is specifically configured to:
[0181] A global context distillation loss is determined based on a first relationship between different categories of the second image samples and a second relationship between different categories of the second image samples, wherein the knowledge distillation loss includes the global context distillation loss.
[0182] In some embodiments, the basic model 930 is specifically used to:
[0183] The step of inputting the second image sample into the basic model to obtain a first feature vector of the second image sample includes:
[0184] Inputting the second image sample into the first backbone network to obtain a plurality of first feature maps of different resolutions of the second image sample;
[0185] Inputting the plurality of first feature maps with different resolutions into the first neck network to obtain a first fusion feature;
[0186] Inputting the first fusion feature into the first detection head to obtain a first prediction result of the second image sample, wherein the first feature vector includes the first prediction result;
[0187] The incremental model 940 is specifically used for:
[0188] Inputting the second image sample into the second backbone network to obtain a plurality of second feature maps of different resolutions of the second image sample;
[0189] Inputting the plurality of second feature maps with different resolutions into the second neck network to obtain a second fusion feature;
[0190] The second fusion feature is input into the second detection head to obtain a second prediction result of the second image sample, wherein the second feature vector includes the second prediction result.
[0191] In some embodiments, the determining unit 950 is specifically configured to:
[0192] A prediction result distillation loss is determined according to the first prediction result and the second prediction result, wherein the knowledge distillation loss includes the prediction result distillation loss.
[0193] In some embodiments, the determining unit 950 is further configured to:
[0194] Determining a detection loss according to the second prediction result and the labeling information of the second image sample;
[0195] The parameter updating unit 960 is specifically used for:
[0196] According to the detection loss and the knowledge distillation loss, the parameters of the incremental model are adjusted to obtain the target detection model.
[0197] In some embodiments, the first image sample includes a defective image sample of a lithium battery, and the second image sample includes a defective image sample of a lithium battery.
[0198] It should be understood that the device embodiment and the method embodiment may correspond to each other, and similar descriptions may refer to the method embodiment. To avoid repetition, they will not be described here. Specifically, Fig. 9 The device 900 shown can execute the above method embodiments, and the above and other operations and / or functions of each module in the device 900 are respectively for implementing the corresponding processes in the above methods 200, which will not be repeated here for the sake of brevity.
[0199] Fig.10 is a schematic block diagram of the target detection device 1000 according to an embodiment of the present application. Fig.10 As shown, the target detection device 1000 may include an acquisition unit 1010 and a target detection model 1020 .
[0200] An acquisition unit 1010 is used to acquire an image to be detected;
[0201] The target detection model 1020 is used to input the image to be detected and obtain the target detection result of the image to be detected, wherein the target detection model is trained by the target detection model training method of the embodiment of the present application.
[0202] It should be understood that the device embodiment and the method embodiment may correspond to each other, and similar descriptions may refer to the method embodiment. To avoid repetition, they will not be described here. Specifically, Fig.10 The device 1000 shown can execute the above method embodiments, and the aforementioned and other operations and / or functions of each module in the device 1000 are respectively for implementing the corresponding processes in each of the above methods 700, which will not be repeated here for the sake of brevity.
[0203] The above describes the device of the embodiment of the present application from the perspective of the functional module in conjunction with the accompanying drawings. It should be understood that the functional module can be implemented in hardware form, can be implemented by instructions in software form, and can also be implemented by a combination of hardware and software modules. Specifically, the steps of the method embodiment in the embodiment of the present application can be completed by the hardware integrated logic circuit and / or software form instructions in the processor, and the steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to perform, or a combination of hardware and software modules in the decoding processor to perform. Optionally, the software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, an electrically erasable programmable memory, a register, etc. The storage medium is located in a memory, and the processor reads the information in the memory, and completes the steps in the above method embodiment in conjunction with its hardware.
[0204] Fig.11 It is a schematic block diagram of an electronic device 1100 provided in an embodiment of the present application.
[0205] like Fig.11 As shown, the electronic device 1100 may include:
[0206] The memory 1110 and the processor 1120, the memory 1110 is used to store the computer program and transmit the program code to the processor 1120. In other words, the processor 1120 can call and run the computer program from the memory 1110 to implement the method in the embodiment of the present application.
[0207] For example, the processor 1120 may be configured to execute the above method embodiments according to instructions in the computer program.
[0208] In some embodiments of the present application, the processor 1120 may include but is not limited to:
[0209] General-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, etc.
[0210] In some embodiments of the present application, the memory 1110 includes but is not limited to:
[0211] Volatile memory and / or non-volatile memory. Among them, the non-volatile memory can be read-only memory (ROM), programmable ROM (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM) or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM), and direct RAM bus random access memory (DR RAM).
[0212] In some embodiments of the present application, the computer program may be divided into one or more modules, which are stored in the memory 1110 and executed by the processor 1120 to complete the method provided by the present application. The one or more modules may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program in the electronic device.
[0213] like Fig.11 As shown, the electronic device 1100 may further include:
[0214] The transceiver 1130 may be connected to the processor 1120 or the memory 1110 .
[0215] The processor 1120 may control the transceiver 1130 to communicate with other devices, specifically, to send information or data to other devices, or to receive information or data sent by other devices. The transceiver 730 may include a transmitter and a receiver. The transceiver 1130 may further include an antenna, and the number of antennas may be one or more.
[0216] It should be understood that the various components in the electronic device are connected via a bus system, wherein the bus system includes not only a data bus but also a power bus, a control bus and a status signal bus.
[0217] The present application also provides a computer storage medium on which a computer program is stored, and when the computer program is executed by a computer, the computer can perform the method of the above method embodiment. In other words, the present application embodiment also provides a computer program product containing instructions, and when the instructions are executed by a computer, the computer can perform the method of the above method embodiment.
[0218] When software is used for implementation, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (digital subscriber line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integration. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a digital video disc (digital video disc, DVD)), or a semiconductor medium (e.g., a solid state drive (solid state disk, SSD)), etc.
[0219] It is understandable that in the specific implementation of this application, user information and other related data may be involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
[0220] Those of ordinary skill in the art will appreciate that the modules and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0221] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the module is only a logical function division. There may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.
[0222] The modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. For example, each functional module in each embodiment of the present application may be integrated into a processing module, or each module may exist physically separately, or two or more modules may be integrated into one module.
[0223] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A target detection model training method, characterized in that: include: Acquire a first training sample set, where the first training sample set includes first image samples collected in a first time period; Training the machine learning model according to the first training sample set to obtain a basic model; Acquire a second training sample set, the second training sample set including second image samples, the second image samples including playback data samples obtained by uniformly sampling samples of each category of the first image samples according to the category and the preset sampling rate, and new data samples collected in the second time period with an appearance frequency lower than a preset value; Inputting the second image sample into the basic model to obtain a first feature vector of the second image sample; Inputting the second image sample into an incremental model to obtain a second feature vector of the second image sample, wherein the incremental model and the basic model have the same model structure; the second feature vector includes a second prediction result of the second image sample; Determining a knowledge distillation loss according to the first feature vector and the second feature vector; Determining a detection loss according to the second prediction result and the labeling information of the second image sample; According to the detection loss and the knowledge distillation loss, the parameters of the incremental model are adjusted to obtain the target detection model.
2. The method according to claim 1, characterized in that The basic model includes a first backbone network, a first neck network and a first detection head, and the incremental model includes a second backbone network, a second neck network and a second detection head.
3. The method according to claim 2, characterized in that The step of inputting the second image sample into the basic model to obtain a first feature vector of the second image sample includes: Inputting the second image sample into the first backbone network to obtain a plurality of first feature maps of different resolutions of the second image sample; Inputting the plurality of first feature maps with different resolutions into the first neck network to obtain a first fused feature, wherein the first feature vector includes the first fused feature; The step of inputting the second image sample into the incremental model to obtain a second feature vector of the second image sample includes: Inputting the second image sample into the second backbone network to obtain a plurality of second feature maps of different resolutions of the second image sample; The multiple second feature maps with different resolutions are input into the second neck network to obtain a second fused feature, wherein the second feature vector includes the second fused feature.
4. The method according to claim 3, characterized in that The determining the knowledge distillation loss according to the first feature vector and the second feature vector includes: A feature distillation loss is determined according to the first fusion feature and the second fusion feature, wherein the knowledge distillation loss includes the feature distillation loss.
5. The method according to claim 2, characterized in that: The basic model further includes a first global context module, and the incremental model further includes a second global context module; The step of inputting the second image sample into the basic model to obtain a first feature vector of the second image sample includes: Inputting the second image sample into the first backbone network to obtain a plurality of first feature maps of different resolutions of the second image sample; Inputting the plurality of first feature maps with different resolutions into the first neck network to obtain a first fusion feature; Inputting the first fused feature into the first global context module to obtain a first relationship between different categories of the second image sample, wherein the first feature vector includes the first relationship between different categories of the second image sample; The step of inputting the second image sample into the incremental model to obtain a second feature vector of the second image sample includes: Inputting the second image sample into the second backbone network to obtain a plurality of second feature maps of different resolutions of the second image sample; Inputting the plurality of second feature maps with different resolutions into the second neck network to obtain a second fusion feature; The second fused feature is input into the second global context module to obtain a second relationship between different categories of the second image samples, wherein the second feature vector includes the second relationship between different categories of the second image samples.
6. The method according to claim 5, characterized in that The determining the knowledge distillation loss according to the first feature vector and the second feature vector includes: A global context distillation loss is determined based on a first relationship between different categories of the second image samples and a second relationship between different categories of the second image samples, wherein the knowledge distillation loss includes the global context distillation loss.
7. The method according to claim 2, characterized in that The step of inputting the second image sample into the basic model to obtain a first feature vector of the second image sample includes: Inputting the second image sample into the first backbone network to obtain a plurality of first feature maps of different resolutions of the second image sample; Inputting the plurality of first feature maps with different resolutions into the first neck network to obtain a first fusion feature; Inputting the first fusion feature into the first detection head to obtain a first prediction result of the second image sample, wherein the first feature vector includes the first prediction result; The step of inputting the second image sample into the incremental model to obtain a second feature vector of the second image sample includes: Inputting the second image sample into the second backbone network to obtain a plurality of second feature maps of different resolutions of the second image sample; Inputting the plurality of second feature maps with different resolutions into the second neck network to obtain a second fusion feature; The second fusion feature is input into the second detection head to obtain a second prediction result of the second image sample, wherein the second feature vector includes the second prediction result.
8. The method according to claim 7, characterized in that The determining the knowledge distillation loss according to the first feature vector and the second feature vector includes: A prediction result distillation loss is determined according to the first prediction result and the second prediction result, wherein the knowledge distillation loss includes the prediction result distillation loss.
9. The method according to any one of claims 1 to 8, characterized in that: The first image samples include defective image samples of lithium batteries, and the second image samples include defective image samples of lithium batteries.
10. A target detection method, characterized in that: include: Acquire the image to be detected; The image to be detected is input into a target detection model to obtain a target detection result of the image to be detected, wherein the target detection model is trained according to the method according to any one of claims 1-9.
11. A target detection model training device, characterized in that: include: An acquisition unit, configured to acquire a first training sample set, wherein the first training sample set includes first image samples collected in a first time period; A training unit, configured to train the machine learning model according to the first training sample set to obtain a basic model; The acquisition unit is further used to acquire a second training sample set, the second training sample set including second image samples, the second image samples including playback data samples obtained by uniformly sampling samples of each category of the first image samples according to categories and preset sampling rates, and new data samples collected in a second time period with an appearance frequency lower than a preset value; The basic model is used to input the second image sample to obtain a first feature vector of the second image sample; An incremental model, used for inputting the second image sample to obtain a second feature vector of the second image sample, wherein the incremental model has the same model structure as the basic model; and the second feature vector includes a second prediction result of the second image sample; a determining unit, configured to determine a knowledge distillation loss according to the first feature vector and the second feature vector; and to determine a detection loss according to the second prediction result and the annotation information of the second image sample; A parameter updating unit is used to adjust the parameters of the incremental model according to the detection loss and the knowledge distillation loss to obtain the target detection model.
12. A target detection device, characterized in that: include: An acquisition unit, used for acquiring an image to be detected; A target detection model is used to input the image to be detected and obtain a target detection result of the image to be detected, wherein the target detection model is trained according to the method according to any one of claims 1 to 9.
13. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores instructions, and when the processor executes the instructions, the processor executes the method according to any one of claims 1 to 10.
14. A computer storage medium, characterized in that: Used to store a computer program, the computer program comprising instructions for executing the method according to any one of claims 1 to 10.
15. A computer program product, characterized in that The method comprises a computer program code, and when the computer program code is executed by an electronic device, the electronic device executes the method according to any one of claims 1 to 10.
