Model training method, device, computer equipment and storage medium
By rotating the training samples, the sample sets in different fields are generated, and the model distillation technology is used to solve the problem of low model accuracy caused by insufficient sample number, which improves the robustness and testing accuracy of the model.
Patent Information
- Application Number
- CN202011162501.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-27
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2040-10-27
AI Technical Summary
In the prior art, since the sample labeling requires a lot of manpower and material cost, the number of samples with labels is small, which leads to fewer features learned by neural network models, thus making the model's testing accuracy poor.
By rotating the picture samples in the first training sample set, a second training sample set of multiple sample rotation angles is generated, and the initial model is trained separately based on these sample sets to obtain an intermediate model, and then multiple models are distilled through model The knowledge of the intermediate model is transferred to the target model, thereby improving the testing accuracy of the model.
The data is expanded through domain transformation, the number of samples trained by the model is increased, the robustness and testing accuracy of the model are improved, the need to artificially collect data in other fields is avoided, and the potential of the original data is fully utilized.
Smart Images

Figure CN112329916B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of machine learning technology, and in particular to a model training method, apparatus, computer equipment and storage medium. Background Art
[0002] Supervised learning refers to the use of labeled samples to train neural network models. In the process of training neural network models based on supervised learning methods, it is necessary to first obtain labeled samples.
[0003] In the prior art, since labeling samples requires a lot of manpower and material resources, the number of labeled samples is relatively small. The small number of samples will result in fewer features learned by the neural network model, resulting in poor test accuracy of the final model. Summary of the invention
[0004] Based on this, it is necessary to provide a model training method, device, computer equipment and storage medium that can improve the accuracy of model testing in response to the above technical problems.
[0005] A model training method, the method comprising:
[0006] Acquire a first training sample set, where the first training sample set includes a plurality of first image samples;
[0007] Acquire multiple sample rotation angles, and for each sample rotation angle, rotate each first image sample in the first training sample set to the sample rotation angle to obtain a second training sample set corresponding to the sample rotation angle; wherein each sample rotation angle is greater than a preset angle threshold;
[0008] Based on each second training sample set, the initial model is trained respectively to obtain an intermediate model corresponding to each second training sample set one by one;
[0009] Perform model distillation on multiple intermediate models to obtain the target model.
[0010] In one embodiment, model distillation is performed on multiple intermediate models to obtain a target model, including:
[0011] Get the target image;
[0012] Rotate the target image to the angle corresponding to each intermediate model to obtain the rotated intermediate image;
[0013] Input the intermediate images into each intermediate model respectively, and obtain the label of the target image according to the output results of each intermediate model;
[0014] The initial model is trained based on the target image and the label of the target image to obtain the target model.
[0015] In one embodiment, rotating the target image to an angle corresponding to each intermediate model includes:
[0016] Use the matrix rotation function to rotate the target image to the angles corresponding to each intermediate model.
[0017] In one embodiment, the output result of the intermediate model is a feature map, and obtaining the label of the target image according to the output result of each intermediate model includes:
[0018] The feature maps output by each intermediate model are added bit by bit to obtain a fused feature map;
[0019] The fused feature map is determined as the label of the target image.
[0020] In one embodiment, the angle difference between the rotation angles of each sample is equal, and the rotation angle of each sample is greater than 20 degrees.
[0021] In one embodiment, the sample rotation angles include 0 degrees, 45 degrees, 90 degrees, 135 degrees, 180 degrees, 225 degrees, 270 degrees and 315 degrees.
[0022] A model training device, comprising:
[0023] A first acquisition module, used to acquire a first training sample set, where the first training sample set includes a plurality of first image samples;
[0024] A second acquisition module is used to acquire multiple sample rotation angles, and for each sample rotation angle, each first image sample in the first training sample set is rotated to the sample rotation angle to obtain a second training sample set corresponding to the sample rotation angle; wherein each sample rotation angle is greater than a preset angle threshold;
[0025] An intermediate model acquisition module, used to train the initial model based on each second training sample set to obtain an intermediate model corresponding to each second training sample set;
[0026] The distillation module is used to perform model distillation on multiple intermediate models to obtain the target model.
[0027] In one embodiment, the distillation module is further configured to:
[0028] Get the target image;
[0029] Rotate the target image to the angle corresponding to each intermediate model to obtain the rotated intermediate image;
[0030] Input the intermediate images into each intermediate model respectively, and obtain the label of the target image according to the output results of each intermediate model;
[0031] The initial model is trained based on the target image and the label of the target image to obtain the target model.
[0032] A computer device includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0033] Acquire a first training sample set, where the first training sample set includes a plurality of first image samples;
[0034] Acquire multiple sample rotation angles, and for each sample rotation angle, rotate each first image sample in the first training sample set to the sample rotation angle to obtain a second training sample set corresponding to the sample rotation angle; wherein each sample rotation angle is greater than a preset angle threshold;
[0035] Based on each second training sample set, the initial model is trained respectively to obtain an intermediate model corresponding to each second training sample set one by one;
[0036] Perform model distillation on multiple intermediate models to obtain the target model.
[0037] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
[0038] Acquire a first training sample set, where the first training sample set includes a plurality of first image samples;
[0039] Acquire multiple sample rotation angles, and for each sample rotation angle, rotate each first image sample in the first training sample set to the sample rotation angle to obtain a second training sample set corresponding to the sample rotation angle; wherein each sample rotation angle is greater than a preset angle threshold;
[0040] Based on each second training sample set, the initial model is trained respectively to obtain an intermediate model corresponding to each second training sample set one by one;
[0041] Perform model distillation on multiple intermediate models to obtain the target model.
[0042] The above-mentioned model training method, device, computer equipment and storage medium can improve the test accuracy of the model. The model training method obtains multiple sample rotation angles, and for each sample rotation angle, each first image sample in the first training sample set is rotated to the sample rotation angle to obtain a second training sample set corresponding to the sample rotation angle; wherein each sample rotation angle is greater than a preset angle threshold; the initial model is trained based on each second training sample set to obtain an intermediate model corresponding to each second training sample set; and the multiple intermediate models are model distilled to obtain a target model. In the embodiment of the present application, after the first image sample in the first training sample set is rotated to a sample rotation angle greater than a preset angle threshold, multiple second training sample sets are obtained, thereby realizing the augmentation of the first training sample set. For the multiple second training sample sets obtained after the augmentation, the initial model is trained respectively to obtain multiple intermediate models corresponding to each second training sample set. Since each intermediate model is obtained by training different second training sample sets, the intermediate models do not interfere with each other. On this basis, the knowledge of multiple intermediate models is transferred to the final target model by model distillation, thereby improving the accuracy of the final target model. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 A schematic diagram of a flow chart of a model training method in one embodiment;
[0044] Figure 2 A schematic flow chart of the steps of performing model distillation in one embodiment;
[0045] Figure 3 A schematic flow chart of the steps of performing feature fusion in one embodiment;
[0046] Figure 4 is a structural block diagram of a model training device in one embodiment;
[0047] Figure 5 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0048] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0049] Supervised learning refers to the use of labeled samples to train neural network models. In the process of training neural network models based on supervised learning methods, it is necessary to first obtain labeled samples.
[0050] In traditional technology, since sample labeling requires a lot of manpower and material resources, the number of labeled samples is small. The small number of samples will result in fewer features learned by the neural network model, resulting in poor test accuracy of the final model.
[0051] In order to solve the problem of poor model accuracy caused by the small number of sample images, the prior art proposes a method of data augmentation for sample images, wherein data augmentation can refer to rotating the sample image by a certain angle. After the sample image is rotated, sample images at different rotation angles can be obtained, but the image content in the sample image does not change, that is, the label corresponding to the rotated sample will not change, so that the number of sample images can be expanded without labeling the newly added sample images. Thus, the purpose of expanding the number of sample images at a relatively low cost is achieved.
[0052] In the above method, the rotation angle of the sample image is generally limited to between -20 degrees and +20 degrees. This is because when the rotation angle is between (-20, +20), the similarity between the sample images before and after the rotation is high, so they can be used in a model training. If the rotation angle of the sample image is large, for example, when the rotation angle of the sample image is in a large range such as 90 degrees or 180 degrees, the sample image before and after the rotation is very different from the model. At this time, when the sample images before and after the rotation are used for the same model training, the model will crash.
[0053] Based on the above content, it can be seen that the existing method of augmenting sample images is limited by the rotation angle. Therefore, the number of expanded sample images is limited and cannot meet the model training requirements.
[0054] In an embodiment of the present application, a model training method is provided, and after the first image sample in the first training sample set is rotated to a sample rotation angle greater than a preset angle threshold, a plurality of second training sample sets are obtained, wherein the preset angle threshold is an angle greater than 20 degrees. Since the rotation angle is large, it can be considered that the plurality of second training sample sets obtained after the rotation belong to different fields. Thereby, the purpose of expanding the data through domain transformation is achieved. In this way, there is no need to manually collect data in other fields, and the potential of the first training sample set is fully utilized. Furthermore, based on each second training sample set, the initial model is trained respectively to obtain an intermediate model corresponding to each second training sample set one by one, and the model distillation technology is used to train the final target model with multiple intermediate models as teachers, thereby improving the robustness and test accuracy of the target model.
[0055] In one embodiment, Figure 1As shown, a model training method is provided. This embodiment uses the method applied to a computer device as an example. The computer device can be a terminal or a server. In this embodiment, the method includes the following steps:
[0056] Step 101: A computer device obtains a first training sample set, where the first training sample set includes a plurality of first picture samples.
[0057] In the embodiment of the present application, the first training sample set is original data.
[0058] Optionally, the first training sample set includes multiple first image samples and labels corresponding to each first image sample. For example, the first training sample set is represented as The label corresponding to each first image sample is represented as Y = {y1, ..., y n}.
[0059] Step 102: The computer device obtains multiple sample rotation angles, and for each sample rotation angle, rotates each first image sample in the first training sample set to the sample rotation angle to obtain a second training sample set corresponding to the sample rotation angle.
[0060] The sample rotation angle refers to the rotation angle of the first image samples in the first training sample set. Each sample rotation angle is greater than a preset angle threshold. Optionally, the preset angle threshold may be 20 degrees. Optionally, the preset angle threshold may be 45 degrees.
[0061] Optionally, the angle value of the sample rotation angle can be arbitrarily set manually.
[0062] Optionally, the angle differences between the rotation angles of the multiple samples are equal. In the case where the angle differences are equal, the difference between the rotated image samples can be maximized.
[0063] Optionally, in an embodiment of the present application, the sample rotation angle may include 0 degrees, 45 degrees, 90 degrees, 135 degrees, 180 degrees, 225 degrees, 270 degrees and 315 degrees.
[0064] In the embodiment of the present application, the process of rotating each first image sample in the first training sample set by the computer device is as follows: Taking the sample rotation angle as 45 degrees as an example, the computer device can rotate multiple first image samples in the first training sample set by 45 degrees one by one to obtain multiple rotated first image samples, and the multiple first image samples rotated by 45 degrees form a second training sample set. The second training sample set can be expressed as X 45° , Y 45° .
[0065] It should be noted that when the first image sample is rotated, the label of the first image sample before and after the rotation does not change.
[0066] Optionally, in the embodiment of the present application, the angles of the plurality of first image samples in the first training sample set are assumed to be 0 degrees. Optionally, rotating each first image sample refers to rotating it clockwise.
[0067] The above method may be referred to to respectively rotate each first image sample in the first training sample set to other sample rotation angles, thereby obtaining a second training sample set corresponding to different sample rotation angles.
[0068] It should be noted that, in the embodiment of the present application, since the sample rotation angle is greater than the preset angle threshold, the first training sample set before rotation and the second training sample set after rotation belong to different fields, and each second training sample set also belongs to a different field. The image samples included in each second training sample set belonging to different fields cannot be used for training in the same model, otherwise, the model will crash.
[0069] In an embodiment of the present application, by rotating multiple first image samples included in the first training sample set to a sample rotation angle greater than a preset angle threshold, multiple second training sample sets corresponding to different fields can be obtained after augmentation, thereby achieving the purpose of field augmentation of the original data.
[0070] In an optional implementation, for each second training sample set belonging to a different field, in an embodiment of the present application, multiple image samples in the second training sample set may be augmented again, and the augmentation again means that the multiple image samples in the second training sample set are rotated again. Optionally, when rotating again, the current angle of each image sample in the second training sample set is 0 degrees by default. In addition, the rotation direction of the rotation again may be counterclockwise or clockwise. The rotation angle of the rotation again is less than a preset angle threshold.
[0071] In the embodiment of the present application, referring to the data augmentation method in the prior art, after the image samples in the second training sample set are rotated again, the rotated image samples and the image samples before rotation together constitute the second training sample set.
[0072] After domain augmentation of the first training sample set, a second training sample set corresponding to a different domain is obtained, and then multiple image samples in each second training sample set are augmented again, so that the amount of data in a single second training sample set becomes larger. The total amount of data contained in the multiple second training sample sets finally obtained is greatly expanded compared to the amount of data contained in the first training sample set, so as to obtain the number of training samples required for model training, which can improve the robustness and test accuracy of the final model.
[0073] Step 103: The computer device trains the initial model based on each second training sample set to obtain an intermediate model that corresponds one-to-one to each second training sample set.
[0074] In the embodiment of the present application, for the second training sample set of each field after augmentation, the initial model is trained separately, and finally a plurality of intermediate models are generated, each intermediate model is responsible for one field.
[0075] Continuing with the above example, for the second training sample set X rotated by 0 degrees 0° , Y 0° , the second training sample set can be used to train the initial model, and the trained model obtained is an intermediate model of 0 degree.
[0076] Correspondingly, for the second training sample set X rotated 45 degrees 45° , Y 45° , the second training sample set can be used to train the initial model, and the trained model obtained is a 45-degree intermediate model.
[0077] By analogy, an intermediate model corresponding to each second training sample set is obtained, and the angle of each intermediate model is the angle of the second training sample set for training the intermediate model relative to the first training sample set.
[0078] Step 104: The computer device performs model distillation on the multiple intermediate models to obtain a target model.
[0079] In the embodiment of the present application, the model distillation method can adopt any model distillation method, such as a feature alignment method. Through model distillation, the knowledge of multiple intermediate models can be transferred to the final target model.
[0080] In an embodiment of the present application, a model training method is provided, and after the first image sample in the first training sample set is rotated to a sample rotation angle greater than a preset angle threshold, a plurality of second training sample sets are obtained, wherein the preset angle threshold is an angle greater than 20 degrees. Since the rotation angle is large, it can be considered that the plurality of second training sample sets obtained after the rotation belong to different fields. Thereby, the purpose of expanding the data through domain transformation is achieved. In this way, there is no need to manually collect data in other fields, and the potential of the first training sample set is fully utilized. Furthermore, based on each second training sample set, the initial model is trained respectively to obtain an intermediate model corresponding to each second training sample set one by one, and the model distillation technology is used to train the final target model with multiple intermediate models as teachers, thereby improving the robustness and test accuracy of the target model.
[0081] In one embodiment, Figure 2 As shown, the process of a computer device performing model distillation on multiple intermediate models to obtain a target model may include the following:
[0082] Step 201: The computer device obtains a target image.
[0083] In the embodiment of the present application, the target image is a sample image used for model distillation.
[0084] Optionally, there may be multiple target images.
[0085] Optionally, the target image may be a plurality of first image samples included in the first training sample set.
[0086] Step 202: The computer device rotates the target image to angles corresponding to the intermediate models to obtain a rotated intermediate image.
[0087] In the embodiment of the present application, the angle corresponding to each intermediate model is the angle of the second training sample set for training the intermediate model relative to the first training sample set.
[0088] In the embodiment of the present application, the process of rotating the target image by the computer device may include the following: using the matrix rotation function to rotate the target image to the angles corresponding to the intermediate models. The matrix rotation function may be, for example, torch.rotation(x,90), where x represents the target image and 90 represents the angle to be rotated. torch.rotation(x,90) means rotating the target image by 90 degrees.
[0089] From the above examples, we can see that the angles corresponding to the intermediate models can be 0 degrees, 45 degrees, 90 degrees, 135 degrees, 180 degrees, 225 degrees, 270 degrees and 315 degrees. Therefore, the matrix rotation function can be used to rotate the target image to 0 degrees, 45 degrees, 90 degrees, 135 degrees, 180 degrees, 225 degrees, 270 degrees and 315 degrees respectively, to obtain the intermediate image of 0 degrees, the intermediate image of 45 degrees, the intermediate image of 90 degrees, ..., the intermediate image of 315 degrees.
[0090] Optionally, when the target image is a plurality of first image samples included in the first training sample set, the rotated intermediate image may refer to image samples in each second training sample set.
[0091] In step 203, the computer device inputs the intermediate images into each intermediate model respectively, and obtains the label of the target image according to the output results of each intermediate model.
[0092] In the embodiment of the present application, the computer device inputs the intermediate images into each intermediate model respectively, which means: inputting the intermediate image at 0 degrees into the intermediate model at 0 degrees, inputting the intermediate image at 45 degrees into the intermediate model at 45 degrees,..., inputting the intermediate image at 315 degrees into the intermediate model at 315 degrees.
[0093] For each intermediate image, each intermediate model can test the input intermediate image. For example, if the intermediate model is a target detection model, where the target is not limited to a face, a human body posture, a vehicle or other targets, then the intermediate model can perform target detection on the intermediate image and output the target detection result.
[0094] For multiple intermediate images of the same target image, each intermediate model can output an object detection result corresponding to the target image.
[0095] In an embodiment of the present application, the process of a computer device obtaining a label of a target image according to the output results of each intermediate model may include the following: the computer device may determine the label of the target image according to the output results of each intermediate model.
[0096] For example, the intermediate model is a vehicle detection model, and the detection results output by the intermediate model may include two situations: the presence of a vehicle or the absence of a vehicle. Assuming that the number of intermediate models is 8, after a certain target image is processed based on step 202, 8 intermediate images corresponding to the target image can be obtained. After the 8 intermediate images are respectively input into the corresponding intermediate models, each intermediate model can output a detection result, and a total of 8 output results are obtained. The detection result output by each intermediate model can be used to indicate whether a vehicle exists in the target image or not. Then, the computer device can use the output results that account for more than 50% of the 8 output results as the label of the target image. For example, among the 8 output results, 7 are for the presence of a vehicle and 1 is for the absence of a vehicle. Then, the output result of the presence of a vehicle accounts for more than 50% of the total output results, and therefore, the output result of the presence of a vehicle is determined as the label of the target image.
[0097] There are multiple target images, and the multiple target images can be processed respectively in the above manner to obtain labels of the multiple target images.
[0098] In an optional implementation, the output result of the intermediate model is a feature map. The feature map (English: FeatureMap) is a data matrix.
[0099] In an embodiment of the present application, the process by which a computer device obtains a label of a target image based on the output results of each intermediate model may include the following: the computer device may perform feature fusion on the feature maps output by each intermediate model to obtain a fused feature map, and use the fused feature map as the label of the target image.
[0100] Optionally, the process of performing feature fusion on the feature maps output by each intermediate model may include the following steps:
[0101] In step 301, the computer device adds the feature maps output by each intermediate model bit by bit to obtain a fused feature map.
[0102] Step 302: The computer device determines the fused feature map as the label of the target image.
[0103] In the embodiment of the present application, the purpose of fusing the features learned by multiple intermediate models can be achieved.
[0104] Step 204: The computer device trains the initial model based on the target image and the label of the target image to obtain a target model.
[0105] In an embodiment of the present application, multiple target images and labels of each target image can be used to train the initial model. Since the label of each target image is determined based on the output results of each intermediate model after learning the target image, training the initial model based on the labels of each target image can achieve the purpose of aligning the output results of the final target model with the output results of each intermediate model, that is, achieving the purpose of transferring the knowledge of multiple intermediate models to the target model, thereby improving the robustness and test accuracy of the target model.
[0106] It should be noted that when performing model testing on the target model, for a test image, there is no need to perform any rotation processing on the test image. The test image can be directly input into the trained target model and tested based on the target model.
[0107] It should be understood that although Figure 1-Figure 3 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1-Figure 3 At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.
[0108] In one embodiment, Figure 4 As shown, a model training device is provided, including: a first acquisition module 401, a second acquisition module 402, an intermediate model acquisition module 403 and a distillation module 404, wherein:
[0109] A first acquisition module 401 is used to acquire a first training sample set, where the first training sample set includes a plurality of first picture samples;
[0110] The second acquisition module 402 is used to acquire multiple sample rotation angles. For each sample rotation angle, each first image sample in the first training sample set is rotated to the sample rotation angle to obtain a second training sample set corresponding to the sample rotation angle; wherein each sample rotation angle is greater than a preset angle threshold;
[0111] An intermediate model acquisition module 403 is used to train the initial model based on each second training sample set to obtain an intermediate model corresponding to each second training sample set;
[0112] The distillation module 404 is used to perform model distillation on multiple intermediate models to obtain a target model.
[0113] In one embodiment of the present application, the distillation module 404 is further used to:
[0114] Get the target image;
[0115] Rotate the target image to the angle corresponding to each intermediate model to obtain the rotated intermediate image;
[0116] Input the intermediate images into each intermediate model respectively, and obtain the label of the target image according to the output results of each intermediate model;
[0117] The initial model is trained based on the target image and the label of the target image to obtain the target model.
[0118] In one embodiment of the present application, the distillation module 404 is further used to:
[0119] Use the matrix rotation function to rotate the target image to the angles corresponding to each intermediate model.
[0120] In one embodiment of the present application, the distillation module 404 is further used to:
[0121] The feature maps output by each intermediate model are added bit by bit to obtain a fused feature map;
[0122] The fused feature map is determined as the label of the target image.
[0123] In one embodiment of the present application, the angle differences between the rotation angles of each sample are equal, and the rotation angle of each sample is greater than 20 degrees.
[0124] In one embodiment of the present application, the sample rotation angles include 0 degrees, 45 degrees, 90 degrees, 135 degrees, 180 degrees, 225 degrees, 270 degrees and 315 degrees.
[0125] For the specific definition of the model training device, please refer to the definition of the model training method above, which will not be repeated here. Each module in the above-mentioned model training device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0126] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 5As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store matrix rotation functions. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a model training method is implemented.
[0127] Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0128] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0129] Acquire a first training sample set, where the first training sample set includes a plurality of first image samples;
[0130] Acquire multiple sample rotation angles, and for each sample rotation angle, rotate each first image sample in the first training sample set to the sample rotation angle to obtain a second training sample set corresponding to the sample rotation angle; wherein each sample rotation angle is greater than a preset angle threshold;
[0131] Based on each second training sample set, the initial model is trained respectively to obtain an intermediate model corresponding to each second training sample set one by one;
[0132] Perform model distillation on multiple intermediate models to obtain the target model.
[0133] In one embodiment, when the processor executes the computer program, the processor further implements the following steps: obtaining a target image;
[0134] Rotate the target image to the angle corresponding to each intermediate model to obtain the rotated intermediate image;
[0135] Input the intermediate images into each intermediate model respectively, and obtain the label of the target image according to the output results of each intermediate model;
[0136] The initial model is trained based on the target image and the label of the target image to obtain the target model.
[0137] In one embodiment, when the processor executes the computer program, the following steps are further implemented: using a matrix rotation function to rotate the target image to the angles corresponding to the intermediate models.
[0138] In one embodiment, the output result of the intermediate model is a feature map, and the processor further implements the following steps when executing the computer program:
[0139] The feature maps output by each intermediate model are added bit by bit to obtain a fused feature map;
[0140] The fused feature map is determined as the label of the target image.
[0141] In one embodiment, when the processor executes the computer program, the following steps are further implemented: the angle differences between the rotation angles of each sample are equal, and the rotation angle of each sample is greater than 20 degrees.
[0142] In one embodiment, when the processor executes the computer program, the following steps are further implemented: the sample rotation angles include 0 degrees, 45 degrees, 90 degrees, 135 degrees, 180 degrees, 225 degrees, 270 degrees and 315 degrees.
[0143] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0144] Acquire a first training sample set, where the first training sample set includes a plurality of first image samples;
[0145] Acquire multiple sample rotation angles, and for each sample rotation angle, rotate each first image sample in the first training sample set to the sample rotation angle to obtain a second training sample set corresponding to the sample rotation angle; wherein each sample rotation angle is greater than a preset angle threshold;
[0146] Based on each second training sample set, the initial model is trained respectively to obtain an intermediate model corresponding to each second training sample set one by one;
[0147] Perform model distillation on multiple intermediate models to obtain the target model.
[0148] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented: obtaining a target image;
[0149] Rotate the target image to the angle corresponding to each intermediate model to obtain the rotated intermediate image;
[0150] Input the intermediate images into each intermediate model respectively, and obtain the label of the target image according to the output results of each intermediate model;
[0151] The initial model is trained based on the target image and the label of the target image to obtain the target model.
[0152] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: using a matrix rotation function to rotate the target image to the angles corresponding to the intermediate models.
[0153] In one embodiment, the output result of the intermediate model is a feature map, and the computer program, when executed by the processor, further implements the following steps:
[0154] The feature maps output by each intermediate model are added bit by bit to obtain a fused feature map;
[0155] The fused feature map is determined as the label of the target image.
[0156] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: the angle differences between the rotation angles of each sample are equal, and the rotation angle of each sample is greater than 20 degrees.
[0157] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: the sample rotation angles include 0 degrees, 45 degrees, 90 degrees, 135 degrees, 180 degrees, 225 degrees, 270 degrees and 315 degrees.
[0158] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0159] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0160] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A model training method, characterized in that: The method comprises: Acquire a first training sample set, where the first training sample set includes a plurality of first picture samples; Acquire multiple sample rotation angles, and for each sample rotation angle, rotate each of the first image samples in the first training sample set to the sample rotation angle, to obtain a second training sample set corresponding to the sample rotation angle; wherein each of the sample rotation angles is greater than a preset angle threshold; the sample rotation angles include 0 degrees, 45 degrees, 90 degrees, 135 degrees, 180 degrees, 225 degrees, 270 degrees and 315 degrees; and the rotation direction includes one of counterclockwise rotation and clockwise rotation; Based on each of the second training sample sets, the initial model is trained respectively to obtain an intermediate model corresponding to each of the second training sample sets; wherein the angle of each of the intermediate models is the angle of the second training sample set for training the intermediate model relative to the first training sample set; Acquire a target image; rotate the target image to an angle corresponding to each of the intermediate models to obtain a rotated intermediate image; input the intermediate image into each of the intermediate models, and obtain a label of the target image according to an output result of each of the intermediate models; train the initial model based on the target image and the label of the target image to obtain a target model.
2. The method according to claim 1, characterized in that The step of rotating the target image to angles corresponding to the intermediate models comprises: The target image is rotated to the angle corresponding to each of the intermediate models using a matrix rotation function.
3. The method according to claim 1, characterized in that The output result of the intermediate model is a feature map, and obtaining the label of the target image according to the output result of each intermediate model includes: Adding the feature maps output by each intermediate model bit by bit to obtain a fused feature map; The fused feature map is determined as the label of the target image.
4. The method according to claim 1, characterized in that: The angle differences between the rotation angles of the samples are equal, and the rotation angles of the samples are greater than 20 degrees.
5. A model training device, characterized in that: The device comprises: A first acquisition module, configured to acquire a first training sample set, wherein the first training sample set includes a plurality of first image samples; A second acquisition module is used to acquire multiple sample rotation angles, and for each sample rotation angle, each of the first image samples in the first training sample set is rotated to the sample rotation angle to obtain a second training sample set corresponding to the sample rotation angle; wherein each of the sample rotation angles is greater than a preset angle threshold; the sample rotation angles include 0 degrees, 45 degrees, 90 degrees, 135 degrees, 180 degrees, 225 degrees, 270 degrees and 315 degrees; and the rotation direction includes one of counterclockwise rotation and clockwise rotation; An intermediate model acquisition module, used to train the initial model based on each of the second training sample sets to obtain an intermediate model corresponding to each of the second training sample sets; wherein the angle of each of the intermediate models is the angle of the second training sample set for training the intermediate model relative to the first training sample set; A distillation module is used to obtain a target image; rotate the target image to an angle corresponding to each of the intermediate models to obtain a rotated intermediate image; input the intermediate image into each of the intermediate models, and obtain a label of the target image according to an output result of each of the intermediate models; train the initial model based on the target image and the label of the target image to obtain a target model.
6. The device according to claim 5, characterized in that The distillation module is also used to: use a matrix rotation function to rotate the target image to the angles corresponding to each intermediate model.
7. The device according to claim 5, characterized in that The distillation module is also used to: add the feature maps output by each of the intermediate models bit by bit to obtain a fused feature map; and determine the fused feature map as a label of the target image.
8. The device according to claim 5, characterized in that The angle differences between the rotation angles of the samples are equal, and the rotation angles of the samples are greater than 20 degrees.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 4 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.
