Code release for "Learning Shape Abstractions by Assembling Volumetric Primitives " (CVPR 2017)
We present a learning framework for abstracting complex shapes by learning to assemble objects using 3D volumetric primitives. In addition to generating simple and geometrically interpretable explanations of 3D objects, our framework also allows us to automatically discover and exploit consistent structure in the data. We demonstrate that using our method allows predicting shape representations which can be leveraged for obtaining a consistent parsing across the instances of a shape collection and constructing an interpretable shape similarity measure. We also examine applications for image-based prediction as well as shape manipulation.READ FULL TEXT VIEW PDF
Code release for "Learning Shape Abstractions by Assembling Volumetric Primitives " (CVPR 2017)
“Treat nature by means of the cylinder, the sphere, the cone, everything brought into proper perspective”
Cezanne’s insight that an object can be conceived as assembled from a set of volumetric primitives has resurfaced multiple times in the vision and graphics literature. In computer vision, generalized cylinders were introduced by Binford back in 1971, where a cross-sectional area is swept along a straight or curved axis while possibly being shrunk or expanded during the process. One of the key motivations was parsimony of description
– an object could be described by relatively few generalized cylinders, each of which in turn requiring only a few parameters. Volumetric primitives remained popular through the 1990s as they provided a coherent framework for explaining shape inference from a single image, perceptual organization, as well as recognition of a 3D object from 2D views. However, fitting generalized cylinders to image data required considerable hand crafting, and as machine learning techniques for object recognition came to the fore in the 1990s, this paradigm faded from the main stage.
Of course, finding parsimonious explanations for complex phenomena lies at the core of learning-based visual understanding. Indeed, machine learning is only possible because our visual world, despite its enormous complexity, is also highly structured – visual patterns don’t just happen once, but keep on repeating in various configurations. In contemporary computer vision, this structure is most often modeled via human supervision: the repeating patterns are labeled as objects or object parts, and supervised learning methods are employed to find and name them in novel imagery. However, it would seem more satisfying if complex structures could be explained in terms of simpler underlying structures.
In this paper we return to the classic problem of explaining objects with volumetric primitives, but using the modern tools of unsupervised learning and convolutional neural networks (CNNs). We choose the simplest possible primitives, rigidly transformed cuboids, and show how deep convolutional networks can be trained to assemble arbitrary 3D objects out of them (at some level of approximation). The main reason we succeed where the classic approaches failed is because we aim to explain the entire dataset of 3D objects jointly, allowing us to learn the common 3D patterns directly from the data.
While the representation of the 3D object shapes e.g. as meshes or voxel occupancies, is typically complex and high-dimensional, the resulting explanation in terms of basic primitives is parsimonious, with a small number of parameters. As examples of their applicability, we leverage the primitive based representation for various tasks e.g. part discovery, image based abstraction, shape manipulation etc. Here we do not wish to reprise the classic debates on the value of volumetric primitives – while they were oversold in the 70s and 80s, they suffer from complete neglect now, and we hope that this demonstration of feasibility of learning how to assemble an object from volumetric primitives will reignite interest. Code is available at https://shubhtuls.github.io/volumetricPrimitives.
3D Representation and Reconstruction. The classic approaches for modeling objects and scenes dating to the very beginnings of the computer vision discipline, such as blocks world , generalized cylinders , and geons , emphasized the compactness of representation as the central goal. In a similar spirit, a few modern approaches have attempted to reconstruct objects/scenes using simple primitives, including Lego pieces  and qualitative 3D blocks . Apart from these attempts, most mainstream methods for representing and reconstructing objects typically use much higher-dimensional representations e.g. objects as point clouds [19, 35] or exemplar CAD models [23, 24, 38]. The success of the latter set of approaches has been largely driven by the data-driven reasoning which the classical methods did not leverage. Our work aims to combine the two – we aim for a parsimonious representation but discover the underlying parsimony in a data-driven manner instead of relying on hand-crafted cues and priors. Similar to our approach, Yumer and Kara [39, 40] showed that parsimonious modelling with data-driven reasoning can allow consistent geometry simplifications or deformations in shape collections but our learning based approach allows efficient test time inference for novel shapes. An additional property of our approach, compared to classical methods, is the consistency of representation across instances. Classical approaches solve a per-instance optimization and obtain an unordered set of primitives whereas our our approach outputs a consistent indexed set of primitives – this allows several applications examined in applications.
Parsing Objects, Scenes and 3D Shapes. The idea of exploiting repeating structures in large datasets has been central to efforts on unsupervised object discovery and co-segmentation [28, 30]. Data-driven compositionality, in particular, has been used for co-segmentation , scene parsing and novel scene generation [17, 29]. In the domain of 3D shapes, the idea of exploiting compositionality has played a similarly important role for object representation, parsing, and manipulation. Pre-labeled, part-based shape representations were used for capturing the category-specific shape manifold , generating novel objects [16, 18] or recovering 3D from 2.5D data . Other methods aim to automatically discover these components in 3D shape datasets , and their relative arrangements . Similar to these shape and scene based methods, our framework can automatically discover consistent components and understand the structure of the data, but we do so by virtue of learning to generate parsimonious explanations.
Deep Generative Models.
The rapid recent progress in supervised learning tasks by using deep learning techniques has been accompanied by a growing interest in leveraging similar methods to discover structure in the visual data. Using generative adversarial networks[9, 26] allows learning the data distribution but the underlying latent space lacks interpretability. Other generative methods aim to explicitly decouple the underlying factors of variation [4, 22] but rely on supervision for disentangling these factors. More closely related to our work, some recent approaches use recurrent networks to iteratively generate components to explain a simple 2D input scene [5, 10, 14]. Our work uses similar principles of learning component based explanations of complex shapes where the components are interpretable simple 3D primitives.
We formulate the problem of assembling a target object , given input signal as that of predicting (up to) distinct parts which are then composed to output the final shape. Towards this, we learn a CNN parametrized by which outputs a primitive based representation. The task of learning this CNN is an unsupervised one – we do not have any annotations for the primitive parameters that best describe the target objects. However, even though there is no direct supervision, one can measure if a predicted primitive configuration is good by checking if the assembled object matches the target object. Using this insight, we formulate a loss function which informs us if the shape assembled using the predicted primitives matches the target shape and optimize this loss to train the CNN.
An overview of our approach is presented in framework. Given a discretized representation of the target shape as input, we use a CNN to predict a primitive representation (described in primRep). The predicted representation implicitly defines an assembled shape by composing the predicted primitives. primLoss describes a differentiable loss function that allows using this representation in a learning framework. While the initial presentation assumes the use of a fixed number of primitives, varNum extends our approach to allow a variable number of primitives.
primRep We represent an assembled shape by composing the predicted simple transformed primitives. Each primitive is encoded in terms of a tuple where represents its shape in a canonical frame and represent the spatial transformation (rotation and translation). The assembled shape predicted by the neural network can therefore be written as below.
The motivation for this parametrization is to exploit the compositionality of parts as well as the independence of ‘what’ and ‘where’ (part shape and spatial transformation respectively). The representation of a shape as a set of parts allows independent reasoning regarding semantically separate units like chair legs, seat etc. The decomposition in terms of part shape and transformation parameters further decomposes factors of variation like ‘broad aeroplane wing’ (captured by shape) and ‘tilted chair back’ (captured by transformation).
primLoss We want to define a differentiable loss function between the CNN prediction and the target object . This is a challenging task because the prediction and the groundtruth have different 3D representations – the prediction is a parametrized shape whereas the groundtruth is a mesh consisting of triangles. To overcome this, we leverage the fact that the parametrization in terms of simple primitives allows efficient computation of some properties of the shape induced by their composition. In particular, we can compute the distance field (prelim) of the assembled shape as well as sample points on the surface of the primitives. These allow us to define two complimentary losses which together aim to minimize the discrepancy between the predicted and ground-truth shape. The Coverage Loss tries to enforce that the object is subsumed by the predicted assembled shape. The Consistency Loss enforces the other direction – that the object subsumes the predicted shape. By optimizing these losses together, we ensure that the assembled shape tries to be maximally consistent with the target object.
prelim Notation. We represent by , the untransformed primitive as predicted according to and use to denote the primitive after rotation, translation according to . Therefore, the final shape induced by the composition of the predicted primitives is .
We use the function to represent the surface of the argument and represents a random point sampled on it e.g. corresponds to a point sampled on the surface of primitive. We also require notations for simple rigid transformations – we denote by result of rotating a point according to rotation specified by quaternion and similarly, denotes the result of translating a point by . Note that the operations are both differentiable.
Distance Field. A distance field corresponding to an object is a function that computes the distance to the closest point of the object. Note that it evaluates to 0 in the object interior.
coverage We want to penalize the CNN prediction if the target object is not completely covered by the predicted shape . A sufficient condition to ensure this is that the distance field of the assembled shape evaluates to zero for all points on the surface of O.
Computation can be simplified due to a nice property of distance fields. It is easy to show that the distance field of a composed shape equals to the pointwise minimum of the distance fields of all composing shapes:
This decomposition rule boils the distance field of a whole shape down to the distance field of a primitive. In the following, we show how to efficiently compute for primitives as cuboids.
Distance field of Primitives. Given an origin-centred cuboid represented by – its extent in the three dimensions, its distance field can be computed as below (using ):
Consider an object (with an associated field ) undergoing a rotation (parametrized by quaternion ) followed by a translation . The distance field at a point w.r.t. the transformed object is the same as the distance field at wrt. the canonical object where . This observations allows us to complete the formulation by defining (required in (LABEL:distDecomp)) as below.
consistency We want to penalize the CNN prediction if the predicted shape is not completely inside the target object . A sufficient condition is to ensure this is that the distance field of the object O shape evaluates to zero for all points on the surface of individual primitives .
Additionally, we observe that to sample a point on the surface of , one can equivalently sample on the surface of the untransformed primitive and then rotate, translate according to .
An aspect for computing gradients for the predicted parameters using this loss is the ability to compute derivatives for given gradients for a sampled point on the canonical untransformed primitive . We do so by using the re-parametrization trick  which decouples the parameters from the random sampling. As an example, consider a point being sampled on a rectangle extending from to . Instead of sampling the x-coordinate as , one can use and . This re-parametrization of sampling allows one to compute . We provide the details for applying the re-parametrization trick for a cuboid primitive in the appendix.
varNum The framework we have presented so far reconstructs each instance in an object category using exactly primitives. However, different instances in an object category can be explained by different number of primitives e.g
. some chairs have handles, others don’t. To incorporate this, in addition to predicting the shape and transformation of each primitive, we also predict the probability of its existence. We first discuss the modified representation predicted by the CNN and discuss how the loss function can incorporate this.
Primitive Representation. As we mentioned above, the primitive representation has an added parameter – the probability of its existence. To incorporate this, we factor the primitive shape into two components – . Here represents the primitive’s dimensions (e.g. cuboid height, width, depth) as before and
is a binary variable which denotes if the primitive actually existsi.e. if we pretend as if the primitive does not exist. The prediction of the CNN in this scenario is as below.
Note that the CNN predicts
– the parameter of the Bernoulli distribution from which the part existence variableis sampled. This representation allows the prediction of a variable number of parts e.g. if a chair is best explained using primitives, the network can predict a high for only primitives and a low for the remaining primitives.
Learning. Under the reformulated representation of primitives, the CNN output does not induce a unique assembled shape – it induces a distribution of possible shapes where the primitive stochastically exists with probability . In this scenario, we want to minimize the expected loss across the possible assemblies. The first step is to modify the consistency and coverage losses to incorporate . Towards this, we note that the untransformed primitive is either a cuboid (if ) or empty (if ). In case it is empty, we can simply skip it the the consistency loss (consistency) for this primitive and can incorporate this in the coverage loss (coverage) by modifying (LABEL:CPmcub) as follows -
We can now define the final loss using the concepts developed. Note that this is simply the expected loss across possible samplings of according to .
Under this loss function, the gradients for the continuous variables i.e.
can be estimated by averaging their gradients across samples. However, to compute gradients for the distribution parameter, we use the REINFORCE algorithm  which basically gives positive feedback if the overall error is low (reward is high) and negative feedback otherwise. To further encourage parsimony, we include a small parsimony reward (reward for choosing fewer primitives) when computing gradients for .
Dataset. We perform our experiments primarily using the ShapeNet  dataset which has a large collection of 3D models. In particular, we use the ‘airplane’ and ‘chair’ object categories which have thousands of meshes available. The ShapeNet models are already aligned in a canonical frame and are of a fixed scale. Additionally, in order to demonstrate applicability beyond rigid objects, we also manually download and similarly preprocess a set of around 100 models corresponding to four-legged animals.
Network Architecture and Training. The dataset described above gives us a set of 3D objects . Corresponding to , the input to our CNN is a discretized representation as a volumetric occupancy grid of size (we later experiment with rendered images as input in imgpred). The encoder used in our shape assembler, as shown in framework, takes in as input an occupancy grid and passes it through 3D convolutional and fully connected layers with intermediate non-linearities to output the primitive parameters . In this work, we use cuboid primitives and represents the width, height and thickness of cuboids. We use ADAM  to train our network according to the loss described in assembly which aims to make the assembled shape predicted using match to the target object .
Implementation Details. The coverage and consistency loss functions are both defined using expectations over sampled points. In practice, we randomly sample 1000 points on to implement (LABEL:coverageLoss) and 150 points from each to implement (LABEL:ConsistencyLoss). To efficiently compute the distance field of the target object at an arbitrary point in (LABEL:ConsistencyLoss), we precompute the distance field and its derivatives for samples in a dense regular grid and use it to obtain efficient but approximate gradients .
Another practical difficulty is that the gradients for the primitive existence probabilities are extremely noisy in the initial training stages – e.g. in the initial stages if a primitive is incorrectly placed, the CNN may learn to predict a very small instead of learning to align the primitive correctly. To overcome this, we use a two-stage training process. We first train the network using a fixed high value of across primitives and later allow the network to also learn while also encouraging simplicity by the external parsimony reward. As shown in trainingErr, this has the effect of first using a large number of primitives and in later stages, merging them together and using fewer primitives.
After the CNN has been trained, when computing the assembled representation for an object, we use MLE estimates instead of sampling i.e. . The final shape predictions using the CNN may still have redundant parts used and we use a simple post-processing step to refine the prediction by removing the parts which significantly overlap with others.
Results and Analysis. We show the results of our method for three object categories – chairs, aeroplanes and animals in predFig. We observe that the predictions successfully capture the coarse structure and are consistent across objects. The results indicate that the we can handle structural variations within a category e.g. the objects in the right side of predFig have a different structure than those on the left which occur more commonly in the dataset.
We visualize in trainingErr the training error across iterations. We observe that in the initial training stage (up to 20000 iterations), the loss rapidly decreases as the correct configuration is being learned. In the second stage of training, when we allow to be learned, the error initially increases – this is because some primitives, encouraged by the parsimony reward, now start disappearing and the network eventually learns to use fewer primitives better. Even though the reconstruction error in the initial stages is lower, the reconstructions using fewer primitives, are more parsimonious. This provides an insight regarding the tradeoff between representation parsimony and reconstruction accuracy – and that we should not judge the former by the latter.
We observe in fig1 and predFig that the inferred representations are consistent across a category – chair seat is explained consistently using the same primitive. They are also descriptive of the underlying shape and are, by construction, interpretable. Therefore, our framework allows us to automatically discover descriptive, consistent and interpretable shape abstractions using a collection of 3D models. By virtue of these properties, our representation can enable several applications related to shape similarity, part discovery, perception and shape manipulation.
parsing The learned primitive decomposition is useful for obtaining part-level correspondences across instances. Since we use a common network across an object category, simple and consistent solutions are preferred to explain the data i.e. the same primitive explains the chair back across the category. We can leverage this observation to extract correspondences across the category by assigning labels to points according to the primitive that explains them – we assign each point to the primitive that has the lowest , giving preference to larger primitives to break ties. We therefore obtain a consistent labelling of all points across instances using the predicted primitive decomposition – some examples are depicted in parsing.
We also evaluate this parsing on the Shape COSEG  dataset by measuring the accuracy using annotated ground-truth. While the ground-truth only has 3 clusters (chair back, seat, legs), our method as well as previous unsupervised approaches [31, 36] cluster shapes into a larger number of partitions (number of primitives in our case) and assign each partition a ground-truth label to evaluate. We obtain a mean accuracy of 89.0 whereas  reports 78.6 and 84.8 accuracy with initial and refined parsings respectively111Unfortunately, we found that  used a preliminary version of the Shape COSEG dataset . We were unable to obtain this preliminary version, therefore the results are not exactly comparable. The algorithm in  does use the current dataset but reports no quantitative results.. See appendix for qualitative results.
similarity The trained CNN of our shape assembler maps every 3D shape to corresponding primitive parameters . These parameters succinctly capture the geometry of the underlying object. We find that a simple euclidean distance in the embedding space is a reliable measure of shape similarity. We use this distance to compute a t-sne  embedding of shapes and visualize 1000 random instances in embedding . We observe that the automatically discovered structure captures similarity better than a simple voxel IoU based metric and that clusters correspond to natural sub-categories e.g. sofa etc.
One aspect unique to our approach is that the shape embedding is interpretable and instead of using primitive parameters for all parts, we can modify the distance measure to focus on specifics of interest for the application. As an example, we show the resulting t-sne embedding if only 2 primitives, which correspond to back and seat, are used to compute the distance across shapes. We observe that the embedding reflects the desired similarity e.g. unlike in the case of using all primitives to measure shape similarity, chairs with and without handles are now embedded together. We also compute the embedding for the distance measure which only measures the difference in the orientation for a specific part (chair back) and observe that this is a 1D manifold with the tilt increasing as we traverse it. Therefore, unlike common shape representations, our inferred abstractions give us control over similarity measures.
imgpred Given our trained model which infers primitive representation using volume inputs, we can train an image based prediction model . We obtain volume-image pairs by rendering ShapeNet models with random lighting and background (as suggested in ) and train the image based network to mimic the volume based network’s predictions i.e. we train to minimize . This distillation technique  for using paired data to train a model for predicting outputs similar to a pre-trained CNN is common  and has previously also been used for learning shape embeddings . We find that we can successfully apply this to our scenario and learn an image-based prediction model that outputs the abstraction of the underlying shape given a single image. We show some results in imgpred. This demonstrates that one can learn to predict shape abstractions using varying inputs and this might enable applications in robotics settings where such inference might help in grasping, planning etc.
manipulation The inferred primitive based shape abstractions can be used as a skeleton to guide manipulation of the underlying objects. We can assign each mesh point a local coordinate in the frame of its corresponding primitive (as computed in parsing). A rotation, translation or scaling of the corresponding primitive can thereby induce a change in the global coordinates of the associated mesh points. We show some examples in manipulation where we deform a source mesh to have a similar configuration as a target mesh. While the transformation used in this example is defined using a target mesh, one can also use our representation for other transformation e.g. making the legs longer or tilting the back etc.
In this work, we take an unsupervised, data-driven approach to explain visual information in terms of simpler primitives. Taking inspiration from the classic work on generalized cylinders  and geons , we too argue that any visual explanation must be in terms of 3D volumetric entities, not 2D pixel patches. However, unlike the earlier work in this area we firmly believe in being data-driven and letting the data itself discover the best representation.
We demonstrated the applicability of data-driven 3D understanding of the visual world in a very simple setting – that of explaining objects from cuboidal primitives. This merely represents the first steps towards the goal of generating parsimonious descriptions of the visual input and hope that this will motivate further efforts, including the use of a wider catalogue of basic parametrized primitives, to understand the underlying 3D structure of the world.
We thank Saurabh Gupta and David Fouhey for insightful discussions. This work was supported in part by Intel/NSF Visual and Experiential Computing award IIS-1539099, NSF Award IIS-1212798, and the Berkeley Fellowship to ST. We gratefully acknowledge NVIDIA corporation for the donation of Tesla GPUs used for this research.
Learning a predictable and generative vector representation for objects.In ECCV, 2016.
Joint shape segmentation with linear programming.In ACM Transactions on Graphics (TOG). ACM, 2011.
Unsupervised co-segmentation of a set of shapes via descriptor-space spectral clustering.ACM Trans. on Graphics (Proc. SIGGRAPH Asia), 2011.
Simple statistical gradient-following algorithms for connectionist reinforcement learning.Machine learning, 1992.
We first re-iterate the consistency loss which aims for the assembled shape to be subsumed by ground-truth object and does so by sampling points on the surface of each primitive and penalizing the squared distance field w.r.t the ground-truth object at the sampled points.
Recall that to sample a point on the surface of , one can equivalently sample on the surface of the untransformed primitive and then rotate, translate according to .
Note that the untransformed primitive is an origin-centered cuboid parametrized by – the dimensions along the three canonical axes. We now aim to show that we can derive gradients for given gradients for a . We do so using a re-parametrization trick where we aim to decouple the random sampling process from the parameters. The process of sampling from a cuboid’s surface requires developing tow aspects. The first concerns how to sample from a particular face. The second required component is to decide which face to sample from – we show that we can sample equally from all faces if we assign sample importance weights.
Sampling Along a Face. Let us assume we want to to sample a point from a given cuboid face – say the one on the plane . The process of sampling a point on this face can be written as -
We can similarly define a sampling process for the other cuboid faces. Note that the coordinates of the sampled point are linear the primitive parameters and that given the random coefficients , it is straightforward to compute .
Importance Weights per Sample. To sample uniformly on the cuboid surface, we need to sample on each face with a probability proportional to its area. Unfortunately, it is unclear how this sampling process can be decoupled from the parameters . Instead, we can simply sample equally from all faces and assign each sample an importance weight proportional to the area of the face it was sampled from. Under this implementation, the consistency loss as previously defined can be implemented as:
Here is the importance weight of the corresponding sample and is proportional to the area of the face where it was drawn from. Note that is also differentiable w.r.t , therefore making consistency loss described differentiable w.r.t the predicted primitive parameters.
We provide more details on how we use the REINFORCE algorithm to compute gradients for the primitive existence probabilities . We discuss a more general implementation compared to the text – we assume represents the probability of the available choices for the primitive – is the probability that the primitive does not exist and is the probability that it is a cuboid. Note that this can be modified to add other choices e.g. a third choice that the primitive is a cylinder.
Let denote the loss incurred for the particular sampling of . Let denote the external parsimony reward obtained if a primitive is sampled as not existing. Using these, the gradient for the predicted probability is computed as -
It is typically also advised to subtract a ‘baseline’ (mean reward in the ideal scenario) to reduce the variance of the estimated gradients so we incorporate it usinginstead of in the equation above where is the running average of the losses incurred.
Architecture and Hyper-parameters.
Our network has five 3D convolution layers (with ReLU) of kernel 3, padding 1, stride 2. The number of channels (initially 4) are doubled after every layer. These are followed by 2 fc layers (with ReLU) with 100 units each, followed by a final layer to predict primitive parameters. We use ADAM for optimization and choose M to be more than the double the number of expected parts. M=20 for chairs, but was reduced to 15, 12 for planes, animals (to reduce iteration time).
Initialization. We initially bias s.t. primitives are small cubes and so every primitive is initially used but all other layer parameters/weights (and primitive positions, rotations etc.) are initialized randomly (our training discovers consistent solutions despite a random initialization because of commonalities in the data).
Shape COSEG Results. We visualize our parsings obtained on the ‘chairs’ subset of the Shape COSEG data. scmesh shows the meshes in the dataset and scabs shows our inferred representations for these. scparse visualizes the obtained unsupervised parsing of the original mesh. scgt shows the annotated ground-truth labels and scpred shows our predictions obtained by assigning each primitive a label from the available ground-truth labels.
We show in embedVox, embedOurs1, embedOurs2 and embedOurs3 the high-resolution images corresponding to the embeddings shown in the original text.