Human body detection model training method and device based on knowledge distillation
Patent Information
- Application Number
- CN202310084529.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-16
- Publication Date
- 2026-10-27
- Estimated Expiration
- 2043-01-16
AI Technical Summary
[0004]有鉴于此,本申请实施例提供了一种基于知识蒸馏的人体检测模型训练方法及装置,以解决现有技术存在的人体检测模型无法应用知识蒸馏的方式训练,人体检测模型的泛化性差,人体检测模型的检测精度降低的问题
[0010]通过获取预训练好的教师模型,并对预设的人体检测模型的参数进行初始化,得到学生模型;将样本图像分别输入到教师模型及学生模型中,利用教师模型对应的分类分支输出第一置信度,并利用学生模型对应的分类分支输出第二置信度;基于第一置信度、第二置信度以及温度参数计算二元交叉熵损失,并依据第一置信度计算权重,利用权重计算加权后的广义交并比损失;利用二元交叉熵损失及加权后的广义交并比损失,分别对学生模型的分类分支和边界框分支进行训练,得到训练后的人体检测模型。本申请实现将知识蒸馏应用在人体检测模型训练中,在保持推理速度的同时,提高了算法的泛化性,本申请简化了基于知识蒸馏的人体检测模型的结构,对知识蒸馏的损失函数设计更加友好,提升模型的蒸馏效果。
Smart Images

Figure CN116052215B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method and apparatus for training a human detection model based on knowledge distillation. Background Technology
[0002] Object detection algorithms are widely used in practice, with human detection algorithms, such as the YOLOX algorithm, being particularly common due to their high accuracy. Knowledge distillation, a technique that uses a large model to improve the generalization of a small model, has also been widely applied due to its advantages of lossless modeling, speed, and improved accuracy. However, the complexity of object detection tasks makes traditional distillation methods difficult to apply effectively.
[0003] Taking human detection based on the YOLOX algorithm as an example, it requires simultaneously locating the coordinates of a human body and determining whether it belongs to a human, making it more complex than image classification tasks. Existing techniques using distillation loss based on softmax and cross-entropy cannot be applied to human detection, preventing the use of knowledge distillation to improve the generalization of human detection. Therefore, existing human detection models cannot be trained using knowledge distillation, resulting in poor generalization and reduced detection accuracy. Summary of the Invention
[0004] In view of this, embodiments of this application provide a method and apparatus for training a human detection model based on knowledge distillation, in order to solve the problems of existing human detection models being unable to be trained using knowledge distillation, having poor generalization ability, and reduced detection accuracy.
[0005] A first aspect of this application provides a method for training a human detection model based on knowledge distillation, comprising: acquiring a pre-trained teacher model and initializing the parameters of a preset human detection model to obtain a student model; inputting sample images into the teacher model and the student model respectively, outputting a first confidence score using the classification branch corresponding to the teacher model, and outputting a second confidence score using the classification branch corresponding to the student model; calculating a binary cross-entropy loss based on the first confidence score, the second confidence score, and a temperature parameter, and calculating weights based on the first confidence score, and calculating a weighted generalized intersection-union (GUU) loss using the weights; and training the classification branch and bounding box branch of the student model respectively using the binary cross-entropy loss and the weighted GUU loss to obtain a trained human detection model.
[0006] A second aspect of this application provides a training device for a human detection model based on knowledge distillation, comprising: an acquisition module configured to acquire a pre-trained teacher model and initialize the parameters of a preset human detection model to obtain a student model; a confidence module configured to input sample images into the teacher model and the student model respectively, output a first confidence score using the classification branch corresponding to the teacher model, and output a second confidence score using the classification branch corresponding to the student model; a calculation module configured to calculate a binary cross-entropy loss based on the first confidence score, the second confidence score, and a temperature parameter, calculate weights based on the first confidence score, and calculate a weighted generalized intersection-union (GUU) loss using the weights; and a training module configured to train the classification branch and bounding box branch of the student model using the binary cross-entropy loss and the weighted GUU loss respectively to obtain a trained human detection model.
[0007] A third aspect of this application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the above-described method.
[0008] A fourth aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the above-described method.
[0009] The above-described technical solutions adopted in the embodiments of this application can achieve the following beneficial effects:
[0010] By acquiring a pre-trained teacher model and initializing the parameters of a preset human detection model, a student model is obtained. Sample images are input into both the teacher and student models. The teacher model outputs a first confidence score using its classification branch, and the student model outputs a second confidence score using its classification branch. A binary cross-entropy loss is calculated based on the first and second confidence scores and a temperature parameter. Weights are calculated based on the first confidence score, and a weighted generalized intersection-union (GUU) loss is calculated using these weights. The student model's classification and bounding box branches are trained using the binary cross-entropy loss and the weighted GUU loss, resulting in a trained human detection model. This application applies knowledge distillation to the training of a human detection model, improving the algorithm's generalization ability while maintaining inference speed. This application simplifies the structure of the knowledge distillation-based human detection model, makes the loss function design more user-friendly, and enhances the model's distillation performance. Attached Figure Description
[0011] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 This is a schematic diagram of the structure of a human detection model based on knowledge distillation in a real-world scenario, as described in the embodiments of this application.
[0013] Figure 2 This is a flowchart illustrating the human detection model training method based on knowledge distillation provided in an embodiment of this application.
[0014] Figure 3 This is a schematic diagram of the structure of the human body detection model training device based on knowledge distillation provided in the embodiments of this application;
[0015] Figure 4 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0016] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.
[0017] As mentioned in the background section, object detection algorithms are widely used in practice, and YOLOX, a representative and excellent algorithm, is frequently used in industry, such as in human detection projects, due to its high-precision detection performance. Knowledge distillation is a method that uses a large model to improve the generalization of a small model. Because it has the advantages of improving model accuracy without loss of model and speed, it has also been widely used. However, due to the complexity of the object detection task, traditional distillation methods are difficult to be effective in object detection algorithms, and this is also the case with the YOLOX algorithm.
[0018] In YOLOX-based human detection tasks, it is necessary to simultaneously locate the coordinates of a human body and determine whether it belongs to a human, making it more complex than image classification tasks. Existing techniques using distillation loss based on softmax and cross-entropy cannot be applied to human detection, preventing the use of knowledge distillation to improve the generalization of human detection. Specifically, the YOLOX algorithm outputs three branches: two classification branches (using binary cross-entropy loss) and one regression branch (using IOU loss). Traditional knowledge distillation, designed for image classification and specifically for cross-entropy loss, cannot be applied to the three branches of the YOLOX algorithm.
[0019] In view of this, this application provides a human detection model training method based on knowledge distillation to solve the above problems. When the human detection model training method of this application is applied to the human detection task, the classification branches and target branches of the teacher model and the student model are merged to obtain a merged classification branch. A temperature-controlled binary cross-entropy loss is designed for the merged classification branch. At the same time, a weighted generalized intersection-union loss based on the output probability value of the classification branch of the teacher model is designed for the bounding box branch. Thus, the distillation of the human detection algorithm (such as the YOLOX algorithm) is successfully realized, which improves the detection accuracy of the human detection task while maintaining the inference speed.
[0020] Figure 1 This is a schematic diagram of the structure of a knowledge distillation-based human detection model involved in a real-world scenario according to an embodiment of this application, as shown below. Figure 1 As shown, the knowledge distillation-based human detection model can specifically include:
[0021] exist Figure 1 The knowledge distillation-based human detection model shown includes a teacher model and a student model. Both the teacher and student models use human detection models, such as models built based on the YOLOX object detection algorithm. Both the teacher and student models include a backbone module, a neck module, and a head module. The head module typically contains three branches: a classification branch (cls branch), an object branch (obj branch), and a bounding box branch (bbox branch). The cls and obj branches are two classification branches used to determine the category of the object at the current location, and the bbox branch is used to locate the coordinates of the object at the current location.
[0022] Furthermore, the idea behind knowledge distillation is to use a large model (called the teacher model) to guide a small model (called the student model) to improve the generalization ability of the small model. The knowledge distillation process involves using sample images as inputs to the teacher and student models. The teacher model is a pre-trained high-precision model, and its cls and bbox branches output corresponding values. The student model is an initialized model. By having the student model learn the output of the teacher model, the parameters of the student model converge, thus achieving the goal of training the student model. In practical applications, the training of the student model branches is guided by a loss function, i.e., the student model branches are trained using a loss function.
[0023] It should be noted that the knowledge distillation-based human detection model provided in this application eliminates the obj branch from the original human detection model. Instead, it merges the cls branch with the obj branch, retaining only the cls branch. Therefore, the knowledge distillation-based human detection model in this application contains only two branches: the cls branch and the bbox branch. By merging the cls and obj branches in the human detection model, the model is easier to train and more user-friendly for distillation loss design. Regarding the loss function, this application uses the outputs of the cls branches of the teacher and student models to calculate the temperature-controlled binary cross-entropy loss (bce loss) as the distillation loss of the cls branch; it uses the output of the teacher model's cls branch to calculate the weights and uses the weighted generalized intersection-union loss (GIOU loss) as the distillation loss of the bbox branch, thus achieving distillation of the human detection model.
[0024] The following is based on Figure 1 The structure of the knowledge distillation-based human detection model shown is illustrated, and the implementation process of the knowledge distillation-based human detection model training method of this application is described in detail.
[0025] Figure 2 This is a flowchart illustrating the human detection model training method based on knowledge distillation provided in this application embodiment. Figure 2 The knowledge distillation-based human detection model training method can be executed by the server. For example... Figure 2 As shown, the training method for the human detection model based on knowledge distillation can specifically include:
[0026] S201, Obtain the pre-trained teacher model and initialize the parameters of the preset human detection model to obtain the student model;
[0027] S202, Input the sample images into the teacher model and the student model respectively, output the first confidence score using the classification branch corresponding to the teacher model, and output the second confidence score using the classification branch corresponding to the student model;
[0028] S203, calculate the binary cross-entropy loss based on the first confidence level, the second confidence level, and the temperature parameter, and calculate the weights based on the first confidence level, and use the weights to calculate the weighted generalized cross-union ratio loss;
[0029] S204 uses binary cross-entropy loss and weighted generalized cross-union ratio loss to train the classification branch and bounding box branch of the student model, respectively, to obtain the trained human detection model.
[0030] Specifically, the human detection model in this application embodiment is a human detection model built based on the YOLOX algorithm. However, it should be understood that the human detection model in this application is not limited to the YOLOX algorithm, and other human detection algorithms are also applicable to this application.
[0031] It's important to note that in the original YOLOX algorithm, the obj branch (target branch) is a binary classification branch, outputting the probability that a target is present at the current location. The cls branch (classification branch) is a multi-class classification branch associated with the number of detection categories, outputting the probability that the current location belongs to each category. Statistically, the obj branch output can be seen as the prior probability of a target's presence, while the cls branch output can be seen as the conditional probability of a target belonging to each category given its presence at the current anchor position. Therefore, the final probability of each category output by the detection model is the product of the cls and obj branch outputs.
[0032] In some embodiments, the head modules of the teacher model and the student model each correspond to a classification branch, which is formed by merging the target branch of the original human detection model and the original classification branch.
[0033] Specifically, the head modules of the teacher model and student model in this application each correspond to a cls branch. The cls branch in this application is formed by merging the cls branch and obj branch in the original YOLOX algorithm. That is, by merging the cls branch and obj branch in the YOLOX algorithm, the merged cls branch is obtained. Since only the cls branch is retained after merging, the output value of the cls branch is the final predicted probability (i.e., confidence level) of each category.
[0034] The advantages of merging the cls branch and the obj branch are as follows: First, the model structure is easier to train and optimize. Compared to the original YOLOX, after merging the branches, only one cls branch needs to be trained, reducing the risk of insufficient optimization caused by training two branches in the original model. Second, the model inference speed is faster. When the model is trained and inference is performed on the input image, the original model would use two branches for calculation, while after merging the branches, only one branch is needed. Third, it is more user-friendly for designing the loss function for knowledge distillation. After merging the branches, only the loss function needs to be designed for the merged cls branch, avoiding poor overall knowledge distillation performance due to a poorly designed obj loss function. At the same time, only the hyperparameter of the distillation loss function of the merged cls branch needs to be adjusted. The hyperparameter has a significant impact on the overall distillation performance and is generally determined through experiments. Adjusting one less hyperparameter saves time and effort.
[0035] In some embodiments, the method of outputting a first confidence score using the classification branch corresponding to the teacher model and a second confidence score using the classification branch corresponding to the student model includes: sequentially extracting a first feature map using the trunk module, neck module, and head module corresponding to the teacher model, inputting the first feature map into the classification branch corresponding to the head module of the teacher model, and outputting the first confidence score; and sequentially extracting a second feature map using the trunk module, neck module, and head module corresponding to the student model, inputting the second feature map into the classification branch corresponding to the head module of the student model, and outputting the second confidence score.
[0036] Specifically, after merging the cls and obj branches in the teacher and student models, the head modules of both models correspond to only two branches: the merged cls branch and the bbox branch. After inputting sample images into the teacher and student models respectively, the trunk, neck, and head modules are processed sequentially to obtain a first feature map and a second feature map. The first feature map is input into the corresponding cls branch of the teacher model, and a first confidence score is output. Similarly, the second feature map is input into the corresponding cls branch of the student model, and a second confidence score is output. This application will further calculate the distillation loss corresponding to the cls branch based on the first confidence score, the second confidence score, and preset temperature parameters.
[0037] In some embodiments, calculating the binary cross-entropy loss based on a first confidence level, a second confidence level, and a temperature parameter includes: dividing the first confidence level and the second confidence level by the temperature parameter respectively, calculating the binary cross-entropy based on the result of the division, and using the binary cross-entropy as the distillation loss of the corresponding classification branch of the student model.
[0038] Specifically, this application requires designing loss functions for the cls branch and the bbox branch respectively for distillation training. When calculating the distillation loss corresponding to the cls branch, the output values (i.e., the first confidence and the second confidence) of the cls branch corresponding to the teacher model and the student model are first divided by the preset temperature parameter T. Based on the calculation result after the division, the binary cross-entropy between them is calculated. The calculated binary cross-entropy is used as the distillation loss of the cls branch corresponding to the student model.
[0039] In some embodiments, calculating weights based on a first confidence level and using the weights to calculate a weighted generalized intersection-union loss includes: performing a normalization function operation on the first confidence level to obtain a normalized confidence level; using the highest confidence level among the normalized confidence levels as the weight of the distillation loss corresponding to the bounding box branch; and multiplying the weights by the generalized intersection-union loss to obtain the weighted generalized intersection-union loss.
[0040] Specifically, when calculating the loss function for the bounding box branch, the output value (i.e., the first confidence level) of the teacher model's cls branch is first processed using the sigmoid function to obtain probability values between 0 and 1. Then, the maximum value of each row is taken to obtain the probability of belonging to the predicted class. This probability is used as the weight of the bounding box branch distillation loss. Multiplying the weights by the generalized intersection-union loss (GIOU loss) yields the bounding box branch distillation loss. It should be noted that the GIOU loss here is the loss of the original YOLOX algorithm. This application is based on the GIOU loss of the original YOLOX algorithm, but with weight processing, a new GIOU loss for the bounding box branch is obtained.
[0041] Furthermore, through the design of the distillation loss described above, we ensure that the cls branch uses a binary cross-entropy loss with a temperature parameter, and the bbox branch uses a class probability-weighted GIOU loss. Finally, we use the temperature-weighted binary cross-entropy loss to guide the training of the student model's cls branch, and use the weighted GIOU loss to guide the training of the student model's bbox branch, thus obtaining the trained student model (i.e., the trained human detection model).
[0042] According to the technical solution provided in the embodiments of this application, this application successfully applies the idea of knowledge distillation to the training of the YOLOX model by designing a knowledge distillation algorithm based on the YOLOX model, and applies it to the human detection task, improving the generalization of the algorithm while maintaining inference speed. This application also proposes a method to merge the cls branch and obj branch in YOLOX, making the model easier to train and more user-friendly for the design of distillation loss. This application further designs a temperature-controlled binary cross-entropy loss for the cls branch and a cls-weighted GIOU loss for the bbox branch, successfully achieving distillation of the YOLOX model. This application simplifies the structure of the YOLOX model based on knowledge distillation, makes the design of the loss function for knowledge distillation more user-friendly, and improves the distillation effect of the model.
[0043] The following are embodiments of the apparatus described in this application, which can be used to execute the embodiments of the method described in this application. For details not disclosed in the apparatus embodiments of this application, please refer to the embodiments of the method described in this application.
[0044] Figure 3 This is a schematic diagram of the structure of the human body detection model training device based on knowledge distillation provided in an embodiment of this application. Figure 3 As shown, the knowledge distillation-based human detection model training device includes:
[0045] The acquisition module 301 is configured to acquire a pre-trained teacher model and initialize the parameters of a preset human detection model to obtain a student model.
[0046] The confidence module 302 is configured to input sample images into the teacher model and the student model respectively, output the first confidence using the classification branch corresponding to the teacher model, and output the second confidence using the classification branch corresponding to the student model.
[0047] The calculation module 303 is configured to calculate the binary cross-entropy loss based on the first confidence level, the second confidence level, and the temperature parameter, and to calculate the weights based on the first confidence level, and then use the weights to calculate the weighted generalized cross-union ratio loss.
[0048] Training module 304 is configured to train the classification branch and bounding box branch of the student model using binary cross-entropy loss and weighted generalized cross-union ratio loss, respectively, to obtain the trained human detection model.
[0049] In some embodiments, both the teacher model and the student model employ a human body detection model, which includes a trunk module, a neck module, and a head module.
[0050] In some embodiments, the head modules of the teacher model and the student model each correspond to a classification branch, which is formed by merging the target branch of the original human detection model and the original classification branch.
[0051] In some embodiments, Figure 3 The confidence module 302 extracts the first feature map sequentially using the trunk module, neck module and head module corresponding to the teacher model, inputs the first feature map into the classification branch corresponding to the head module of the teacher model, and outputs the first confidence; and extracts the second feature map sequentially using the trunk module, neck module and head module corresponding to the student model, inputs the second feature map into the classification branch corresponding to the head module of the student model, and outputs the second confidence.
[0052] In some embodiments, Figure 3 The calculation module 303 divides the first confidence level and the second confidence level by the temperature parameter respectively, calculates the binary cross-entropy based on the division result, and uses the binary cross-entropy as the distillation loss of the corresponding classification branch of the student model.
[0053] In some embodiments, Figure 3 The calculation module 303 performs a normalization function operation on the first confidence level to obtain the normalized confidence level. The highest confidence level among the normalized confidence levels is used as the weight of the distillation loss corresponding to the bounding box branch. The weight is multiplied by the generalized intersection-union loss to obtain the weighted generalized intersection-union loss.
[0054] In some embodiments, the human detection model employs a model created based on the YOLOX algorithm.
[0055] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. 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 this application.
[0056] Figure 4 This is a schematic diagram of the structure of the electronic device 4 provided in an embodiment of this application. Figure 4 As shown, the electronic device 4 of this embodiment includes a processor 401, a memory 402, and a computer program 403 stored in the memory 402 and executable on the processor 401. When the processor 401 executes the computer program 403, it implements the steps in the various method embodiments described above. Alternatively, when the processor 401 executes the computer program 403, it implements the functions of each module / unit in the various device embodiments described above.
[0057] For example, computer program 403 may be divided into one or more modules / units, which are stored in memory 402 and executed by processor 401 to complete this application. The one or more modules / units may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of computer program 403 in electronic device 4.
[0058] Electronic device 4 can be a desktop computer, laptop, handheld computer, cloud server, or other electronic device. Electronic device 4 may include, but is not limited to, processor 401 and memory 402. Those skilled in the art will understand that... Figure 4 This is merely an example of electronic device 4 and does not constitute a limitation on electronic device 4. It may include more or fewer components than shown, or combine certain components, or different components. For example, electronic device may also include input / output devices, network access devices, buses, etc.
[0059] Processor 401 can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor.
[0060] The memory 402 can be an internal storage unit of the electronic device 4, such as a hard disk or RAM. The memory 402 can also be an external storage device of the electronic device 4, such as a plug-in hard disk, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card. Furthermore, the memory 402 can include both internal and external storage units of the electronic device 4. The memory 402 is used to store computer programs and other programs and data required by the electronic device. The memory 402 can also be used to temporarily store data that has been output or will be output.
[0061] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0062] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0063] Those skilled in the art will recognize that the units and algorithm steps of the various examples 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 implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0064] In the embodiments provided in this application, it should be understood that the disclosed apparatus / computer devices and methods can be implemented in other ways. For example, the apparatus / computer device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. Multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0065] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0066] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0067] If integrated modules / units are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program may include computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. A computer-readable medium may include: any entity or device capable of carrying computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), or a random access memory (RAM). The content contained in a computer-readable medium can be appropriately added to or subtracted according to the requirements of legislation and patent practice in a jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, a computer-readable medium may not include electrical carrier signals and telecommunication signals.
[0068] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A method for training a human detection model based on knowledge distillation, characterized in that, include: Obtain the pre-trained teacher model and initialize the parameters of the preset human detection model to obtain the student model; Both the teacher model and the student model employ a human detection model, which includes a trunk module, a neck module, and a head module. The head module of the teacher model and the student model each correspond to a classification branch. The classification branch is formed by merging the target branch and the original classification branch of the original human detection model. The classification branch is used to directly output the predicted probability of each category. The sample images are input into the teacher model and the student model respectively. The first confidence score is output using the classification branch corresponding to the teacher model, and the second confidence score is output using the classification branch corresponding to the student model. The binary cross-entropy loss is calculated based on the first confidence level, the second confidence level, and the temperature parameter. The weights are then calculated based on the first confidence level, and the weighted generalized cross-union ratio loss is calculated using the weights. The step of calculating the binary cross-entropy loss based on the first confidence level, the second confidence level, and the temperature parameter includes: dividing the first confidence level and the second confidence level by the temperature parameter respectively, calculating the binary cross-entropy based on the division results, and using the binary cross-entropy as the distillation loss of the corresponding classification branch of the student model; the step of calculating the weight based on the first confidence level and using the weight to calculate the weighted generalized intersection-union loss includes: performing a normalization function operation on the first confidence level to obtain a normalized confidence level, using the largest confidence level among the normalized confidence levels as the weight of the distillation loss corresponding to the bounding box branch of the student model, and multiplying the weight by the generalized intersection-union loss to obtain the weighted generalized intersection-union loss; The classification branch and bounding box branch of the student model are trained using the binary cross-entropy loss and the weighted generalized cross-union loss, respectively, to obtain the trained human detection model.
2. The method according to claim 1, characterized in that, The step of outputting a first confidence score using the classification branch corresponding to the teacher model and outputting a second confidence score using the classification branch corresponding to the student model includes: The first feature map is extracted sequentially using the backbone module, neck module and head module corresponding to the teacher model. The first feature map is then input into the classification branch corresponding to the head module of the teacher model, and the first confidence score is output. Furthermore, the second feature map is extracted sequentially using the trunk module, neck module, and head module corresponding to the student model, and the second feature map is input into the classification branch corresponding to the head module of the student model to output the second confidence score.
3. The method according to any one of claims 1 to 2, characterized in that, The human detection model is a model created based on the YOLOX algorithm.
4. A training device for a human detection model based on knowledge distillation, characterized in that, include: The acquisition module is configured to acquire a pre-trained teacher model and initialize the parameters of a preset human detection model to obtain a student model. Both the teacher model and the student model use a human detection model, which includes a trunk module, a neck module, and a head module. The head module of the teacher model and the student model each correspond to a classification branch. The classification branch is formed by merging the target branch and the original classification branch of the original human detection model. The classification branch is used to directly output the predicted probability of each category. The confidence module is configured to input sample images into the teacher model and the student model respectively, output a first confidence score using the classification branch corresponding to the teacher model, and output a second confidence score using the classification branch corresponding to the student model. The calculation module is configured to calculate the binary cross-entropy loss based on the first confidence level, the second confidence level, and the temperature parameter, and to calculate the weights based on the first confidence level, and to calculate the weighted generalized cross-union ratio loss using the weights. The step of calculating the binary cross-entropy loss based on the first confidence level, the second confidence level, and the temperature parameter includes: dividing the first confidence level and the second confidence level by the temperature parameter respectively, calculating the binary cross-entropy based on the division results, and using the binary cross-entropy as the distillation loss of the corresponding classification branch of the student model; the step of calculating the weight based on the first confidence level and using the weight to calculate the weighted generalized intersection-union loss includes: performing a normalization function operation on the first confidence level to obtain a normalized confidence level, using the largest confidence level among the normalized confidence levels as the weight of the distillation loss corresponding to the bounding box branch of the student model, and multiplying the weight by the generalized intersection-union loss to obtain the weighted generalized intersection-union loss; The training module is configured to train the classification branch and bounding box branch of the student model using the binary cross-entropy loss and the weighted generalized intersection-union ratio loss, respectively, to obtain the trained human detection model.
5. An electronic device comprising a processor and a memory, the memory being used to store a computer program that, when executed by the processor, implements the method as described in any one of claims 1 to 3.
6. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 3.
Citation Information
Patent Citations
Method for compressing YOLOX target detection model based on positioning distillation
CN115035386A
Target detection model training method and device, equipment and storage medium
CN115359322A