The present invention belongs to the technical field of computer vision and image processing, and involves to use depth estimation sub-network, edge sub-network and camera pose estimation sub-network based on convolutional neural network to jointly obtain the high-quality depth maps. Specifically, it relates to a monocular unsupervised depth estimation method based on a contextual attention mechanism.
At this stage, as a basic research task in the field of computer vision, depth estimation has a wide range of applications in the fields of target detection, automatic driving, simultaneous localization and map construction and so on. For depth estimation, especially monocular depth estimation, without geometric constraints and other prior knowledge, predicting a depth map from a single image is an extremely ill-posed problem. So far, the monocular depth estimation methods based on deep learning are mainly divided into two categories: supervised methods and unsupervised methods. Although the supervised methods can obtain better depth estimation results, they require a large amount of ground-truth depth data as supervision information, and these ground-truth depth data are not easy to obtain. In contrast, unsupervised methods propose to transform the depth estimation problem into a viewpoint synthesis problem, thereby avoiding the use of ground-truth depth data as supervised information during the training process. According to different training data, unsupervised methods can be further subdivided into depth estimation methods based on stereo matching pairs and monocular videos. Among them, the unsupervised method based on stereo matching pairs guides the parameters' update of the entire network by establishing photometric loss between the left and right images during the training process. However, the stereo image pairs used for training are usually difficult to obtain and need to be corrected in advance, which limits the practical application of such methods. The unsupervised methods based on monocular video propose to use monocular image sequences, namely monocular video, in the training process, and predict the depth map by establishing the photometric loss between two adjacent frames (T. Zhou, M. Brown, N. Snavely, D. G. Lowe, Unsupervised learning of depth and ego-motion from video, in: IEEE CVPR, 2017, pp. 1-7). Since the camera pose between adjacent frames of the video is unknown, it is necessary to estimate the depth and camera pose at the same time during training Although the current unsupervised loss function is simple in form, its disadvantage is that it cannot guarantee the sharpness of the depth edge and the integrity of the fine structure of the depth map, especially in the occlusion and low-texture areas, which will produce low-quality depth estimation maps. In addition, the current monocular depth estimation methods based on deep learning usually cannot obtain the correlation between long-range features, and thus cannot obtain a better feature expression, resulting in problems such as loss of details in the estimated depth map.
To solve the above-mentioned problem, the present invention provides a monocular unsupervised depth estimation method based on context attention mechanism, and designs a framework for high-quality depth prediction based on convolutional neural networks. The framework includes four parts: depth estimation sub-network, edge estimator sub-network, camera pose estimation sub-network and discriminator. It proposes a context attention mechanism module to effectively acquire features, and construct a hybrid geometric enhancement loss function to train the entire framework to obtain high-quality depth information.
The specific technical solution of the present invention is a monocular unsupervised depth estimation method based on context attention mechanism, which contains the following steps:
(1) preparing initial data, the initial data includes the monocular video sequence used for training and the single image or sequence used for testing;
(2) the construction of depth estimation sub-network and edge estimation sub-network and the construction of context attention mechanism:
(2-1) using the encoder-decoder structure, the residual network containing the residual structure is used as the main structure of the encoder to convert the input color map into the feature map; the depth estimation sub-network and the edge estimation sub-network share the encoder, but have their own decoders, which are easy to output their respective features; the decoders contain deconvolution layers for up-sampling the feature map and converting the feature map into a depth map or edge map;
(2-2) constructing the context attention mechanism into the decoder of the depth estimation sub-network;
(3) the construction of the camera pose sub-network:
the camera pose sub-network contains an average pooling layer and more than five convolutional layers, and except for the last convolutional layer, all other convolutional layers adopt batch normalization and ReLU activation function;
(4) the construction of the discriminator structure: the discriminator structure contains more than five convolutional layers, each of which uses batch normalization and Leaky-ReLU activation functions, and the final fully connected layer;
(5) the construction of a loss function based on hybrid geometry enhancement;
(6) training the whole network composed by (2), (3) and (4); the supervision method adopts the loss function based on the hybrid geometric enhancement constructed in step 5) to gradually optimize the network parameters; after training, using the trained model to test on the test set to get the output result of the corresponding input image.
Furthermore, the construction of the context attention mechanism in step 2-2) above specifically includes the following steps:
the context attention mechanism is added to the front end of the decoder of the depth estimation network; the feature map obtained by the previous encoder network is A∈H×W×C, where H, W, C respectively represent the height, width, and number of channels; at first, transform A into B∈N×C(N=H×W), and then multiply B and its transposed matrix BT; the result can get the spatial attention map S∈N×N or channel attention map S∈C×C after the softmax activation function operation, that is, S=softmax(BBT) or S=softmax(BTB); next, perform matrix multiplication on S and B and transform them into U∈H×W×C and finally add the original feature map A and U pixel by pixel to get the final feature output Aa.
The present invention has the following beneficial effects:
The present invention is designed based on CNN. It builds a depth estimation sub-network and an edge sub-network based on a 50-layer residual network to obtain a preliminary depth map and an edge information map. At the same time, the camera pose estimation sub-network is used to obtain the camera pose information. This information and the preliminary depth map are used to obtain synthetic adjacent frame color maps through the warping function, and then the synthetic image is optimized by the hybrid geometric enhancement loss function; finally, the optimized synthetic image is distinguished from the real color map by the discriminator, the discriminator optimizes the difference through the adversarial loss function. When the difference is small enough, a high-quality estimated depth map can be obtained. The present invention has the following characteristics:
1. it is easy to construct the system. This system can obtain the high-quality depth map from the monocular video directly by the well-trained end to end convolutional neural network. The program framework is easy to implement and the algorithm runs fast.
2. the present invention uses an unsupervised method to analyze the depth information, avoiding the problem that ground-truth data is difficult to obtain in the supervised method.
3. the present invention uses monocular picture sequences to solve the depth information, avoiding the problem of difficulty in obtaining stereo picture pairs when solving the depth information.
4. the context attention mechanism and hybrid geometric loss function designed in the present invention can effectively improve performance.
5. the invention has good scalability, and can realize more accurate depth estimation by combining different monocular cameras to realize algorithms.
The present invention proposes a monocular unsupervised depth estimation method based on a context attention mechanism, which is described in detail with reference to the drawings and embodiments as follows:
The method includes the following steps:
(1) preparing initial data:
(1-1) use two public datasets, KITTI dataset and Make3D dataset to evaluate the invention;
(1-2) the KITTI dataset is used for training and testing of the present invention. It has a total of 40,000 training samples, 4,000 verification samples, and 697 test samples. During training, the original image resolution size of 375×1242 is scaled to 128×416. The length of the input image sequence during training is set to 3, and the middle frame is the target view while the other frames are the source views.
(1-3) the Make3D dataset is mainly used to test the generalization performance of the present invention on different datasets. The Make3D dataset has a total of 400 training samples and 134 test samples. Here, the present invention only selects the test set of the Make3D dataset, and the training model comes from the KITTI dataset. The resolution of the original image in the Make3D dataset is 2272×1704. By cropping the central area, the image resolution is changed to 525×1704 so that the sample set has the same aspect ratio as the KITTI sample, and then its size is scaled to 128×416 as input for network testing.
(1-4) the input during the test can be either a sequence of images with the length of 3 or a single image.
(2) the construction of depth estimation sub-network and edge sub-network and the construction of context attention mechanism:
(2-1) as shown in
The context attention mechanism is added to the front end of the decoder of the depth estimation network; the context attention mechanism is shown in
(3) construction of camera pose network:
the camera pose network is mainly used to estimate the pose transformation between two adjacent frames, where the pose transformation refers to the displacement and rotation of the corresponding position between the two adjacent frames. The camera pose network consists of an average pooling layer and eight convolutional layers. Except for the last convolutional layer, all other convolutional layers use batch normalization (BN) and ReLU (Rectified Linear Unit) activation functions.
(4) construction of the discriminator structure:
the discriminator is mainly used to judge the authenticity of the color map, that is, to determine whether it is a real color map or a synthesized color map. Its purpose is to enhance the ability of the network to synthesize color maps to thereby indirectly improving the quality of depth estimation. The discriminator structure contains five convolutional layers, each of which uses batch normalization and Leaky-ReLU activation functions, and the final fully connected layer.
(5) in order to solve the problem that the ordinary unsupervised loss function is difficult to produce high-quality results in the edge, occlusion and low-texture areas, this invention constructs the loss function based on hybrid geometric enhancement to train the network.
(5-1) designing the photometric loss function Lp; use the depth map information and the camera pose to obtain the source frame image coordinates from the target frame image coordinates, and establish the projection relationship between adjacent frames; the formula is:
p
s
=KT
t→s
D
t(pt)K−1pt
where K is the camera calibration parameter matrix, K−1 is the inverse matrix of the parameter matrix, Dt is the predicted depth map, s and t represent the source frame and the target frame, respectively; Tt→s is the camera pose information from t to s, ps is the image coordinate of the source frame, and pt is the image coordinate of the target frame; the source frame image Is is warped to the target frame angle of view to obtain the synthesized image Îs→t, which is expressed as follows:
among them, wj is the linear interpolation coefficient, and the value is ¼; psj is the adjacent pixel in ps, j∈{t,b,l,r} represents 4-neighborhood, and t, b, l, r represent the top, bottom, left and right ends of the coordinate position;
Lp is defined as follows:
among them, N represents the number of images per training, the effective mask Mt*=1−M, M is defined as: M=I(ξ≥0), where I is the indicator function, and the definition of ξ is ξ=∥Dt−Ďt∥2−(n1∥Dt∥2+η1∥Ďt∥2+η2), where η1 and η2 are weight coefficients set to 0.01 and 0.5 respectively; Ďt is a depth map generated by warping the depth map Dt of the target frame;
(5-2) designing space smooth loss function LS, used to process the depth value of low-texture areas, the formula is as follows:
among them, the parameter γ is set to 10, Et is the output result of the edge sub-network, and ∇x2 and ∇y2 are the two-step gradient in the x and y directions of the coordinate system, respectively; to avoid getting trivial solutions, design the edge regularization loss function Le, the formula is as follows:
(5-3) designing the left and right consistency loss function Ld to eliminate the error caused by occlusion between the viewpoints; the formula is as follows:
(5-4) the discriminator uses the adversarial loss function when distinguishing real images and synthetic images; regarding the combination of deep network, edge network, and camera pose network as the generator, and the final synthesized image is sent to the judgment together with the real input image to get better results in the device; the adversarial loss function formula is as follows:
among them, P(*) represents the probability distribution of the data *, E represents the expectation, and D represents the discriminator; this adversarial loss function prompts the generator to learn the mapping of synthetic data to real data, so that the synthetic image is similar to the real image;
(5-5) the loss function of the overall network structure is defined as follows:
L=α
1
L
p+α2Ls+α3Le+α4Ld+α5LAdv
among them, α1, α2, α3, α4 and α5 are the weight coefficients.
(6) the convolutional neural networks obtained from (2), (3) and (4) into the network structure are combined as shown in
The final result of this implementation is shown in
Number | Date | Country | Kind |
---|---|---|---|
202010541514.3 | Jun 2020 | CN | national |