Image detection method, system, equipment and device based on depth estimation
By combining supervised and semi-supervised learning data sets, the semantic-assisted perception model is used to optimize the depth estimation model, which solves the problem of insufficient generalization ability of the depth estimation model and achieves higher robustness and accuracy in the autonomous driving system. Reduces hardware cost and computational complexity.
Patent Information
- Application Number
- CN202410596294.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-14
- Publication Date
- 2024-08-30
AI Technical Summary
Existing depth estimation models have insufficient generalization capabilities in autonomous driving systems, especially poor performance in new environments and different lighting conditions, and rely on expensive lidar or computationally intensive binocular cameras, which suffer from hardware cost and computational complexity issues. .
By combining annotated supervised learning data sets and unlabeled semi-supervised learning data sets, a data set with pseudo-depth labels is generated, and the data set is optimized using a semantic-assisted perceptual model and random diverse perturbations, and the student model is trained to improve Accuracy and robustness of depth estimation, mapping directly from RGB images to depth maps simplifies the depth estimation process.
Improves the generalization ability of the depth estimation model in new environments, reduces hardware costs, simplifies computational complexity, enhances the scalability and adaptability of the model, and can maintain detection accuracy in unfamiliar scenes and lighting conditions .
Smart Images

Figure CN118570753A
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of autonomous driving and relates to a detection method, and in particular to an image detection method, system, equipment and device based on depth estimation. Background Art
[0002] Forward-looking depth estimation for autonomous driving is of great significance in autonomous driving systems and is essential for achieving safe, efficient, and intelligent autonomous driving functions. It can be used in autonomous driving environment perception and obstacle detection, planning and decision support, adaptive driving experience, unmanned vehicle positioning and navigation, reducing sensor dependence, and improving robustness. Monocular depth estimation is the task of estimating the depth value (relative to the camera distance) for each pixel of a given monocular or single RGB (Red, Green, Blue) image. This challenging task is a key prerequisite for determining scene understanding for applications such as 3D scene reconstruction, autonomous driving, and AR (Augmented Reality). The most advanced methods are generally divided into two categories: the first is to design a complex network that is powerful enough to directly regress the depth map. This type of method uses a deep student model, usually a convolutional neural network (CNN), to directly map the input RGB image to the depth map. This requires the network to learn the complex mapping between the features extracted from the image and the true depth or use an attention mechanism to enable the network to focus on specific areas in the image, thereby improving the accuracy of depth estimation; the second is to divide the input into boxes or windows to reduce computational complexity, divide the input image into local blocks or windows, and then estimate the depth of each block separately. The depth estimation results of these blocks can be merged to obtain the overall depth map.
[0003] However, the existing methods have many defects in terms of both hardware and algorithms. In terms of hardware devices, LiDAR is one of the main depth perception sensors in autonomous driving. It generates point clouds by emitting laser beams and measuring their reflection time to obtain distance information. Although the data generated by LiDAR is the densest, it is usually expensive, especially automotive-grade LiDAR, which can even cost tens of thousands of yuan; and some LiDAR devices are relatively large and heavy, which may be inconvenient for embedded systems and small vehicles; at the same time, when encountering visible airborne particles such as dust, rain, snow or fog, the perception of LiDAR will be affected. Another is the binocular camera, which can calculate the parallax of objects and infer the depth by acquiring images on the baseline between cameras. This method is more economical than LiDAR and can provide denser depth information. However, it requires accurate internal and external parameters to be repeatedly and tediously calibrated to ensure correct depth estimation, and binocular cameras usually require computationally intensive operations such as stereo matching, which may affect real-time performance and system complexity. In terms of software algorithms, the existing depth estimation models have insufficient generalization capabilities and are greatly affected by the external scene environment. Summary of the invention
[0004] The present application provides an image detection method, system, device and apparatus based on depth estimation, which are mainly used to solve the problem of insufficient generalization ability of depth estimation models.
[0005] In a first aspect, the present application provides an image detection method based on depth estimation, the method comprising: obtaining a training data set, the training data set comprising a labeled supervised learning data set and an unlabeled semi-supervised learning data set; using the supervised learning data set to train a teacher model, using the teacher model after training to generate a data set with a pseudo-depth label for the semi-supervised learning data set, and merging the supervised learning data set and the data set with the pseudo-depth label into a combined data set; optimizing the data set with the pseudo-depth label by combining a semantically-assisted perception model and random diverse perturbations, training the teacher model with the optimized combined set to generate a student model; converting and encapsulating the student model according to the model weight of the student model, and using the encapsulated and deployed student model to perform depth estimation on the detected object.
[0006] In this application, model training is performed using labeled supervised learning datasets and unlabeled semi-supervised learning datasets, which improves the problem of lack of labeled data and avoids the problem that the depth estimation model performs well in the training data but may have poor generalization ability in scenarios that are significantly different from the training data.
[0007] In an implementation of the first aspect, the teacher model includes a monocular depth estimation model, and the monocular depth estimation model includes a depth estimation head and a self-supervised encoder model.
[0008] In an implementation of the first aspect, the step of training a teacher model using the supervised learning data set includes: loading the supervised learning data set to generate each input tensor; loading the pre-trained corresponding version of the self-supervised encoder model according to the set encoder, inputting the input tensor into the self-supervised encoder model, and generating the intermediate layer features and classification labels corresponding to the supervised learning data set; the classification labels are used to identify each intermediate layer feature in a classified manner; the intermediate layer features are passed to the depth estimation head to generate a depth estimation result; the depth estimation result includes a depth map; the classification labels are processed by linear transformation and activation function; the depth map is scaled to the original image size by interpolation; the scaled depth map is activated and squeezed to obtain the final depth map; an affine invariant loss function is used to calculate the unknown scale and displacement ignored by each sample in the supervised learning data set, and the calculation result of the affine invariant loss function is used as the evaluation indicator of the teacher model.
[0009] In an implementation of the first aspect, the intermediate layer features are passed to a depth estimation head to generate a depth estimation result; the step of processing the classification mark through linear transformation and activation function includes: allowing the depth estimation head to project the intermediate layer features using convolution; resizing the projected features through a transposed convolution sequence and an identity mapping layer; performing a linear transformation and activation on each adjusted projection layer to process the classification mark; creating a basic structure and a layer-by-layer progressive feature fusion block; the basic structure refers to a module containing a series of convolution layers, and the feature fusion block is used to fuse features of different levels in the model; the features of the last layer are input into a preset convolution structure, and the depth estimation result is output.
[0010] In this implementation, the trained depth estimation model can maintain the accuracy of detection when facing unfamiliar scenes, lighting, weather, or occlusion, and the estimated depth of detection can remain consistent.
[0011] In an implementation of the first aspect, a data set with pseudo-depth labels is optimized by combining a semantically assisted perception model and random diverse perturbations, and the teacher model is trained using the optimized combination set to generate a student model, including: optimizing the assignment of semantic segmentation labels to the data set with pseudo-depth labels in the combination set using the semantically assisted supervision model; injecting random diverse perturbations with strong color distortion and strong spatial distortion into the data set with pseudo-depth labels to introduce randomness and diversity of images in the combination set; and training the teacher model using the optimized combination set to generate a student model.
[0012] In an implementation of the first aspect, the step of injecting random diverse perturbations of strong color distortion and strong spatial distortion into a dataset with pseudo-depth labels includes: in strong color distortion, adjusting the brightness, contrast, saturation and hue of the image and applying a Gaussian filter to blur the image to introduce randomness and diversity of the image; in strong spatial distortion, randomly selecting a rectangular area from an image, and then randomly selecting another image from the combined dataset and replacing it with a rectangular area at the same position in the other image; at the same time, the labels are weighted according to the mixed areas to improve the student model's ability to learn changes and relationships between different objects.
[0013] In this implementation, the complexity of the deep student model is simplified, so there is no need to consider the limitations of computing power in embedded systems or real-time applications.
[0014] In an implementation of the first aspect, the step of training the teacher model using the optimized combination set to generate a student model also includes: calculating the loss function of the combination set, and using the calculation result of the loss function as an evaluation indicator of the student model.
[0015] In a second aspect, the present application provides an image detection system based on depth estimation, the system comprising: a data set acquisition module, configured to acquire a training data set, the training data set comprising a labeled supervised learning data set and an unlabeled semi-supervised learning data set; a model training module, configured to use the supervised learning data set to train a teacher model, use the teacher model after training to generate a data set with a pseudo-depth label for the semi-supervised learning data set, and combine the supervised learning data set and the data set with the pseudo-depth label into a combined data set; optimize the data set with the pseudo-depth label in combination with a semantically-assisted perception model and random diverse perturbations, train the teacher model using the optimized combined set, and generate a student model; a depth estimation module, configured to convert and encapsulate the student model according to the model weight of the student model, and use the encapsulated and deployed student model to perform depth estimation on the detected object.
[0016] In a third aspect, the present application provides an electronic device, comprising: a processor and a memory; the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the electronic device performs the described method.
[0017] In a fourth aspect, the present application provides an image detection device based on depth estimation, the device comprising: the electronic device and the image acquisition device; the image acquisition device is communicatively connected to the electronic device; the image acquisition device transmits real-time image data corresponding to the detected object to the electronic device; the electronic device uses a packaged and deployed student model to perform depth estimation on the detected object.
[0018] In an implementation manner of the fourth aspect, the electronic device includes a display interface; the display interface is used to display the depth estimation result and real-time image data corresponding to the detected object.
[0019] As described above, the image detection method, system, device and apparatus based on depth estimation described in this application have the following
[0020] Beneficial effects:
[0021] The student model trained in this application realizes the mapping directly from the original input data (monocular image) to the output result (depth map), without the need to manually design complex feature extractors, which simplifies the entire depth estimation process and improves the scalability and adaptability of the model. And using multiple pre-trained joint deep student models (student models), the model trained on large-scale image data is transferred to learn, which accelerates the learning of the task of monocular depth estimation. At the same time, by training on large-scale data sets, the deep student model can better generalize to new and unseen data, thereby improving the robustness in practical applications. This application only requires RGB images as input, without the need for additional depth sensors, which reduces the hardware cost of the system and improves the flexibility of deployment. In addition, the depth estimation method of this application plays an important role in the fields of autonomous driving, parking, traffic management and vehicle navigation. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 Shown is a schematic diagram of an application scenario of the image detection method based on depth estimation described in an embodiment of the present application.
[0023] Figure 2 Shown is a principle flow chart of the image detection method based on depth estimation described in an embodiment of the present application.
[0024] Figure 3 Shown is a flowchart of teacher model training for the depth estimation-based image detection method described in an embodiment of the present application.
[0025] Figure 4 Shown is a flowchart of preliminary generation of depth estimation results of the depth estimation-based image detection method described in an embodiment of the present application.
[0026] Figure 5 Shown is a student model training flowchart of the depth estimation-based image detection method described in an embodiment of the present application.
[0027] Figure 6 Shown is a depth estimation flow chart after model deployment of the depth estimation-based image detection method described in an embodiment of the present application.
[0028] Figure 7 Shown is an overall flow chart of the image detection method based on depth estimation described in an embodiment of the present application.
[0029] Figure 8 Shown is a first output effect diagram of the image detection method based on depth estimation described in an embodiment of the present application.
[0030] Fig. 9 Shown is a second output effect diagram of the image detection method based on depth estimation described in an embodiment of the present application.
[0031] Fig.10 Shown is a structural principle diagram of the image detection system based on depth estimation described in an embodiment of the present application.
[0032] Fig.11 Shown is a schematic diagram of the structural connection of an electronic device described in an embodiment of the present application.
[0033] Fig.12 Shown is a structural principle diagram of the image detection device based on depth estimation described in an embodiment of the present application.
[0034] Component number description
[0035] 1 Image Detection System Based on Depth Estimation
[0036] 11 Dataset acquisition module
[0037] 12 Model Training Module
[0038] 13 Depth Estimation Module
[0039] 2 Electronic devices
[0040] 21 Processor
[0041] 22 Memory
[0042] 23 Communication Interface
[0043] 24 System bus
[0044] 3 Image acquisition equipment
[0045] Steps S21 to S23
[0046] Steps S31 to S36
[0047] Steps S331 to S335
[0048] Steps S51 to S53
[0049] Steps S61 to S63 DETAILED DESCRIPTION
[0050] The following describes the embodiments of the present application through specific examples, and those skilled in the art can easily understand other advantages and effects of the present application from the contents disclosed in this specification. The present application can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present application. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.
[0051] It should be noted that the illustrations provided in the following embodiments are only used to illustrate the basic concept of the present application in a schematic manner, and therefore the illustrations only show components related to the present application rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.
[0052] The following embodiments of the present application provide image detection methods, systems, devices and apparatuses based on depth estimation, including but not limited to electronic devices applied to vehicles. This application scenario will be described below as an example.
[0053] See also Figure 1 , which is a schematic diagram of an application scenario of the image detection method based on depth estimation described in an embodiment of the present application. Figure 1 As shown, this embodiment provides an application scenario of an image detection method based on depth estimation, specifically comprising: an electronic device. A pre-trained student model is deployed in the electronic device, real-time image data of the detected object is obtained, the image detection method based on depth estimation is executed, and the real-time image data is input into the student model to output a depth estimation result.
[0054] The electronic device may be a computer including all or part of the components such as a memory, a storage controller, one or more processing units (CPU), a peripheral interface, an RF circuit, an audio circuit, a speaker, a microphone, an input / output (I / O) subsystem, a display screen, other output or control devices, and an external port; the computer includes but is not limited to a personal computer such as a laptop, a tablet computer, a smart phone, etc. placed in the vehicle, or may be the hardware electronic device of the vehicle itself. In other embodiments, the electronic device may also be a server, which may be arranged on one or more physical servers according to various factors such as function and load, or may be a cloud server composed of a distributed or centralized server cluster, which is not limited in this embodiment.
[0055] The technical solutions in the embodiments of the present application will be described in detail below in conjunction with the drawings in the embodiments of the present application.
[0056] See also Figure 2 , which is a principle flow chart of the image detection method based on depth estimation described in an embodiment of the present application.
[0057] like Figure 2 As shown, this embodiment provides an image detection method based on depth estimation, which specifically includes the following steps:
[0058] S21, obtaining a training data set, wherein the training data set includes a labeled supervised learning data set D l and unlabeled semi-supervised learning dataset D u Thus, the present application avoids the lack of labeled data and also improves the generalization ability of the model from the perspective of the training data set in specific scenarios or new environments.
[0059] Specifically, the steps for generating each data set in the training data set are as follows:
[0060] (1) We collected 62 million unlabeled images with rich information but without any processing from 8 large-scale open source datasets; formally, we denote the unlabeled image dataset as D u . The eight datasets include: BDD100K, Google Landmarks, ImageNet-21K, LSUN, Objects365, Open Images V7, Places365, and SA-1B.
[0061] (2) For these images D uA special annotation tool, namely the teacher model T (where the teacher model T is the MDE model, Monocular Depth Estimation, monocular depth estimation model), is specially designed. The generation of the MDE model annotation tool includes: collecting 1.5 million labeled images D from another 6 public datasets l To train an initial MDE (Monocular Depth Estimation) model, the labeled supervised learning dataset is formally represented as D l .
[0062] It should be noted that the present application may change the design of the annotation tool and adopt different algorithms or methods to annotate images; use different open source data sets, or change the scale and type of data sets to ensure training on data from different fields, and adopt other ways to obtain unlabeled images, such as using unsupervised learning methods to generate virtual labels.
[0063] S22, using the supervised learning dataset D u A teacher model is trained, and the trained teacher model is used to generate a dataset D with pseudo depth labels for the semi-supervised learning dataset. uf , combining the supervised learning dataset and the dataset with pseudo-depth labels into a combined dataset; optimizing the dataset with pseudo-depth labels by combining a semantically-assisted perception model and random diverse perturbations, and using the optimized combined set to train the teacher model to generate a student model.
[0064] In one embodiment, the teacher model includes a monocular depth estimation model, and the monocular depth estimation model includes a depth estimation head DPTHead and a self-supervised encoder model DINOv2.
[0065] Specifically, the student model, namely the Depth Anything model, as a hybrid model, specifically refers to the supervised learning dataset D l Learn the teacher model T (initial MDE); then, use T as the unlabeled semi-supervised learning dataset D u Generate a dataset D with pseudo-depth labels uf ; Finally, in the tag set D l and D uf The combination of pseudo-labeled sets D, and a semantic auxiliary supervision module M is developed to force the model to inherit rich semantic priors from the pre-trained encoder, and finally a student model S is trained.
[0066] Furthermore, given the previously obtained teacher model T, we can uThe prediction results are obtained on the D u Generate a dataset D with pseudo-depth labels uf ).
[0067] S23, converting and encapsulating the student model according to the model weight of the student model, and using the encapsulated and deployed student model to perform depth estimation on the detected object. Specifically, for the model weight conversion and encapsulation of the student model, the student model is integrated into the Jetson board, a suitable camera is set, and then the reasoning is displayed using the application interface of the electronic device.
[0068] See also Figure 3 , which is a flow chart of teacher model training for the image detection method based on depth estimation described in the embodiment of the present application. Figure 3 As shown, the steps of training a teacher model using the supervised learning data set include:
[0069] S31, load the supervised learning dataset and generate various input tensors.
[0070] S32, load the pre-trained corresponding version of the self-supervised encoder model according to the set encoder, input the input tensor into the self-supervised encoder model, and generate the intermediate layer features and classification labels corresponding to the supervised learning data set; the classification labels are used to identify each intermediate layer feature in a classified manner.
[0071] S33, passing the intermediate layer features to the depth estimation head to generate a depth estimation result; the depth estimation result includes a depth map; and processing the classification mark through linear transformation and activation function.
[0072] Specifically, the teacher model T based on DPT_DINOv2 learns labeled images. DPT_DINOv2 consists of the depth estimation head DPTHead that mainly does regression and the self-supervised encoder DINOv2. First, load the image data D l Generate input tensors one by one, then load the pre-trained DINOv2 model directly from local or remote, load a certain version of the model according to the specified encoder ("vits", "vitb", "vitl"), generate the intermediate layer features and classification tags of the DINOv2 model, and then pass the intermediate layer features to the depth estimation head DPTHead to generate the depth estimation result.
[0073] See also Figure 4 , which is a flowchart showing the initial generation of depth estimation results of the image detection method based on depth estimation described in the embodiment of the present application. Figure 4As shown, the intermediate layer features are passed to the depth estimation head to generate a depth estimation result; step S33 of processing the classification mark by linear transformation and activation function includes:
[0074] S331, enabling the depth estimation head to project the intermediate layer features using convolution.
[0075] Specifically, DPTHead first uses a series of 1x1 convolutions on the input (image data D l ) is projected, and the number of output channels of each projection layer is specified by the out_channels parameter.
[0076] S332, resize the projected features through a transposed convolution sequence and an identity mapping layer.
[0077] Specifically, the projected features are resized using a sequence of transposed convolutions (a convolution with a kernel size of 4x4, a stride of 4, and padding of 0, a convolution with a kernel size of 2x2, a stride of 2, and padding of 0, and a convolution with a kernel size of 3x3, a stride of 2, and padding of 1) and an identity mapping layer commonly used in transfer learning.
[0078] S333, performing linear transformation and activation on each adjusted projection layer to process the classification label.
[0079] Specifically, a linear transformation and a GELU (Gaussian Error Linear Units) activation function are applied to each projection layer to process classification labels.
[0080] S334, creating a basic structure and a layer-by-layer progressive feature fusion block; the basic structure refers to a module including a series of convolutional layers, and the feature fusion block is used to fuse features of different levels in the model.
[0081] Specifically, the basic structure is created by calling the Pytorch basic library function (creating a module containing a series of convolutional layers, defining the shapes of four output features according to the shape of the input features and whether to expand them, and using the nn.Conv2d function to create four convolutional layers with a kernel size of 3x3, a stride of 1, a padding of 1, no bias, and grouped convolutions, corresponding to different input features, and finally outputting the processed feature values), and then creating some layer-by-layer progressive feature fusion blocks to fuse features at different levels in the model.
[0082] S335, input the features of the last layer into a preset convolution structure, and output the depth estimation result.
[0083] Specifically, the features of the last layer are input into the CLC channel local convolution structure (a convolution with a kernel size of 3x3, a stride of 1, and a padding of 1 + a ReLU activation function + a convolution with a kernel size of 1x1, a stride of 1, and a padding of 0) and then used as the output.
[0084] S34, scaling the depth map to the original image size by using an interpolation method. Specifically, the interpolation method may be, for example, bilinear interpolation or other interpolation methods that can achieve an image scaling function.
[0085] S35, activating and squeezing the scaled depth map to obtain a final depth map.
[0086] Specifically, a ReLU (Rectified Linear Unit) activation function is applied for activation, and the depth map is squeezed from the channel dimension through the squeeze(1) function to obtain the final depth map.
[0087] S36, using an affine invariant loss function to calculate the unknown scale and displacement ignored by each sample in the supervised learning data set, and using the calculation result of the affine invariant loss function as an evaluation indicator of the teacher model.
[0088] Specifically, the affine invariant loss function is used to calculate D l The unknown scale and displacement of each sample are ignored as evaluation indicators.
[0089]
[0090]
[0091]
[0092] t(d)=median(d)
[0093] Among them, H represents the length of the graph, W represents the width of the graph, and i represents the index value after the graph is expanded into a one-dimensional sequence. and d i are the prediction and ground truth respectively. p is the affine invariant mean absolute error loss: in, and It is a prediction and the ground truth d i The scaled and shifted versions of t(d) and s(d) are used to align the predictions with the ground truth to obtain zero translation and unit scale.
[0094] It should be noted that the present application can use different deep learning models as teacher models, such as other self-supervised learning frameworks or regression models; change the way of image loading and pre-training models, such as other image processing libraries or pre-training model sources; modify the feature generation process, possibly by using different encoders or other transformations to generate intermediate layer features; modify the projection layer structure of DPTHead, such as other convolution kernel size, number of output channels and other parameters, and adjust the parameters of the transposed convolution sequence, such as convolution kernel size, stride and padding value, and adjust the identity mapping layer used; use different infrastructure creation methods, such as other convolution layer combinations or module designs; modify the structure or number of feature fusion blocks to adapt to the fusion requirements of features at different levels; change the output structure of the last layer, adjust the convolution kernel size, stride, activation function and other parameters, such as other output structures, to meet different task requirements.
[0095] See also Figure 5 , which is a flow chart of the student model training of the image detection method based on depth estimation described in the embodiment of the present application. Figure 5 As shown, the step of optimizing the data set with pseudo-depth labels by combining the semantic-assisted perceptual model and random diverse perturbations, training the teacher model using the optimized combination set, and generating the student model includes: step S51 to step S53. Prior to this, step A to step C are the training process of the semantic-assisted supervision model, so as to optimize the allocation of semantic segmentation labels to the data set with pseudo-depth labels in the combination set using the trained and optimized semantic-assisted supervision model.
[0096] A, The semantically assisted supervision model is trained using the Cityscapes dataset.
[0097] Specifically, the Cityscapes dataset was used for training, and a data loading pipeline was configured, including image loading, label loading, random cropping, random flipping, etc.; then the data was preprocessed, including normalization, color channel exchange and other common operations.
[0098] B. Determine the backbone network and neck network of the semantic-assisted supervision model, and perform pyramid fusion on features at different levels.
[0099] Specifically, the semantic-assisted supervision model uses an Encoder-Decoder structure, and the backbone network is GroundingDINO, specifically DINOv2 as the backbone network, the version is "large" and the parameters of the backbone network are not frozen; the neck network uses Feature Pyramid Network (FPN) to pyramidally fuse features at different levels.
[0100] C. Optimize the semantic-assisted supervision model according to the determined decoding head and loss function, and configure the training parameters of the semantic-assisted supervision model.
[0101] Specifically, Mask2FormerHead is used as the decoding head, which includes a Transformer decoder (using Mask2FormerTransformerDecoder, containing 9 Transformer decoder layers) and a pixel decoder (using MSDeformAttnPixelDecoder including self-attention layer and multi-scale deformation attention); then the loss function is determined, including using CrossEntropyLoss as the classification loss to classify each pixel and using CrossEntropyLoss as the segmentation loss for each image. The pixels are segmented and DiceLoss is used as Dice loss for auxiliary optimization; finally, the training parameters are configured. The training strategy uses IterBasedTrainLoop for iterative training, with a total of 80,000 training times, and a validation every 5,000 iterations. The sliding window test is used, and the cropping size of the test image is (896,896), the sliding window step is (518,518), and the AdamW optimizer is used. The learning rate is set to 0.00003 and the weight decay is 0.05. The learning rate scheduler uses LinearLR and PolyLR to adjust the learning rate, and the parameters are saved regularly to train the model M. The loss function is as follows:
[0102]
[0103] Among them, cos() measures the cosine similarity between two feature vectors. i is the feature extracted by the deep model S, and f i ' are features extracted from the frozen DINOv2 encoder.
[0104] S51, optimizing the allocation of semantic segmentation labels to the data set with pseudo-depth labels in the combined set by using the semantic-assisted supervision model.
[0105] S52, injecting random diverse perturbations of strong color distortion and strong spatial distortion into the dataset with pseudo-depth labels to introduce randomness and diversity into the images in the combined set.
[0106] S53, using the optimized combination set to train the teacher model to generate a student model.
[0107] In one embodiment, the step of injecting random diverse perturbations with strong color distortion and strong spatial distortion into a dataset with pseudo-depth labels includes:
[0108] In strong color distortion, the brightness, contrast, saturation and hue of the image are adjusted and a Gaussian filter is applied to blur the image to introduce randomness and diversity to the image; in strong spatial distortion, a rectangular area is randomly selected from an image, and then another image is randomly selected from the combined dataset and replaced with a rectangular area at the same position in the other image; at the same time, the labels are weighted according to the mixed areas to improve the student model's ability to learn changes and the relationship between different objects.
[0109] In one embodiment, the step of training the teacher model using the optimized combination set to generate a student model also includes: calculating the loss function of the combination set, and using the loss function calculation result as an evaluation indicator of the student model.
[0110] Specifically, during the training of the student model S, two strong perturbations are injected into the dataset D, forcing the student model to actively seek additional visual knowledge and obtain invariant representations from these datasets D. Specifically, two forms of perturbations are introduced into each group of images in the dataset D: one is strong color distortion, including color jitter and Gaussian blur; the other is strong spatial distortion, namely CutMix. In strong color distortion, color jitter is introduced by adjusting the brightness, contrast, saturation and hue of the image (for parameter values brightness = 0.4, contrast = 0.4, saturation = 0.2, hue = 0.1), introducing some randomness, while the image is blurred by applying a Gaussian filter. The combination of these two operations is to introduce randomness and diversity in the image, helping the model to better learn robustness to various changes; while using the CutMix method, it is necessary to first randomly select a rectangular area from an image, and then randomly select another image from the dataset D and replace it with a rectangular area at the same position in the image. At the same time, the labels are weighted according to the mixed area. If the selected rectangular area occupies the entire image, then CutMix is equivalent to Mixup. Its purpose is to help improve the model's ability to learn about changes and the relationship between different objects. The loss design of the dataset D is as follows,
[0111]
[0112]
[0113]
[0114]
[0115] Among them, u a and u b represents a pair of random unlabeled images to be spatially interpolated by CutMix, where M is a binary mask with a rectangular region set to 1, and The affine invariant loss in the valid region defined by M and 1-M is calculated, and the final dataset D loss L u The pixel indices are omitted and the two losses are added together by weighted averaging.
[0116] It should be noted that the parameter values of color distortion in this application (brightness = 0.4, contrast = 0.4, saturation = 0.2, hue = 0.1) can be adjusted to change the intensity and influence of color jitter; adjust the parameters of the Gaussian filter, such as modifying the convolution kernel size, standard deviation, etc., to change the degree of blur of the image; modify the combination of strong color distortion and Gaussian blur, such as different orders or weights, to introduce different image transformation effects; adjust the strategy of randomly selecting rectangular areas in CutMix, which can change the size, shape, etc. of the rectangular area, or modify the weighting method of the mixed area, such as different weight allocation strategies; adjust the architecture or hyperparameters of the student model to adapt to the introduced perturbations and pseudo-annotation sets.
[0117] See also Figure 6 , which is a flow chart of depth estimation after model deployment of the image detection method based on depth estimation described in the embodiment of the present application. Figure 6 As shown, the step of converting and encapsulating the student model according to the model weight of the student model, and using the encapsulated and deployed student model to perform depth estimation on the detected object includes:
[0118] S61, serialize the student model. Specifically, serialize the model S into an onnx file.
[0119] S62, generating the engine file of the reasoning library according to the serialized student model. Specifically, generating the engine file of the reasoning library tensorrt through trtexec.
[0120] S63, combining the engine file, using the reasoning library and the open source computer vision library to perform depth estimation on the input real-time image data of the detected object.
[0121] Specifically, tensorrt and opencv are used to load the input real-time image data and engine files and output the results for subsequent vehicle planning and control.
[0122] See also Figure 7, which is a flow chart of the overall image detection method based on depth estimation described in the embodiment of the present application. Figure 7 As shown, the overall process of depth estimation generation in this application is as follows: First, through the labeled dataset image D l And the unlabeled dataset D u Integrate the dataset. Among them, the labeled dataset image D l The teacher model T is obtained through DPT_DINOv2, and the teacher model T is used as the unlabeled dataset D u Generate pseudo-label dataset D uf , using labeled dataset images D l and pseudo-label dataset D uf Get the final dataset D. For the final dataset D, especially the pseudo-label dataset D uf Inject two strong perturbations, strong color distortion and CutMix, and then combine the semantic-assisted perception model M, using the labeled dataset image D l and pseudo-label dataset D uf Use DPT_DINOv2 for joint training to obtain the final student model S, and then perform model conversion and deployment.
[0123] See also Figure 8 and Fig. 9 , respectively showing the first output effect diagram of the image detection method based on depth estimation described in the embodiment of the present application and the second output effect diagram of the image detection method based on depth estimation described in the embodiment of the present application. Figure 8 and Fig. 9 As shown, the output effect of the depth estimation detection of the present application is shown. In the interface program of the present application, the depth estimation results and the real-time detection results are displayed in an intuitive way, for example, by superimposing the depth information and the object bounding box on the original image, or displaying the combination of the depth map and the detection results in 3D form. Thus, the present application avoids the problem of the sparsity of the depth map in some cases, which may be missing or incomplete in the measurement of the depth sensor (such as LiDAR) by combining the display method. In practical applications, the output results of the present application can be used for environmental perception and obstacle detection, planning and decision support, adaptive driving experience, unmanned vehicle positioning and navigation of autonomous driving, and effectively reduce sensor dependence. For example, the comprehensive image detection results formed by the depth map of the vehicle-mounted forward view and the real-time detection image output by the present application are used for obstacle detection and obstacle avoidance in front of the vehicle.
[0124] In existing depth estimation, there are many problems with algorithm performance: 1. Lack of labeled data: Deep learning methods usually require a large amount of labeled depth data for training, and obtaining accurate depth labels is expensive and time-consuming. This limits the generalization ability of deep learning methods in specific scenarios or new environments. 2. Uncertainty handling: When the depth estimation model faces unfamiliar scenes, backlighting, or occlusion, its depth estimation may become uncertain. This uncertainty is a challenge for safety-critical applications such as autonomous driving, because the model should be able to provide reliable depth estimates. For example, sensitivity to lighting and weather conditions: Depth estimation methods are usually sensitive to changes in lighting and weather conditions, which may lead to decreased accuracy of depth estimation under different lighting conditions. 3. Depth inconsistency: In some cases, depth estimation models may produce inconsistent depth predictions, especially in areas with weak textures or repeated textures, which may lead to inaccurate scene understanding. 4. Sparsity problem: In some cases, the measurements of depth sensors (such as lidar) may be missing or incomplete, resulting in sparsity of depth maps. Depth estimation models may encounter challenges in dealing with this sparsity. 5. Computational complexity: Some advanced deep student models, especially large neural networks for end-to-end depth estimation, can require a lot of computing resources. This can be a problem for embedded systems or real-time applications, as they are usually limited by computing power. 6. Insufficient generalization ability: Depth estimation models perform well in training data, but may have poor generalization ability in scenarios that are significantly different from the training data.
[0125] Therefore, the student model of this application effectively improves the defects of the above algorithm performance, only requires RGB images as input, no additional depth sensor is required, the hardware cost of the system is reduced, and the flexibility of deployment is improved. On the other hand, from the experimental data of this application, for the evaluation indicators AbsRel (Absolute Relative Error) and δ1 (the percentage of samples with a ratio between predicted depth and true depth within a specific range), the optimal model of Depth Anything has achieved (-0.051, +0.093), (-0.005, +0.001), (-0.155, +0.061), (-0.021, +0.023), (-0.013, +0.018), (-0.009, +0.010) progress on the six datasets of KITTI, NYUv2, Sintel, DDAD, ETH3D and DIODE respectively.
[0126] The protection scope of the image detection method based on depth estimation described in the embodiment of the present application is not limited to the execution order of the steps listed in the present embodiment. All solutions implemented by adding, reducing or replacing steps in the prior art based on the principles of the present application are included in the protection scope of the present application.
[0127] An embodiment of the present application also provides an image detection system based on depth estimation, which can implement the image detection method based on depth estimation described in the present application. However, the implementation device of the image detection method based on depth estimation described in the present application includes but is not limited to the structure of the image detection system based on depth estimation listed in the present embodiment. All structural deformations and replacements of the prior art made according to the principles of the present application are included in the protection scope of the present application.
[0128] See also Fig.10 , which is a schematic diagram of the structure of the image detection system based on depth estimation described in the embodiment of the present application. Fig.10 As shown, the image detection system 1 based on depth estimation provided in this embodiment includes: a data set acquisition module 11, a model training module 12 and a depth estimation module 13.
[0129] The data set acquisition module 11 is configured to acquire a training data set, wherein the training data set includes a labeled supervised learning data set and an unlabeled semi-supervised learning data set.
[0130] The model training module 12 is configured to train a teacher model using the supervised learning data set, generate a data set with pseudo-depth labels for the semi-supervised learning data set using the trained teacher model, and combine the supervised learning data set and the data set with pseudo-depth labels into a combined data set; optimize the data set with pseudo-depth labels in combination with a semantically-assisted perception model and random diverse perturbations, train the teacher model using the optimized combined set, and generate a student model.
[0131] The depth estimation module 13 is configured to convert and encapsulate the student model according to the model weight of the student model, and use the encapsulated and deployed student model to perform depth estimation on the detected object.
[0132] In the several embodiments provided in the present application, it should be understood that the disclosed system or method can be implemented in other ways. For example, the system embodiments described above are only schematic. For example, the division of modules / units is only a logical function division. There may be other division methods in actual implementation, such as multiple modules or units can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules or units, which can be electrical, mechanical or other forms.
[0133] The modules / units described as separate components may or may not be physically separated, and the components displayed as modules / units may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules / units may be selected according to actual needs to achieve the purpose of the embodiments of the present application. For example, the functional modules / units in the various embodiments of the present application may be integrated into one processing module, or each module / unit may exist physically separately, or two or more modules / units may be integrated into one module / unit.
[0134] Those of ordinary skill in the art should further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0135] The present application provides an electronic device, which includes: a processor and a memory; the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the electronic device performs the above-mentioned image detection method based on depth estimation.
[0136] See also Fig.11 , which is a schematic diagram showing the structural connection of the electronic device described in the embodiment of the present application. Fig.11As shown, the electronic device 2 of the present application includes: a processor 21, a memory 22, a communication interface 23 and / or a system bus 24. The memory 22 and the communication interface 23 are connected to the processor 21 through the system bus 24 and communicate with each other. The memory 22 is used to store computer programs, the communication interface 23 is used to communicate with other devices, and the processor 21 is used to run the computer program so that the electronic device 2 performs each step of the image detection method based on depth estimation.
[0137] The above-mentioned processor 21 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
[0138] The memory 22 may include a random access memory (RAM), and may also include a non-volatile memory, such as at least one disk memory.
[0139] The system bus 24 mentioned above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The system bus 24 can be divided into an address bus, a data bus, a control bus, etc. The communication interface is used to realize the communication between the database access device and other devices (such as a client, a read-write library, and a read-only library).
[0140] See also Fig.12 , which is a schematic diagram of the structure of the image detection device based on depth estimation according to the embodiment of the present application. Fig.12 As shown, this embodiment provides an image detection device based on depth estimation, which includes: the above-mentioned electronic device 2 and an image acquisition device 3; the image acquisition device 3 is communicatively connected with the electronic device 2.
[0141] The image acquisition device 3 transmits real-time image data corresponding to the detected object to the electronic device 2; the electronic device 2 uses the packaged and deployed student model to perform depth estimation on the detected object.
[0142] In one embodiment, the electronic device 2 includes a display interface; the display interface is used to display the depth estimation result and the real-time image data corresponding to the detected object.
[0143] In a practical application, the electronic device is an embedded device, Jetson AGX Orin, to optimize hardware imaging. Its powerful computing power and low power consumption are suitable for the deployment of the student model of this application. At the same time, the image acquisition device uses an external USB wide-angle camera with a low focal length to obtain a wider field of view. The TensorRT provided by NVIDIA Jetpack SDK is used to accelerate the deployment of the deep learning model, and the model is converted into the engine file of TensorRT to achieve efficient reasoning of the model. Based on NVIDIA's deep learning reasoning library (such as TensorRT, CUDA, etc.) and OpenCV library, a real-time detection program is developed to achieve real-time image processing and object detection with an external camera, an interface program is developed, and Qt (QtToolkit, application development framework) is used to create a user-friendly interface software, and the depth estimation results are integrated with the real-time detection results and displayed on the interface; the depth estimation model is combined with the real-time detection algorithm so that it can run simultaneously on the same device. In this way, more accurate depth estimation of the detected objects can be achieved, thereby improving the reliability and practicality of the detection system. In the interface program, the depth estimation results and real-time detection results are displayed in an intuitive way, for example, by superimposing the depth information and the object bounding box on the original image, or displaying the combination of the depth map and the detection results in 3D form. Therefore, the present application avoids the problem that in some cases, the measurement of the depth sensor (such as LiDAR) may be missing or incomplete, resulting in the sparsity of the depth map by combining the display method.
[0144] It should be noted that the present application can change the training data set (such as ADE20K, VOC, etc.) and use other semantic segmentation data sets for training to adapt to different scenes and objects; modify the data loading pipeline, such as other image preprocessing techniques, such as rotation, scaling, brightness adjustment, etc., or adjust the parameters of data preprocessing, such as the order of color channel exchange, normalization method, etc.; replace the backbone network, such as other pre-trained models or custom architectures, to compare different feature extraction effects; for example, other neck network structures, such as using U-Net or DeepLab, etc., to explore different feature fusion methods; modify the decoding head structure, such as different numbers or types of Transformer decoder layers, or change the design of the pixel decoder; adjust the weight or type of the loss function, such as a combination of other loss functions, to obtain better semantic segmentation effects; adjust the training strategy, such as different numbers of iterations, verification intervals, testing strategies, etc., to find better model performance, or modify the parameters of the sliding window test, such as cropping size and step size, to affect the performance of the model on the test set; replace other optimizers, such as SGD, RMSprop, etc., and adjust the initial value and decay strategy of the learning rate.
[0145] It should be noted that this application can use other serialization formats instead of ONNX, such as TensorFlowSavedModel or PyTorch JIT Script; change the parameters of the trtexec command, such as modifying the accuracy, maximum batch size, maximum workspace, etc., to adapt to different models and hardware; modify the image processing process, you can consider other image processing libraries or manually implement some preprocessing steps; modify the post-processing steps of the results, you can consider different post-processing methods or change the output format; adjust the interface of the output results to meet the needs of subsequent vehicle planning and control; replace embedded devices, such as other embedded platforms suitable for deep learning, use cameras of different focal lengths or types to adapt to different scenarios and needs; such as other deep learning model acceleration deployment tools, such as ONNX Runtime, OpenVINO, etc.; modify the algorithm of the real-time detection program, such as other object detection models or algorithms, and use different deep learning inference libraries, such as OpenVINO, to adapt to different combinations of hardware and libraries; change the interface development framework, such as other user interface libraries, such as tkinter, Electron, etc., adjust the interface design, optimize the user experience, or provide more interactive functions; adjust the integration method of depth estimation and real-time detection results, such as changing the overlay method or display form; adjust the combination method of the depth estimation model and the real-time detection algorithm, such as modifying the fusion rules or introducing more information sources; change the combination form of the depth map and the detection results, such as using 3D rendering to display.
[0146] The descriptions of the processes or structures corresponding to the above-mentioned figures have different emphases. For parts that are not described in detail in a certain process or structure, please refer to the relevant descriptions of other processes or structures.
[0147] The above embodiments are merely illustrative of the principles and effects of the present application and are not intended to limit the present application. Anyone familiar with the technology may modify or change the above embodiments without violating the spirit and scope of the present application. Therefore, all equivalent modifications or changes made by a person of ordinary skill in the art without departing from the spirit and technical ideas disclosed in the present application shall still be covered by the claims of the present application.
Claims
1. An image detection method based on depth estimation, characterized in that: The method comprises: Acquire a training data set, wherein the training data set includes a labeled supervised learning data set and an unlabeled semi-supervised learning data set; Using the supervised learning data set to train a teacher model, using the trained teacher model to generate a data set with pseudo-depth labels for the semi-supervised learning data set, and combining the supervised learning data set and the data set with pseudo-depth labels into a combined data set; optimizing the data set with pseudo-depth labels by combining a semantically-assisted perception model and random diverse perturbations, and using the optimized combined set to train the teacher model to generate a student model; The student model is converted and encapsulated according to the model weight of the student model, and the depth of the detected object is estimated by using the encapsulated and deployed student model.
2. The method according to claim 1, characterized in that: The teacher model includes a monocular depth estimation model, which includes a depth estimation head and a self-supervised encoder model.
3. The method according to claim 2, characterized in that The step of training a teacher model using the supervised learning data set includes: Load the supervised learning dataset and generate various input tensors; According to the set encoder, a corresponding version of the pre-trained self-supervised encoder model is loaded, and the input tensor is input into the self-supervised encoder model to generate intermediate layer features and classification labels corresponding to the supervised learning data set; the classification labels are used to identify each intermediate layer feature in a classified manner; Passing the intermediate layer features to a depth estimation head to generate a depth estimation result; the depth estimation result includes a depth map; processing the classification mark by linear transformation and activation function; Scaling the depth map to the original image size by interpolation; Activate and squeeze the scaled depth map to obtain the final depth map; An affine invariant loss function is used to calculate the unknown scale and displacement ignored by each sample in the supervised learning data set, and the calculation result of the affine invariant loss function is used as an evaluation indicator of the teacher model.
4. The method according to claim 3, characterized in that Passing the intermediate layer features to a depth estimation head to generate a depth estimation result; The step of processing the classification mark by linear transformation and activation function includes: Instructing the depth estimation head to project the intermediate layer features using convolution; The projected features are resized through a sequence of transposed convolutions and an identity mapping layer; Performing a linear transformation and activation on each adjusted projection layer to process the classification label; Creating a basic structure and a layer-by-layer progressive feature fusion block; the basic structure refers to a module containing a series of convolutional layers, and the feature fusion block is used to fuse features of different levels in the model; The features of the last layer are input into a preset convolution structure, and the depth estimation result is output.
5. The method according to claim 2, characterized in that: The steps of optimizing the dataset with pseudo-depth labels by combining the semantically-assisted perception model and random diverse perturbations, training the teacher model using the optimized combination set, and generating a student model include: Utilizing the semantic-assisted supervision model to optimize the allocation of semantic segmentation labels to the dataset with pseudo-depth labels in the combined set; Injecting random diverse perturbations of strong color distortion and strong spatial distortion into the dataset with pseudo-depth labels to introduce randomness and diversity of images in the combined set; The teacher model is trained using the optimized combination set to generate a student model.
6. The method according to claim 5, characterized in that The steps of injecting random diverse perturbations with strong color distortion and strong spatial distortion into the dataset with pseudo-depth labels include: In strong color distortion, the brightness, contrast, saturation and hue of the image are adjusted and a Gaussian filter is applied to blur the image, introducing randomness and diversity to the image; In strong spatial warping, a rectangular region is randomly selected from one image, and then another image is randomly selected from the combined dataset and replaced with a rectangular region at the same position in the other image; at the same time, labels are weighted according to the mixed areas to improve the student model's ability to learn changes and relationships between different objects.
7. The method according to claim 5, characterized in that The step of training the teacher model using the optimized combination set to generate a student model also includes: The loss function of the combination set is calculated, and the calculation result of the loss function is used as the evaluation index of the student model.
8. An image detection system based on depth estimation, characterized in that: The system comprises: A data set acquisition module is configured to acquire a training data set, wherein the training data set includes a labeled supervised learning data set and an unlabeled semi-supervised learning data set; A model training module is configured to train a teacher model using the supervised learning data set, generate a data set with pseudo-depth labels for the semi-supervised learning data set using the trained teacher model, and combine the supervised learning data set and the data set with pseudo-depth labels into a combined data set; optimize the data set with pseudo-depth labels by combining a semantically-assisted perception model and random diverse perturbations, train the teacher model using the optimized combined set, and generate a student model; The depth estimation module is configured to convert and encapsulate the student model according to the model weight of the student model, and use the encapsulated and deployed student model to perform depth estimation on the detected object.
9. An electronic device, characterized in that: The electronic device comprises: a processor and a memory; The memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the electronic device executes the method according to any one of claims 1 to 7.
10. An image detection device based on depth estimation, characterized in that: The device comprises: the electronic device and the image acquisition device as claimed in claim 9; the image acquisition device is communicatively connected with the electronic device; The image acquisition device transmits real-time image data corresponding to the detected object to the electronic device; The electronic device uses the packaged and deployed student model to perform depth estimation on the detected object.
11. The device according to claim 10, characterized in that: The electronic device comprises a display interface; the display interface is used to display the depth estimation result and the real-time image data corresponding to the detected object.
