Real-time semantic segmentation method of fisheye images based on knowledge distillation
Through output migration and feature migration technology based on knowledge distillation, the problem of difficulty in balancing real-time performance and accuracy of semantic segmentation methods in the existing technology is solved, and the accuracy and real-time performance of semantic segmentation can be improved without increasing the amount of calculation. Effect.
Patent Information
- Application Number
- CN202110254588.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-09
- Publication Date
- 2024-10-18
- Estimated Expiration
- Not applicable · inactive patent
Smart Images

Figure CN115049534B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a technology in the field of computer vision and pattern recognition, specifically a real-time semantic segmentation method of fisheye images based on knowledge distillation. Background Art
[0002] Most existing semantic segmentation methods are based on deep neural networks. In recent years, some methods for accelerating and improving complex semantic segmentation networks include: limiting the size of network input images, so that complex networks can achieve real-time performance improvements while maintaining the same structure; reducing the size of the network, by pruning early channels of the network or discarding certain stages to improve real-time performance. However, these methods improve the real-time performance of the network at the expense of accuracy and generalization ability, and do not achieve a good balance between real-time performance and accuracy of the model. Summary of the invention
[0003] In view of the above-mentioned deficiencies in the prior art, the present invention proposes a real-time semantic segmentation method for fisheye images based on knowledge distillation, which can effectively suppress the influence of interference such as occlusion and light intensity in the environment during the semantic segmentation of fisheye images. For input high-resolution images, the accuracy of the model can be greatly improved while ensuring real-time performance.
[0004] The present invention is achieved through the following technical solutions:
[0005] The present invention relates to a real-time semantic segmentation method for fisheye images based on knowledge distillation. A data set is constructed by using fisheye images to train a teacher semantic segmentation model. Then, a complex feature extraction skeleton in the teacher semantic segmentation model is replaced with a lightweight skeleton to obtain a lightweight student model. The lightweight student model is trained on the data set. Then, output migration and feature migration based on knowledge distillation are constructed to improve the accuracy while maintaining the real-time performance of the lightweight student model. In the test phase, the lightweight student model is used alone to perform real-time semantic segmentation of fisheye images based on knowledge distillation on the test image.
[0006] The improved accuracy specifically includes: output migration uses a loss function to measure the probability differences between the outputs of the teacher semantic segmentation model and the lightweight student model, so that the outputs of the two are as consistent as possible; feature migration processes the intermediate layer feature maps of the teacher semantic segmentation model and the lightweight student model output to form a similarity attention map, extracts structured information, and aligns the similarity attention map between the teacher semantic segmentation model and the lightweight student model through a loss function to complete the structured knowledge transfer.
[0007] Technical Effects
[0008] The present invention solves the problem that existing semantic segmentation technologies are difficult to balance between real-time performance and accuracy as a whole; the present invention utilizes a teacher semantic segmentation model with a larger parameter scale to assist in the training of a lightweight student model, and obtains the student model by replacing the feature extraction skeleton. Due to the similar structure, the student model can better understand the knowledge acquired by the teacher model from the data set, which is more convenient for knowledge transfer, and can achieve both real-time and accurate semantic segmentation without reducing the resolution of the input image; the knowledge of the teacher semantic segmentation model is effectively extracted and transferred to the lightweight student model through output migration and feature migration, which can improve its accuracy without increasing the computational complexity of the lightweight student model, thereby achieving a balance between the real-time performance and accuracy of the lightweight student model.
[0009] Compared with traditional knowledge distillation technology, the feature transfer module of the present invention can effectively transfer the structured knowledge of the teacher semantic segmentation model to understand the image to the lightweight student model, achieving a greater improvement than traditional output distillation. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] Figure 1 It is the overall framework diagram of the knowledge distillation of the present invention;
[0011] Figure 2 Schematic diagram of images collected by fisheye camera and semantic segmentation;
[0012] Figure 3 This is a schematic diagram of the category distribution of the collected data set;
[0013] Figure 4 Design a flow chart for real-time semantic segmentation software; DETAILED DESCRIPTION
[0014] like Figure 1 As shown, this embodiment relates to a real-time semantic segmentation system for fisheye images based on knowledge distillation, including: a teacher semantic segmentation module, an output transfer module, a feature transfer module and a lightweight student module connected in sequence, wherein: during the training of the lightweight student module, the output transfer module extracts knowledge from the output probability distribution of the teacher semantic segmentation module to the lightweight student module, and the feature transfer module extracts structured knowledge from the feature map of the intermediate layer output of the teacher semantic segmentation module to the lightweight student module.
[0015] The present embodiment relates to a real-time semantic segmentation method of fisheye images based on knowledge distillation of the above-mentioned system. By aligning the differences between the outputs of the teacher model and the student model, a similarity attention map is regenerated and structured semantic knowledge is transferred from the teacher model to the student model. Specifically, street view images are first collected and annotated using a vehicle-mounted fisheye camera to construct a data set, and a teacher model with a large parameter scale is trained on the data set. The student model replaces the complex feature extraction skeleton in the teacher model with a lighter skeleton. The knowledge distillation framework of the present invention is used to transfer the knowledge in the teacher model to the student model, so that the student model can improve its accuracy without changing its real-time performance.
[0016] This embodiment specifically includes the following steps:
[0017] The first step is to use the on-board fisheye camera to collect images to build a data set and train the teacher semantic segmentation model with poor real-time performance but high accuracy:
[0018] The images in the dataset are collected by cameras installed on unmanned vehicles in a real street scene environment. Four cameras are set in the front, back, left, and right directions of the unmanned vehicle to collect street scene images in each direction. The resolution of the collected images is 1920*1080. The pixels are annotated into 18 categories according to the object categories in the image. A dataset of 600 pixel-level annotated images is constructed, of which 350 images are used as training sets, 150 images as validation sets, and 100 images as test sets. The distribution of each category in the dataset is as follows: Figure 2 shown.
[0019] The teacher semantic segmentation model uses BiSeNet as the basic network framework, and its feature extraction skeleton uses the ResNet18 deep network pre-trained on ImgNet, and uses an auxiliary loss function to supervise the network training process, specifically: Where: l m is the main loss function used to supervise the final classification result, X is the final prediction result, W is the network parameter, l i is the auxiliary loss function used to supervise the i-th stage, X i is the feature output by the i-th stage of the model, α is the hyperparameter used to combine the two, and the above losses are all softmax losses.
[0020] The training described uses data augmentation operations on the images in the data set during training, and performs enhancement processing such as mean normalization, random horizontal flipping and random scale transformation before inputting into the teacher semantic segmentation model.
[0021] The random scale transformation sizes include 0.75, 1.0, 1.5, 1.75, and 2.0. Finally, the enhanced images are randomly cropped to a fixed size for training.
[0022] The training described above uses the batch gradient descent algorithm (SGD), and introduces the momentum method (Momentum) and weight decay (WeightDecay) in the training to optimize the batch gradient descent algorithm. The learning rate in the training adopts the poly change strategy, specifically: Among them: lr0 is the initial learning rate, iter is the current number of iterations, max_iter is the maximum number of iterations, and power is the decay exponent; after the training is completed, the accuracy of the teacher model is measured by the average intersection and union, specifically: Where: p ij represents the number of pixels whose label belongs to the i-th class and is predicted to be the j-th class, p ii To predict the correct number of pixels, p ij is the number of false positives (FalsePositives), i.e., the number of pixels that are incorrectly predicted as other categories in the i-th category, p ji It is the false negative number (FalseNegatives), which is the number of pixels that are mistakenly predicted as other categories as the i-th category.
[0023] The second step is to replace the complex feature extraction skeleton in the teacher semantic segmentation model with a lightweight skeleton, and train the improved lightweight network on the data set of the first step. Specifically, the complex feature extraction skeleton ResNet18 in the teacher semantic segmentation model is replaced with the ResNet series or Xception series network pre-trained by ImgNet and used as the lightweight student model, and then trained with the data set of the first step.
[0024] The training of the lightweight student model is the same as the training of the teacher semantic segmentation model in the first step.
[0025] The third step is to use the output transfer processing based on knowledge distillation to measure the difference in output probability distribution between the teacher semantic segmentation model and the lightweight student model using the loss function, so that the outputs of the two are as consistent as possible. Then, through the feature transfer processing based on knowledge distillation, the intermediate layer feature maps of the teacher semantic segmentation model and the lightweight student model are processed to form a similarity attention map, extract structured information, and align the similarity attention map between the teacher semantic segmentation model and the lightweight student model through the loss function to complete the structured knowledge transfer.
[0026] The output migration process is implemented through the L2 loss function, specifically: Where: I is the index set of the corresponding image positions in the teacher semantic segmentation model and the lightweight student model, They are the logits output by the lightweight student model and the teacher semantic segmentation model before the softmax layer. The present invention uses logits to extract knowledge in the output probability distribution.
[0027] The feature migration process is specifically as follows: Among them: A S (φ), A T (φ) are the similarity attention maps output by the lightweight student model and the teacher semantic segmentation model respectively. The process of generating the similarity attention map from the intermediate layer feature map of the model is: Where: A(φ) ij is the similarity between the i-th feature and the j-th feature in the feature graph, φ i is the i-th vector in the feature map.
[0028] The structured knowledge transfer means that the teacher semantic segmentation model guides the lightweight student model through output transfer and feature transfer. During the training process, the parameters of the teacher semantic segmentation model remain unchanged, and the lightweight student model updates its parameters under the supervision of the original softmax loss, output transfer loss and feature transfer loss. The settings of the hyperparameters α and β should keep the three loss functions at the same order of magnitude. In the training process of the lightweight student model, the output transfer loss function and the feature transfer loss function are added on the basis of the original softmax loss function, specifically:
[0029] L total (S) = L CE (S)+αL OT (S)+βL FT (S), where: L CE is the loss function for the separate training of the lightweight student model, L OT is the output migration loss function, L FT is the feature transfer loss function, and α and β are hyperparameters used to adjust the contribution of loss to network training.
[0030] Step 4. During the testing phase, the lightweight student model optimized in the third step is used alone to segment the test image to obtain a segmentation result with a size of 1 / 8 of the original image. The final result is upsampled to the input image size through bilinear interpolation.
[0031] This example illustrates the effectiveness of the method through experiments. The training data set is collected by the on-board surround view camera and is labeled into 18 categories, such as Figure 2As shown in Figure 2. BiSeNet based on ResNet18 is used to guide the training of BiSeNet based on Xception39. During the training process, the hyperparameters are set to α=10, β=1000, lr0=0.1, power=0.9, and batch size=16. The improvement of segmentation effect by different modules is shown in Figure 2. Figure 2 The experimental results are shown in Table 1.
[0032] Table 1 BiSeNet series model distillation experiment
[0033]
[0034]
[0035] Table 1 shows the experimental results of BiSeNet on the collected fisheye image dataset. BiSeNet based on Xception39 1 In BiSeNet based on ResNet18 2 The training is guided by the output distribution, and the L2 output transfer loss function is used to align the output distributions of the two. BiSeNet based on Xception39 1 In BiSeNet based on ResNet18 2 The average intersection-over-union ratio under the guidance of output transfer is 73.7%, which is higher than that of BiSeNet trained separately. 1 After further training with the feature migration distillation scheme designed by the present invention, BiSeNet 1 The average intersection-over-union ratio of the student model is increased to 74.6%. The two-part distillation increases the average intersection-over-union ratio of the student model by 1.7%.
[0036] In this example, the distilled model is deployed on the NVIDIA Jetson Xavier embedded platform, and the embedded platform is used to achieve real-time semantic segmentation in a real environment, with a speed of 14 FPS, which proves that the semantic segmentation method of the present invention has both accuracy and real-time performance. The real-time performance test of the model is shown in Table 2.
[0037] Table 2 Real-time performance comparison of models on NVIDIA Jetson Xavier embedded platform
[0038] Model skeleton Test platform Input size FPS <![CDATA[BiSeNet 1 ]]> Xception39 Xavier 1920*1080 14.0 <![CDATA[BiSeNet 2 ]]> ResNet18 Xavier 1920*1080 6.6
[0039] In order to improve the segmentation performance of the existing real-time semantic segmentation network, the present invention designs a set of training schemes for the semantic segmentation network based on the knowledge distillation technology. On the basis of achieving real-time semantic segmentation, a higher-performance real-time lightweight student model is obtained through distillation training in two aspects, output migration and feature migration, with the help of a complex and accurate teacher semantic segmentation model. The present invention can effectively extract the knowledge in the complex teacher semantic segmentation model and migrate it to the lightweight student model. While greatly improving the accuracy of the lightweight semantic segmentation model, there is no increase in any computational complexity. It has the advantages of flexible application and significant improvement in accuracy.
[0040] Compared with the prior art, the present invention improves the accuracy of the existing semantic segmentation model by designing a knowledge distillation framework without changing the real-time performance. As can be seen from the embodiment, Table 1 is the experimental results of BiSeNet under the collected fisheye image dataset. BiSeNet based on Xception39 1 In BiSeNet based on ResNet18 2 The training is guided by the output distribution, and the L2 output transfer loss function is used to align the output distributions of the two. BiSeNet based on Xception39 1 In BiSeNet based on ResNet18 2 The average intersection-over-union ratio under the guidance of output transfer is 73.7%, which is higher than that of BiSeNet trained separately. 1 After further training with the feature migration distillation scheme designed by the present invention, BiSeNet 1 The average intersection-over-union ratio of the student model is increased to 74.6%. The two-part distillation increases the average intersection-over-union ratio of the student model by 1.7%. While the accuracy is improved, the computational complexity of the student model does not increase at all.
[0041] The above-mentioned specific implementation can be partially adjusted in different ways by those skilled in the art without departing from the principle and purpose of the present invention. The protection scope of the present invention shall be based on the claims and shall not be limited by the above-mentioned specific implementation. Each implementation scheme within its scope shall be subject to the constraints of the present invention.
Claims
1. A real-time semantic segmentation method for fisheye images based on knowledge distillation, characterized in that: A data set is constructed using fisheye images to train a teacher semantic segmentation model. The complex feature extraction skeleton in the teacher semantic segmentation model is then replaced with a lightweight skeleton to obtain a lightweight student model. The lightweight student model is then trained on the data set. Output migration and feature migration based on knowledge distillation are then constructed to improve the accuracy while maintaining the real-time performance of the lightweight student model. In the test phase, the lightweight student model is used alone to perform real-time semantic segmentation of fisheye images based on knowledge distillation on the test image. The improved accuracy specifically includes: output migration uses a loss function to measure the probability difference between the outputs of the teacher semantic segmentation model and the lightweight student model, so that the outputs of the two are as consistent as possible; feature migration processes the intermediate layer feature maps of the teacher semantic segmentation model and the lightweight student model output to form a similarity attention map, extracts structured information, and aligns the similarity attention map between the teacher semantic segmentation model and the lightweight student model through a loss function to complete the structured knowledge migration; The output migration process is implemented through the L2 loss function, specifically: Where: I is the index set of the corresponding image positions in the teacher semantic segmentation model and the lightweight student model, They are the logits output by the lightweight student model and the teacher semantic segmentation model before the softmax layer. The present invention uses logits to extract knowledge in the output probability distribution; The feature migration process is specifically as follows: Among them: A S (φ), A T (φ) are the similarity attention maps output by the lightweight student model and the teacher semantic segmentation model respectively. The process of generating the similarity attention map from the intermediate layer feature map of the model is: Where: A(φ) ij is the similarity between the i-th feature and the j-th feature in the feature graph, φ i is the i-th vector in the feature map; The structured knowledge transfer refers to: the teacher semantic segmentation model guides the lightweight student model through output transfer and feature transfer. During the training process, the parameters of the teacher semantic segmentation model remain unchanged, and the lightweight student model updates its parameters under the supervision of the original softmax loss, output transfer loss and feature transfer loss. The settings of the hyperparameters α and β should keep the three loss functions at the same order of magnitude; in the training process of the lightweight student model, based on the original softmax loss function, the output transfer loss function and the feature transfer loss function are added, specifically: L total (S) = L CE (S)+αL OT (S)+βL FT (S), where: L CE is the loss function for the separate training of the lightweight student model, L OT is the output migration loss function, L FT is the feature transfer loss function, and α and β are hyperparameters used to adjust the contribution of loss to network training.
2. The method for real-time semantic segmentation of fisheye images based on knowledge distillation according to claim 1, characterized in that: The teacher semantic segmentation model uses BiSeNet as the basic network framework, and its feature extraction skeleton uses the ResNet18 deep network pre-trained on ImgNet, and uses an auxiliary loss function to supervise the network training process, specifically: Among them: m is the main loss function used to supervise the final classification result, X is the final prediction result, W is the network parameter, l i is the auxiliary loss function used to supervise the i-th stage, X i is the feature output by the i-th stage of the model, α is the hyperparameter used to combine the two, and the above losses are all softmax losses.
3. The method for real-time semantic segmentation of fisheye images based on knowledge distillation according to claim 2, characterized in that: The training described above adopts a batch gradient descent algorithm. The momentum method and weight decay are introduced in the training to optimize the batch gradient descent algorithm. The learning rate adopts a poly change strategy, specifically: Among them: lr0 is the initial learning rate, iter is the current number of iterations, max_iter is the maximum number of iterations, and power is the decay exponent; after the training is completed, the accuracy of the teacher model is measured by the average intersection and union, specifically: Where: p ij represents the number of pixels whose label belongs to the i-th class and is predicted to be the j-th class, p ii To predict the correct number of pixels, p ij is the number of false positives, i.e., the number of pixels that are incorrectly predicted as other categories in the i-th category, p ji It is the false negative number, that is, the number of pixels that are incorrectly predicted as other categories as class i.
4. The method for real-time semantic segmentation of fisheye images based on knowledge distillation according to any one of claims 1 to 3, characterized in that: include: The first step is to use the on-board fisheye camera to collect images to build a dataset and train a teacher semantic segmentation model with poor real-time performance but high accuracy; The second step is to replace the complex feature extraction skeleton in the teacher semantic segmentation model with a lightweight skeleton, and train the improved lightweight network on the data set of the first step. Specifically, the complex feature extraction skeleton ResNet18 in the teacher semantic segmentation model is replaced with a ResNet series or Xception series network pre-trained by ImgNet and used as a lightweight student model, and then trained with the data set of the first step. The training method of the lightweight student model is the same as that of the teacher semantic segmentation model in the first step. The third step is to use the loss function to measure the difference in the output probability distribution of the teacher semantic segmentation model and the lightweight student model through output migration processing based on knowledge distillation, so that the outputs of the two are as consistent as possible. Then, through the feature migration processing based on knowledge distillation, the intermediate layer feature maps of the teacher semantic segmentation model and the lightweight student model are processed to form a similarity attention map, extract structured information, and align the similarity attention map between the teacher semantic segmentation model and the lightweight student model through the loss function to complete the structured knowledge migration. Step 4. During the testing phase, the lightweight student model optimized in the third step is used alone to segment the test image to obtain a segmentation result with a size of 1 / 8 of the original image. The final result is upsampled to the input image size through bilinear interpolation.
5. A system for implementing the real-time semantic segmentation method of fisheye images based on knowledge distillation as described in any one of claims 1 to 4, characterized in that: include: The teacher semantic segmentation module, output transfer module, feature transfer module and lightweight student module are connected in sequence, wherein: during the training of the lightweight student module, the output transfer module extracts the knowledge in the output probability distribution of the teacher semantic segmentation module to the lightweight student module, and the feature transfer module extracts the structured knowledge in the feature map of the intermediate layer output of the teacher semantic segmentation module to the lightweight student module.
