BSP-Net: Generating Compact Meshes via Binary Space Partitioning
Zhiqin Chen, Andrea Tagliasacchi, Hao Zhang
Introduction
Recently, there has been an increasing interest in representation learning and generative modeling for 3D shapes. Up to now, deep neural networks for shape analysis and synthesis have been developed mainly for voxel grids , point clouds , and implicit functions . As the dominant 3D shape representation for modeling, display, and animation, polygonal meshes have not figured prominently amid these developments. One of the main reasons is that the non-uniformity and irregularity of triangle tessellations do not naturally support conventional convolution and pooling operations . However, compared to voxels and point clouds, meshes can provide a more seamless and coherent surface representation; they are more controllable, easier to manipulate, and are more compact, attaining higher visual quality using fewer primitives; see Figure 1.
For visualization purposes, the generated voxels, point clouds, and implicits are typically converted into meshes in post-processing, e.g., via iso-surface extraction by Marching Cubes . Few deep networks can generate polygonal meshes directly, and such methods are limited to genus-zero meshes , piece-wise genus-zero meshes, meshes sharing the same connectivity , or meshes with very low number of vertices . Patch-based approaches can generate results which cover a 3D shape with planar polygons or curved mesh patches, but their visual quality is often tampered by visible seams, incoherent patch connections, and rough surface appearance. It is difficult to texture or manipulate such mesh outputs.
In this paper, we develop a generative neural network which outputs polygonal meshes natively. Specifically, parameters or weights that are learned by the network can predict multiple planes which fit the surfaces of a 3D shape, resulting in a compact and watertight polygonal mesh; see Figure 1. We name our network BSP-Net, since each facet is associated with a binary space partitioning (BSP), and the shape is composed by combining these partitions.
BSP-Net learns an implicit field: given point coordinates and a shape feature vector as input, the network outputs values indicating whether the points are inside or outside the shape. The construction of this implicit function is illustrated in Figure 2, and consists of three steps: \raisebox{-.75pt}{1}⃝ a collection of plane equations implies a collection of binary partitions of space; see Figure 2-top; \raisebox{-.75pt}{2}⃝ an operator groups these partitions to create a collection of convex shape primitives/parts; \raisebox{-.75pt}{3}⃝ finally, the part collection is merged to produce the implicit field of the output shape.
Figure 3 shows the network architecture of BSP-Net corresponding to these three steps: \raisebox{-.75pt}{1}⃝ given the feature code, an MLP produces in layer a matrix of canonical parameters that define the implicit equations of planes: ; these implicit functions are evaluated on a collection of point coordinates in layer ; \raisebox{-.75pt}{2}⃝ the operator is a binary matrix that enforces a selective neuron feed from to the next network layer , forming convex parts; \raisebox{-.75pt}{3}⃝ finally, layer assembles the parts into a shape via either sum or -pooling.
At inference time, we feed the input to the network to obtain components of the BSP-tree, i.e., leaf nodes (planes ) and connections (binary weights ). We then apply classic Constructive Solid Geometry (CSG) to extract the explicit polygonal surfaces of the shapes. The mesh is typically compact, formed by a subset of the planes directly from the network, leading to a significant speed-up over the previous networks during inference, and without the need for expensive iso-surfacing – current inference time is about 0.5 seconds per generated mesh. Furthermore, meshes generated by the network are guaranteed to be watertight, possibly with sharp features, in contrast to smooth shapes produced by previous implicit decoders .
BSP-Net is trainable and characterized by interpretable network parameters defining the hyper-planes and their formation into the reconstructed surface. Importantly, the network training is self-supervised as no ground truth convex shape decompositions are needed. BSP-Net is trained to reconstruct all shapes from the training set using the same set of convexes constructed in layer of the network. As a result, our network provides a natural correspondence between all the shapes at the level of the convexes. BSP-Net does not yet learn semantic parts. Grouping of the convexes into semantic parts can be obtained manually, or learned otherwise as semantic shape segmentation is a well-studied problem. Such a grouping only need to be done on each convex once to propagate the semantic understanding to all shapes containing the same semantic parts.
BSP-Net is the first deep generative network which directly outputs compact and watertight polygonal meshes with arbitrary topology and structure variety.
The learned BSP-tree allows us to infer both shape segmentation and part correspondence.
By adjusting the encoder of our network, BSP-Net can also be adapted for shape auto-encoding and single-view 3D reconstruction (SVR).
To the best of our knowledge, BSP-Net is among the first to achieve structured SVR, reconstructing a segmented 3D shape from a single unstructured object image.
Last but not the least, our network is also the first which can reconstruct and recover sharp geometric features.
Through extensive experiments on shape auto-encoding, segmentation, part correspondence, and single-view reconstruction, we demonstrate state-of-the-art performances by BSP-Net. Comparisons are made to leading methods on shape decomposition and 3D reconstruction, using conventional distortion metrics, visual similarity, as well as a new metric assessing the capacity of a model in representing sharp features. In particular, we highlight the favorable fidelity-complexity trade-off exhibited by our network.
Related work
Large shape collections such as ShapeNet and PartNet have spurred the development of learning techniques for 3D data processing. In this section, we cover representative approaches based on the underlying shape representation learned, with a focus on generative models.
Early approaches generalized 2D convolutions to 3D , and employed volumetric grids to represent shapes in terms of coarse occupancy functions, where a voxel evaluates to zero if it is outside and one otherwise. Unfortunately, these methods are typically limited to low resolutions of at most due to the cubic growth in memory requirements. To generate finer results, differentiable marching cubes operations have been proposed , as well as hierarchical strategies that alleviate the curse of dimensionality affecting dense volumetric grids. Another alternative is to use multi-view images and geometry images , which allow standard 2D convolution, but such methods are only suitable on the encoder side of a network architecture, while we focus on decoders. Finally, recent methods that perform sparse convolutions on voxel grids are similarly limited to encoders.
Surface models
As much of the semantics of 3D models is captured by their surface, the boundary between inside/outside space, a variety of methods have been proposed to represent shape surfaces in a differentiable way. Amongst these we find a category of techniques pioneered by PointNet that express surfaces as point clouds , and techniques pioneered by AtlasNet that adopt a 2D-to-3D mapping process . An interesting alternative is to consider mesh generation as the process of estimating vertices and their connectivity , but these methods do not guarantee watertight results, and hardly scale beyond a hundred vertices.
Implicit models
A very recent trend has been the modeling of shapes as a learnable indicator function , rather than a sampling of it, as in the case of voxel methods. The resulting networks treat reconstruction as a classification problem, and are universal approximators whose reconstruction precision is proportional to the network complexity. However, at inference time, generating a 3D model still requires the execution of an expensive iso-surfacing operation whose performance scales cubically in the desired resolution. In contrast, our network directly outputs a low-poly approximation of the shape surface.
Shape decomposition
BSP-Net generates meshes using a part-based approach, hence techniques that learn shape decompositions are of particular relevance. There are methods that decompose shapes as oriented boxes , axis aligned gaussians , super-quadrics , or a union of indicator functions, in BAE-NET . The architecture of our network draws inspiration from BAE-NET, which is designed to segment a shape by reconstructing its parts in different branches of the network. For each shape part, BAE-NET learns an implicit field by means of a binary classifier. In contrast, BSP-Net explicitly learns a tree structure built on plane subdivisions for bottom-up part assembly.
Another similar work is CvxNet , which decomposes shapes as a collection of convex primitives. However, BSP-Net differs from CvxNet in several significant ways: \raisebox{-.75pt}{1}⃝ we target low-poly reconstruction with sharp features, while they target smooth reconstruction; \raisebox{-.75pt}{2}⃝ their network always outputs convexes, while the “right” number of primitives is learnt automatically in our method; \raisebox{-.75pt}{3}⃝ our optimization routine is completely different from theirs, as their compositional tree structure is hard-coded.
Structured models
There have been recent works on learning structured 3D models, in particular, linear or hierarchical organization of part bounding boxes. While some methods learn part geometries separately , others jointly embed/encode structure and geometry . What is common about all of these methods is that they are supervised, and were trained on shape collections with part segmentations and labels. In contrast, BSP-Net is unsupervised. On the other hand, our network is not designed to infer shape semantics; it is trained to learn convex decompositions. To the best of our knowledge, there is only one prior work, Im2Struct , which infers part structures from a single-view image. However, this work only produces a box arrangement; it does not reconstruct a structured shape like BSP-Net.
Binary and capsule networks
The discrete optimization for the tree structures in BSP-Net bears some resemblance to binary and XNOR neural networks. However, only one layer of BSP-Net employs binary weights, and our training method differs, as we use a continuous relaxation of the weights in early training. Further, as our network can be thought of as a simplified scene graph, it holds striking similarities to the principles of capsule networks , where low-level capsules (hyperplanes) are aggregated in higher (convexes) and higher (shapes) capsule representations. Nonetheless, while addresses discriminative tasks (encoder), we focus on generative tasks (decoder).
Method
We seek a deep representation of geometry that is both trainable and interpretable. This is achieved by devising a network architecture that provides a differentiable Binary Space Partitioning tree (BSP-tree) representationWhile typical BSP-trees are binary, we focus on -ary trees, with the “B” in BSP referring to binary space partitioning, not the tree structure., a classical spatial data structure originated from graphics . This representation is easily trainable as it encodes geometry via implicit functions, and interpretable since its outputs are a collection of convex polytopes. While we generally target 3D geometry, we employ 2D examples to explain the technique without loss of generality.
We achieve our goal via a network containing three main modules, which act on feature vectors extracted by an encoder corresponding to the type of input data (e.g. the features produced by ResNet for images or 3D CNN for voxels). In more details, a first layer that extracts hyperplanes conditional on the input data, a second layer that groups hyperplanes in the form of half-spaces to create parts (convexes), and a third layer assembles parts together to reconstruct the overall object; see Figure 3.
Given a feature vector , we apply a multi-layer perceptron to obtain plane parameters , where is the number of planes – i.e. . For any point , the product is a vector of signed distances to each plane – the th distance is negative if is inside, and positive if it is outside, the th plane, with respect to the plane normal.
Layer 2: hyperplane grouping
To group hyperplanes into geometric primitives we employ a binary matrix . Via a max-pooling operation we aggregate input planes to form a set of convex primitives:
Note that during training the gradients would flow through only one (max) of the planes. Hence, to ease training, we employ a version that replaces max with summation:
Layer 3: shape assembly
This layer groups convexes to create a possibly non-convex output shape via min-pooling:
Note that the use of in the expression above is intentional. We avoid using due to the lack of a memory efficient implementation of the operator in TensorFlow 1.
Again, to facilitate learning, we distribute gradients to all convexes by resorting to a (weighted) summation:
where is a weight vector, and performs clipping. During training we will enforce . Note that the inside/outside status here is only approximate. For example, when , and all , one is outside of all convexes, but inside their composition.
Two-stage training
Losses evaluated on (4) will be approximate, but have better gradient than (3). Hence, we develope a two-stage training scheme where: \raisebox{-.75pt}{1}⃝ in the continuous phase, we try to keep all weights continuous and compute an approximate solution via – this would generate an approximate result as can be observed in Figure 4 (b); \raisebox{-.75pt}{2}⃝ in the next discrete phase, we quantize the weights and use a perfect union to generate accurate results by fine-tuning on – this creates a much finer reconstruction as illustrated in Figure 4 (c,d).
Our two-stage training strategy is inspired by classical optimization, where smooth relaxation of integer problems is widely accepted, and mathematically principled.
1 Training Stage 1 – Continuous
We initialize and with random zero-mean Gaussian noise having , and optimize the network via:
Note that this is more effective than using a sigmoid activation, as its gradients do not vanish. Further, we would like to be close to so that the merge operation is a sum:
However, we remind the reader that we initialize with to avoid vanishing gradients in early training.
2 Training Stage 2 – Discrete
In the second stage, we first quantize by picking a threshold and assign . Experimentally, we found the values learnt for to be small, which led to our choice of a small threshold value. With the quantized , we fine-tune the network by:
where we ensure that the shape is well reconstructed via:
The above loss function pulls towards if should be inside the shape; it pushes beyond otherwise. Optionally, we can also discourage overlaps between the convexes. We first compute a mask such that if is in convex and is contained in more than one convex, and then evaluate:
3 Algorithmic and training details
In our 2D experiments, we use planes and convexes. We use a simple 2D convolutional encoder where each layer downsamples the image by half, and doubles the number of feature channels. We use the centers of all pixels as samples. In our 3D experiments, we use planes and convexes. The encoder for voxels is a 3D CNN encoder where each layer downsamples the grid by half, and doubles the number of feature channels. It takes a volume of size as input. The encoder for images is ResNet-18 without pooling layers that receives images of size as input. All encoders produce feature codes . The dense network has widths where the last layer outputs the plane parameters.
When training the auto-encoder for 3D shapes, we adopt the progressive training from , on points sampled from grids that are increasingly denser (, , ). Note that the hierarchical training is not necessary for convergence, but results in an speedup in convergence. In Stage 1, we train the network on grids for 8 million iterations with batch size , then for 8 million iterations with batch size , then for 8 million iterations with batch size . In Stage 2, we train the network on grids for 8 million iterations with batch size .
For single-view reconstruction, we also adopt the training scheme in , i.e., train an auto-encoder first, then only train the image encoder of the SVR model to predict latent codes instead of directly predicting the output shapes. We train the image encoder for 1,000 epochs with batch size . We run our experiments on a workstation with an Nvidia GeForce RTX 2080 Ti GPU. When training the auto-encoder (one model on the 13 ShapeNet categories), Stage 1 takes about days and Stage 2 takes days; training the image-encoder requires day.
Results and evaluation
We study the behavior of BSP-Net on a synthetic 2D shape dataset (Section 4.1), and evaluate our auto-encoder (Section 4.2), as well as single view reconstruction (Section 4.3) compared to other state-of-the-art methods.
To illustrate how our network works, we created a synthetic 2D dataset. We place a diamond, a cross, and a hollow diamond with varying sizes over images; see Figure 4(a). The order of the three shapes is sorted so that the diamond is always on the left and the hollow diamond is always on the right – this is to mimic the structure of shape datasets such as ShapeNet . After training Stage 1, our network has already achieved a good approximate reconstruction, however, by inspecting , the output of our inference, we can see there are several imperfections. After the fine-tuning in Stage 2, our network achieves near perfect reconstructions. Finally, the use of overlap losses significantly improves the compactness of representation, reducing the number of convexes per part; see Figure 4(d).
Figure 5 visualizes the planes used to construct the individual convexes – we visualize planes in convex so that and for a small threshold (to ignore planes with near-zero gradients). Note how BSP-Net creates a natural semantic correspondence across inferred convexes. For example, the hollow diamond in Figure 4(d) is always made of the same four convexes in the same relative positions – this is mainly due to the static structure in : different shapes need to share the same set of convexes and their associated hyper-planes.
2 Auto-encoding 3D shapes
For 3D shape autoencoding, we compare BSP-Net to a few other shape decomposition networks: Volumetric Primitives (VP) , Super Quadrics (SQ) , and Branched Auto Encoders (BAE) . Note that for the segmentation task, we also evaluate on BAE*, the version of BAE that uses the values of the predicted implicit function, and not just the classification boundaries – please note that the surface reconstructed by BAE and BAE* are identical.
Since all these methods target shape decomposition tasks, we train single class networks, and evaluate segmentation as well as reconstruction performance. We use the ShapeNet (Part) Dataset , and focus on five classes: airplane, car, chair, lamp and table. For the car class, since none of the networks separates surfaces (as we perform volumetric modeling), we reduce the parts from (wheel, body, hood, roof) (wheel, body); and analogously for lamps (base, pole, lampshade, canopy) (base, pole, lampshade) and tables (top, leg, support) (top, leg).
As quantitative metrics for reconstruction tasks, we report symmetric Chamfer Distance (CD, scaled by ) and Normal Consistency (NC) computed on surface sampled points. We also report the Light Field Distance (LFD) – the best-known visual similarity metric from computer graphics. For segmentation tasks, we report the typical mean per-label Intersection Over Union (IOU).
Table 2 shows the per category segmentation results. As we have ground truth part labels for the point clouds in the dataset, after training each network, we obtain the part label for each primitive/convex by voting: for each point we identify the nearest primitive to it, and then the point will cast a vote for that primitive on the corresponding part label. Afterwards, for each primitive, we assign to it the part label that has the highest number of votes. We use 20% of the dataset for assigning part labels, and we use all the shapes for testing. At test time, for each point in the point cloud, we find its nearest primitive, and assign the part label of the primitive to the point. In the comparison to BAE, we employ their one-shot training scheme [4, Sec.3.1]. Note that BAE-NET* is specialized to the segmentation task, while our work mostly targets part-based reconstruction; as such, the IoU performance in Table 2 is an upper bound of segmentation performance.
Figure 6 shows semantic segmentation and part correspondence implied by BSP-Net autoencoding, showing how individual parts (left/right arm/leg, etc.) are matched. In our method, all shapes are corresponded at the primitive (convexes) level. To reveal shape semantics, we manually group convexes belonging to the same semantic part and assign them the same color. Note that the color assignment is done on each convex once, and propagated to all the shapes.
Reconstruction comparison
BSP-Net achieves significantly better reconstruction quality, while maintaining high segmentation accuracy; see Table 1 and Figure 7, where we color each primitive based on its inferred part label. BAE-NET was designed for segmentation, thus produces poor-quality part-based 3D reconstructions. Note how BSP-Net is able to represent complex parts such as legs of swivel chairs in Figure 7, while none of the other methods can.
3 Single view reconstruction (SVR)
We compare our method with AtlasNet , IM-NET and OccNet on the task of single view reconstruction. We report quantitative results in Table 3 and Table 4, and qualitative results in Figure 8. We use the categories in ShapeNet that have more than 1,000 shapes each, and the rendered views from 3D-R2N2 . We train one model on all categories, using 80% of the shapes for training and 20% for testing, in a similar fashion to AtlasNet . For other methods, we download the pre-trained models released by the authors. Since the pre-trained OccNet model has a different train-test split than others, we evaluate it on the intersection of the test splits.
To measure the capacity of a model to represent sharp features, we introduce a new metric. We first compute an “edge sampling” of the surface by generating points uniformly distributed on the surface of a model, and then compute sharpness as: where extracts the indices of the samples in within distance from , and is the surface normal of a sample. We set , and generate our edge sampling by retaining points such that ; see Figure 8. Given two shapes, the ECD between them is nothing but the Chamfer Distance between the corresponding edge samplings.
Analysis
Our method achieves comparable performance to the state-of-the-art in terms of Chamfer Distance. As for visual quality, our method also outperforms most other methods, which is reflected by the superior results in terms of Light Field Distance. Similarly to Figure 6, we manually color each convex to show part correspondences in Figure 9. We visualize the triangulations of the output meshes in Figure 8: our method outputs meshes with a smaller number of polygons than state-of-the-art methods. Note that these methods cannot generate low-poly meshes, and their vertices are always distributed quasi-uniformly.
Finally, note that our method is the only one amongst those tested capable of representing sharp edges – this can be observed quantitatively in terms of Edge Chamfer Distance, where BSP-Net performs much better. Note that AtlasNet could also generate edges in theory, but the shape is not watertight and the edges are irregular, as it can be seen in the zoom-ins of Figure 8. We also analyze these metrics aggregated on the entire testing set in Table 4. In this final analysis, we also include OccNet128 and IM-NET256, which are the original resolutions used by the authors. Note the average number of polygons inferred by our method is (recall #polygons #triangles in polygonal meshes).
Conclusion, limitation, and future work
We introduce BSP-Net, an unsupervised method which can generate compact and structured polygonal meshes in the form of convex decomposition. Our network learns a BSP-tree built on the same set of planes, and in turn, the same set of convexes, to minimize a reconstruction loss for the training shapes. These planes and convexes are defined by weights learned by the network. Compared to state-of-the-art methods, meshes generated by BSP-Net exhibit superior visual quality, in particular, sharp geometric details, when comparable number of primitives are employed.
The main limitation of BSP-Net is that it can only decompose a shape as a union of convexes. Concave shapes, e.g., a teacup or ring, have to be decomposed into many small convex pieces, which is unnatural and leads to wasting of a considerable amount of representation budget (planes and convexes). A better way to represent such shapes is to do a difference operation rather than union. How to generalize BSP-Net to express a variety of CSG operations is an interesting direction for future work.
Current training times for BSP-Net are quite significant: 6 days for planes and convexes for the SVR task trained across all categories; inference is fast however. While most shapes only need a small number of planes to represent, we cannot reduce the total number of planes as they are needed to well represent a large set of shapes. It would be ideal if the network can adapt the primitive count based on the complexity of the input shapes; this may call for an architectural change to the network.
While its applicability to RGBD data could leverage the auto-decoder ideas explored by , the generalization of our method beyond curated datasets , and the ability to train from only RGB images are of critical importance.
Acknowledgements
We thank the anonymous reviewers for their valuable comments. This work was supported in part by an NSERC grant (No. 611370), a Google Faculty Research Award, and Google Cloud Platform research credits.