A voxel-based 3D reconstruction method based on visual transformer
Through the three-dimensional reconstruction method based on visual transformer, image features are extracted using the encoding layer and self-attention mechanism, the scene applicability and self-occlusion problems of three-dimensional reconstruction in the prior art are solved, and efficient in single-view or multi-view situations are achieved Three-dimensional voxel reconstruction.
Patent Information
- Application Number
- CN202110876128.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-30
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2041-07-30
AI Technical Summary
The existing three-dimensional reconstruction voxel method requires specific techniques to speculate on image three-dimensional structures, and it is difficult to successfully reconstruct if the camera is not calibrated or the surface of the object is self-occluded.
Using a visual transformer-based method, using single-view or multi-view image input, the encoding layer extracts features, combined with three-dimensional transposed convolution and self-attention mechanism, a three-dimensional visual transformer structure is designed to improve the accuracy of voxel information and generate the final The voxel model is reconstructed by the three-dimensional reconstruction of the voxel model and the voxel probability is predicted by the loss function.
There is no need for specific technology to speculate on the three-dimensional structure, it is suitable for all scenarios, can be successfully reconstructed in the absence of information or self-occlusion, and the multi-view model can process any image input in parallel, and the reconstruction result is irrelevant to the input order.
Smart Images

Figure CN113658322B
Abstract
Description
Technical Field
[0001] The invention discloses a three-dimensional reconstruction voxel method based on a visual transformer, and relates to the field of three-dimensional reconstruction voxels. Background Art
[0002] The objects that people encounter in the objective world are three-dimensional. We can observe objects from a three-dimensional perspective, so that we can better analyze their structure and properties. For example, whether the interior space of a car is wide enough for people to sit comfortably; whether a schoolbag has interlayers, and whether students can use multiple interlayers to organize different books. However, for computer vision, such an analysis process is very difficult, because the general representation of objects in computers is a two-dimensional image, which will lose a lot of information compared to three-dimensional objects, so in some applications, certain technical means are needed to restore the three-dimensional structure of the object.
[0003] At present, many methods use the feature points of image sequences and the connections between image sequences to achieve 3D reconstruction. However, due to the lack of some key information, the reconstruction process will bring some difficulties: how to restore the invisible parts is a problem that must be considered in the 3D reconstruction process. The solution to this problem requires the use of specific technologies to infer the 3D structure of the image; some methods require the camera to be calibrated in advance, so they are not applicable in specific scenarios; when part of the surface of the object is self-occluded, the feature points of the image may not be extracted, resulting in the failure of reconstruction. Therefore, how to reconstruct 3D voxels in the absence of information has become one of the problems that need to be solved urgently. Summary of the invention
[0004] The problem that the present invention solves is that existing methods of three-dimensional reconstruction of voxels require the use of specific technologies to infer the three-dimensional structure of the image, and some methods require the camera to be calibrated in advance, so they are not applicable in certain scenarios; when part of the surface of an object is self-occluded, the feature points of the image may not be extracted, resulting in the failure of reconstruction.
[0005] A three-dimensional reconstruction voxel method based on a visual transformer, wherein the object reconstructed by the method is a single view, and the method comprises:
[0006] The single view to be reconstructed is used as the initial value of the input single view image in the neural network;
[0007] Input the initial value of the single-view image into the encoding layer based on the visual transformer module to extract features on different dimensions of the image;
[0008] The extracted image features are decoded through three-dimensional transposed convolution to obtain rough voxel information;
[0009] Design a 3D visual transformer structure to reconstruct voxels, improve the accuracy of rough voxel information, and obtain a single-view Figure 3 The final voxel model after dimensional reconstruction.
[0010] The initial value of the single-view image is input into the coding layer based on the visual transformer module, and the features of the image on different dimensions are extracted, and the following method is used to obtain:
[0011] Convert the image into image blocks;
[0012] The input of the encoding layer is
[0013] x∈R H×W×C
[0014] Among them, H represents the long dimension of the input information; W represents the wide dimension of the input information; C represents the feature dimension to be extracted; R represents the matrix information;
[0015] The image blocks are extracted in a sliding window order, where
[0016] l×l
[0017] Each image block x p The size is
[0018] l×l×C
[0019] The sliding window sliding step size is s, then the total number of image blocks E is
[0020] (Hl / s)×(Wl / s)
[0021] Flatten each image block into
[0022] x' p ∈R D×1
[0023] The scale of the image block x' is obtained as:
[0024] x′∈R E×D ;
[0025] Introduce self-attention mechanism to each image block:
[0026] The fully connected layer obtains the key x in the image block self-attention mechanism k , query x q , value x v :
[0027] x k = x'W k ,W k ∈R D×D' ,xk ∈R E×D'
[0028] x q = x'W q ,W q ∈R D×D' ,x q ∈R E×D'
[0029] x v = x'W v ,W v ∈R D×D' ,x v ∈R E×D'
[0030] Where D' represents the new feature dimension; W k Represents the weight matrix of the bond; W q Represents the weight matrix of the query; W v Represents the weight matrix;
[0031] The weight matrix x is obtained by calculating the similarity between the query and the key through matrix dot product w :
[0032]
[0033] Use the Softmax function to normalize the weight matrix:
[0034]
[0035] in, Represents the element corresponding to the i-th j-th column;
[0036] The encoding layer based on the visual transformer module learns the features x in the image by multiplying the weight matrix and the value. att :
[0037] x att =x w ·x v
[0038] The multi-layer perception mechanism of the neural network is used, which consists of multiple fully connected layers and dropout layers.
[0039] The three-dimensional visual transformer structure is designed to reconstruct voxels, improve the accuracy of rough voxel information, and obtain a single-view Figure 3 The process of the final voxel model after dimensional reconstruction is:
[0040] Encoding layer input x∈R C×H×W×L , where L represents the high dimension of the input information;
[0041] Use a 3D sliding window to extract voxel modules and stack them in the feature dimension:
[0042] The sliding window is l×l×l, so the size of each extracted voxel block is
[0043] x p ∈R D×1
[0044] D=l×l×l×c
[0045] Arrange each image block in order to form a matrix to obtain the feature information matrix of the three-dimensional voxel block:
[0046] x′∈R N×D
[0047] in
[0048] N=(Hl / s)×(Wl / s)×(Ll / s)
[0049] N represents the number of three-dimensional voxel blocks;
[0050] Get the feature matrix of the three-dimensional transformer;
[0051] Calculate the key, query, and value in the 3D voxel block, and finally obtain the feature output;
[0052] The output voxel model is of size 32×32×32.
[0053] A three-dimensional reconstruction voxel method based on a visual transformer, wherein the object reconstructed by the method is a multi-view, and the method comprises:
[0054] Input image information; use the network coding layer to learn features in the image; use three-dimensional transposed convolution to decode features and generate rough voxel information; use image information to learn the corresponding voxel weights, and use the network output layer to fuse voxels based on the three-dimensional convolution of the generated weight layer to obtain the probability value of the fused voxels and generate a voxel model.
[0055] The method of using image information to learn the corresponding voxel weights and fusing voxels using the network output layer according to the three-dimensional convolution of the generated weight layer is as follows:
[0056] The set of three-dimensional features learned from different images is
[0057] S={x 1 ,x 2 ,L,x n}
[0058] Where: x n ∈RC×H×W×L , represents the features learned from the nth image; H represents the long dimension of the input information, W represents the wide dimension of the input information, L represents the high dimension of the input information, and C represents the feature dimension;
[0059] Using 3D convolutional layers to learn the attention score C = {c 1 ,c 2 ,L,c n}
[0060] in:
[0061] c n =g(x n ),c n ∈R H×W×L
[0062] g represents multiple three-dimensional convolution operations;
[0063] The obtained attention score is regularized into attention weight through Softmax function
[0064] S={s 1 ,s 2 ,L,s n}
[0065] in: Represents the value of the i-th weight at the position (h,w,l);
[0066] Each image is viewed through a single Figure 3 The voxel probability generated by dimensional reconstruction is
[0067] V={v 1 ,v 2 ,L,v n}
[0068] where v n ∈R H×W×L ;
[0069] Multiply the weights with the corresponding voxels and add them together for complete fusion. The fully fused voxel y is:
[0070]
[0071] The * represents the element-wise multiplication operation.
[0072] The probability value of the fused voxel is obtained and a voxel model is generated. The probability value of the voxel is:
[0073]
[0074] Among them, (h,w,l) represents the voxel position.
[0075] The three-dimensional reconstruction voxel method based on visual transformer also includes designing a loss function, and the loss function is a binary cross loss function:
[0076]
[0077] Among them, y (i,j,k) Represents the true value of the voxel block at (i, j, k), which is 1 or 0, p (i,j,k) Represents the predicted voxel probability value; the smaller the loss function, the closer the predicted value is to the true value.
[0078] The present invention is beneficial in that:
[0079] The three-dimensional reconstruction voxel method of the present invention does not need to use a specific technology to infer the three-dimensional structure of an image; it does not need to calibrate the camera in advance, and is applicable to all scenes.
[0080] When a part of the surface of an object is self-occluded, the existing voxel reconstruction method will fail to reconstruct because the feature points of the image technology cannot be extracted. The present invention can calculate the occluded image features for this situation and successfully complete the reconstruction.
[0081] The present invention can infer the unknown structure of an object in the case of missing information, that is, a single view, and the voxels generated by the model can restore the overall structure of the object. Figure 3 The 3D reconstruction voxel model uses an attention module based on 3D convolution to fuse the probability values of reconstructed voxels from different images. The model can process any number of image inputs in parallel, and the reconstruction results are independent of the order of the image inputs.
[0082] The present invention can be applied to three-dimensional reconstruction voxel models of all scenes. BRIEF DESCRIPTION OF THE DRAWINGS
[0083] Figure 1 Single Vision Figure 3 Reconstruct the overall structure of the voxel model
[0084] Figures 2 to 4 These are images of various stages in the process of implementing three-dimensional voxel reconstruction from a single view as described in Implementation Method 1, which are, from left to right, input image, target voxel, and model reconstruction voxel.
[0085] Figures 5 to 7 These are the images at each stage in the process of implementing 3D voxel reconstruction from multiple views as described in the second implementation mode. In the figure, the first three images are model input images, followed by target voxels and model reconstructed voxels. DETAILED DESCRIPTION
[0086] Several embodiments of the present invention will be described with reference to the accompanying drawings.
[0087] Implementation method 1, see Figures 1 to 4 This embodiment describes a 3D reconstruction voxel method based on a visual transformer, wherein the object reconstructed by the method is a single view, and the method comprises:
[0088] The single view to be reconstructed is used as the initial value of the input single view image in the neural network;
[0089] Input the initial value of the single-view image into the encoding layer based on the visual transformer module to extract features on different dimensions of the image;
[0090] The extracted image features are decoded through three-dimensional transposed convolution to obtain rough voxel information;
[0091] Design a 3D visual transformer structure to reconstruct voxels, improve the accuracy of rough voxel information, and obtain a single-view Figure 3 The final voxel model after dimensional reconstruction.
[0092] The initial value of the single-view image is input into the coding layer based on the visual transformer module, and the features of the image on different dimensions are extracted, and the following method is used to obtain:
[0093] Convert the image into image blocks;
[0094] The input of the encoding layer is
[0095] x∈R H×W×C
[0096] Among them, H represents the long dimension of the input information; W represents the wide dimension of the input information; C represents the feature dimension to be extracted; R represents the matrix information;
[0097] The image blocks are extracted in a sliding window order, where
[0098] l×l
[0099] Each image block x p The size is
[0100] l×l×C
[0101] The sliding window sliding step size is s, then the total number of image blocks E is
[0102] (Hl / s)×(Wl / s)
[0103] Flatten each image block into
[0104] x' p ∈R D×1
[0105] The scale of the image block x' is obtained as:
[0106] x′∈R E×D
[0107] Introduce self-attention mechanism to each image block:
[0108] The fully connected layer obtains the key x in the image block self-attention mechanism k , query x q , value x v :
[0109] x k = x'W k ,W k ∈R D×D' ,x k ∈R E×D'
[0110] x q = x'W q ,W q ∈R D×D' ,x q ∈R E×D'
[0111] x v = x'W v ,W v ∈R D×D' ,x v ∈R E×D'
[0112] Where D' represents the new feature dimension; W k Represents the weight matrix of the bond; W q Represents the weight matrix of the query; W v Represents the weight matrix;
[0113] The weight matrix x is obtained by calculating the similarity between the query and the key through matrix dot product w :
[0114]
[0115] Use the Softmax function to normalize the weight matrix:
[0116]
[0117] in, Represents the element corresponding to the i-th j-th column;
[0118] The encoding layer based on the visual transformer module learns the features x in the image by multiplying the weight matrix and the value. att:
[0119] x att =x w ·x v
[0120] Using the multi-layer perception mechanism of the neural network, which is composed of multiple layers of fully connected layers and dropout layers, the visual transformer structure not only takes into account the connection between each pixel in the image and its surrounding pixels, but also learns the key features of the image block by introducing a self-attention mechanism for each image block.
[0121] The three-dimensional visual transformer structure is designed to reconstruct voxels, improve the accuracy of rough voxel information, and obtain a single-view Figure 3 The process of the final voxel model after dimensional reconstruction is:
[0122] Encoding layer input x∈R C×H×W×L , where L represents the high dimension of the input information;
[0123] Use a 3D sliding window to extract voxel modules and stack them in the feature dimension:
[0124] The sliding window is l×l×l, so the size of each extracted voxel block is
[0125] x p ∈R D×1
[0126] D=l×l×l×c
[0127] Arrange each image block in order to form a matrix to obtain the feature information matrix of the three-dimensional voxel block:
[0128] x′∈R N×D
[0129] in
[0130] N=(Hl / s)×(Wl / s)×(Ll / s)
[0131] N represents the number of three-dimensional voxel blocks;
[0132] Get the feature matrix of the three-dimensional transformer;
[0133] Calculate the key, query, and value in the 3D voxel block, and finally obtain the feature output;
[0134] The output is a voxel probability value of size 32×32×32, and a voxel model is generated at the same time.
[0135] The three-dimensional reconstruction voxel method also includes using the overlap IoU as an evaluation indicator:
[0136]
[0137] Among them, p (i,j,k) represents the predicted value of the voxel at (i,j,k), gt (i,j,k) represents the true value of the voxel at (i, j, k), t represents the voxel threshold, and I(·) represents the indicator function;
[0138] A higher IoU value represents a better reconstruction result.
[0139] Specifically, as shown in Table 1, Table 1 is a single-view Figure 3 The overlap IoU results of the 3D-reconstructed voxel model and other models in the test set are compared. The 43,736 3D models of 13 types provided in 3D-R2N2 are used as the data set. 32,700 of them are divided into training sets and the rest are divided into test sets. At the same time, 3D-R2N2 also gives 24 random perspective renderings of each model. These renderings are used as input to the network to show the experimental results of the 3D reconstructed voxel model in a single view. Among them, the voxel threshold t is taken as 0.4, and a higher IoU value represents a better reconstruction result. It can be seen that there is a large gap in the overlap IoU of different categories. The reconstruction effect of the car and cabinet types is better because the object structures in their types are relatively similar, which is convenient for the network to infer their structures. The reconstruction effects of the two types of lights and displays are average. On the one hand, there are more invisible parts of the objects, and on the other hand, there are more differences in the object structures, which is not conducive to the model to infer their structures.
[0140] Table 1 also shows the experimental results of the comparison between the 3D reconstruction voxel model based on the visual transformer and other models in a single view. In the process of using the method of the present invention to reconstruct the 3D voxel model of the single view of the airplane, the car and the rifle, the images obtained at each stage are respectively shown in Table 1. Figure 2 , Figure 3 and Figure 4 As shown in the figure. OGN uses an octree model to represent the target voxel, which can represent higher resolution 3D output in a limited memory space. However, its representation is more complex, and as the resolution increases, network training becomes difficult. As can be seen from the chart, this model has a good reconstruction effect in the types of instances such as airplanes and cars.
[0141] Table 1. Comparison of overlap IoU between the 3D reconstruction voxel model based on visual transformer and other models in single view
[0142]
[0143] Implementation Method 2: See Figures 5 to 7This embodiment describes a 3D reconstruction voxel method based on a visual transformer, wherein the object reconstructed by the method is a multi-view, and the method comprises:
[0144] Input image information; use the network coding layer to learn features in the image; use three-dimensional transposed convolution to decode features and generate rough voxel information; use image information to learn the corresponding voxel weights, and use the network output layer to fuse voxels based on the three-dimensional convolution of the generated weight layer to obtain the probability value of the fused voxels and generate a voxel model.
[0145] The method of using image information to learn the corresponding voxel weights and fusing voxels using the network output layer according to the three-dimensional convolution of the generated weight layer is as follows:
[0146] The set of three-dimensional features learned from different images is
[0147] S={x 1 ,x 2 ,L,x n}
[0148] Where: x n ∈R C×H×W×L , represents the features learned from the nth image; H represents the long dimension of the input information, W represents the wide dimension of the input information, L represents the high dimension of the input information, and C represents the feature dimension;
[0149] Using 3D convolutional layers to learn the attention score C = {c 1 ,c 2 ,L,c n}
[0150] in:
[0151] c n =g(x n ),c n ∈R H×W×L
[0152] g represents multiple three-dimensional convolution operations;
[0153] The obtained attention score is regularized into attention weight through Softmax function
[0154] S={s 1 ,s 2 ,L,s n}
[0155] in: Represents the value of the i-th weight at the position (h,w,l);
[0156] Each image is viewed through a single Figure 3The voxel probability generated by dimensional reconstruction is
[0157] V={v 1 ,v 2 ,L,v n}
[0158] where v n ∈R H×W×L ;
[0159] Multiply the weights with the corresponding voxels and add them together for complete fusion. The fully fused voxel y is:
[0160]
[0161] The * represents the element-wise multiplication operation.
[0162] Weights are generated using features, and the idea of the attention mechanism is used to give larger weights to areas where image reconstruction effects are good, so that the voxel probability values generated by each image can be better integrated.
[0163] The probability value of the fused voxel is obtained and a voxel model is generated. The probability value of the voxel is:
[0164]
[0165] Among them, (h,w,l) represents the voxel position.
[0166] The parameters of the convolution layer used to extract image features and the three-dimensional convolution layer used to generate attention weights are shared. When the number of image inputs is different, the method can adaptively use these shared parameters for voxel fusion. Specifically, as shown in Table 2, Table 2 compares the overlap IoU of the three-dimensional reconstruction of the model under different numbers of input images. The images obtained at each stage of the three-dimensional reconstruction process of the multiple views of the lamp, mobile phone and airplane using the method of the present invention are respectively shown in Table 2. Figures 5 to 7 As shown in the figure, we can see that as the number of viewpoints increases, the model's performance on the test set continues to improve. This shows that the model uses the features of multiple images to reconstruct voxels. Compared with the single-view results, the reconstruction results of multiple views are significantly improved. For example, for a chair, adding an image can increase the overlap IoU by 0.3, which is a significant effect.
[0167] Table 2 The overlap IoU of reconstructed voxels in multi-view scenarios using the voxel model based on the visual transformer
[0168]
[0169] Table 3 shows the comparison of the multi-view reconstruction results of this model with other methods. The results show that this model can reconstruct the voxel model of the object better when the number of input images is different. In addition, compared with the 3D-R2N2 model, this model has improved the reconstruction speed and reconstructed better results with fewer parameters. In addition, the multi-view model can adaptively use any number of images to complete the reconstruction task, which is more flexible than the 3D-R2N2 model.
[0170] Table 3 Comparison of IoU results between the voxel model based on visual transformer and other models under multi-view reconstruction
[0171]
[0172]
Claims
1. A three-dimensional reconstruction voxel method based on visual transformer, characterized in that: The object reconstructed by the method is a single view, and the method comprises: The single view to be reconstructed is used as the initial value of the single view image input into the neural network; Input the initial value of the single-view image into the encoding layer based on the visual transformer module to extract features on different dimensions of the image; The extracted image features are decoded through three-dimensional transposed convolution to obtain rough voxel information; Design a 3D visual transformer structure to reconstruct voxels, improve the accuracy of rough voxel information, and obtain the final voxel model after single-view 3D reconstruction; The initial value of the single-view image is input into the coding layer based on the visual transformer module, and the features of the image on different dimensions are extracted, and the following method is used to obtain: Convert the image into image blocks; The input of the encoding layer is Where H represents the long dimension of the input information; W represents the wide dimension of the input information; C represents the feature dimension to be extracted; R represents the matrix information; The image blocks are extracted in a sliding window order, where Each image block The size is The step size of the sliding window is , then the total number of image blocks for Flatten each image block into Get image blocks The scale is: Introduce self-attention mechanism to each image block: The fully connected layer obtains the key x in the image block self-attention mechanism k , query x q , value x v : in Represents a new feature dimension; The weight matrix representing the bonds; The weight matrix representing the query; Represents the weight matrix of the value; The weight matrix is obtained by calculating the similarity between the query and the key through matrix dot product : Use the Softmax function to normalize the weight matrix: in, Representative No. The elements corresponding to the columns; The encoding layer based on the visual transformer module learns the features in the image by multiplying the weight matrix and the value. : The multi-layer perception mechanism of the neural network is used, which consists of multiple fully connected layers and dropout layers.
2. The three-dimensional reconstruction voxel method based on visual transformer according to claim 1, characterized in that: The process of designing a 3D visual transformer structure to reconstruct voxels and improving the accuracy of rough voxel information to obtain the final voxel model after single-view 3D reconstruction is as follows: Encoding layer input , in Represents the high dimensionality of the input information; Use a 3D sliding window to extract voxel modules and stack them in the feature dimension: The sliding window is , then the size of each extracted voxel block is Arrange each image block in order to form a matrix to obtain the feature information matrix of the three-dimensional voxel block: in Represents the number of 3D voxel blocks; Get the feature matrix of the three-dimensional transformer; Calculate the key, query, and value in the 3D voxel block, and finally obtain the feature output; The output size is The voxel probability value of is obtained and the voxel model is generated at the same time.
3. A three-dimensional reconstruction voxel method based on visual transformer according to any one of claims 1 to 2, characterized in that: The three-dimensional reconstruction voxel method based on visual transformer also includes designing a loss function, and the loss function is a binary cross loss function: in, Represents a voxel block in The true value at is 1 or 0. Represents the predicted voxel probability value; the smaller the loss function, the closer the predicted value is to the true value.
4. A three-dimensional reconstruction voxel method based on visual transformer according to any one of claims 1 to 2, characterized in that: The three-dimensional reconstruction voxel method also includes using the overlap IoU as an evaluation indicator: in, Representatives in The predicted value of the voxel at Representatives in The true value of the voxel at represents the voxel threshold, represents the indicator function; A higher IoU value represents a better reconstruction result.
5. A three-dimensional reconstruction voxel method based on visual transformer, characterized in that: The object reconstructed by the method is multiple views. The method inputs image information; uses a network coding layer to learn features in the image; uses a three-dimensional transposed convolution to decode the features and generate rough voxel information; uses image information to learn the corresponding voxel weights, and uses a network output layer to fuse voxels based on the three-dimensional convolution of the generated weight layer; Obtain the probability value of the fused voxel and generate a voxel model; The method of using image information to learn the corresponding voxel weights and using the network output layer to fuse the voxels according to the three-dimensional convolution of the generated weight layer is obtained by the following method: The set of three-dimensional features learned from different images is in Representative Features learned from an image; Represents the long dimension of the input information, represents the wide dimension of the input information, Represents the high dimension of the input information, Represents the feature dimension; Learning Attention Scores Using 3D Convolutional Layers in: , Represents multiple three-dimensional convolution operations; The obtained attention score is regularized into attention weight through Softmax function in: Representative The weight in The value at the position; The voxel probability of each image generated by single-view 3D reconstruction is in ; The weights are multiplied by the corresponding voxels and added together for complete fusion. : in Represents element-wise multiplication operation.
6. The three-dimensional reconstruction voxel method based on visual transformer according to claim 5, characterized in that: The probability value of the fused voxel is obtained and a voxel model is generated. The probability value of the voxel is: in, Represents the voxel position.
7. A computer device, characterized in that: It comprises a memory and a processor, wherein the memory stores a computer program, and when the processor runs the computer program stored in the memory, the processor executes a three-dimensional reconstruction voxel method based on a visual transformer according to any one of claims 1-2.
