Introduction
Visual programs—scripts that generate geometry—are the gold standard for 3D modeling due to their interpretability, editability, and compactness. However, creating a robust library of functions for these programs typically requires human experts to manually define a Domain-Specific Language (DSL). ShapeCoder introduces a novel system that automatically discovers high-level, reusable "code" abstractions from datasets of unstructured 3D primitives. By combining a bottom-up neural recognition network with a specialized program-refactoring engine based on e-graphs, it transforms "soups" of geometric blocks into compact, interpretable, and editable visual programs.
The Challenge of Automated Library Learning
Existing automated methods for "library learning," such as DreamCoder, often struggle with visual data for two primary reasons:
- Parametric Complexity: Visual shapes involve complex mathematical relationships (e.g., a support bar's length being relative to a table's width) rather than just discrete structure.
- Unstructured Input: Real-world geometric data often consists of unordered collections of parts. Previous methods frequently required perfectly ordered data to identify recurring patterns.
ShapeCoder addresses these issues by learning the underlying logic of 3D parts without human guidance, bridging the gap between raw geometry and structured code.
Methodology: The ShapeCoder Loop
ShapeCoder operates through an iterative four-phase loop:
- Dream Phase: The system generates random programs from its current library to create synthetic shapes.
- Wake Phase: A Transformer-based recognition network is trained on these "dreams." It employs a bottom-up approach, learning to identify sub-problems (parts of a shape) rather than predicting an entire program at once, which enhances its ability to handle complex scenes.
- Proposal Phase: The system analyzes programs generated during the Wake phase to identify recurring structural and parametric patterns suitable for new library functions.
- Integration Phase: This phase utilizes e-graphs (Equality Graphs) to refactor the dataset's programs. To manage the state-space explosion inherent in mathematical relationships, the authors introduced a conditional rewrite scheme. This scheme lazily evaluates parametric relationships (like symmetry or proportions) only after a structural match is found, making the search computationally tractable.
Key Insights
- Abstraction as Compression: Following Occam’s Razor, a "good" abstraction is defined as one that minimizes the total description length of the dataset (Library + Programs).
- Lazy Parametric Matching: By decoupling the structure of a part from its parameters, ShapeCoder discovers complex proportions without getting bogged down in infinite mathematical possibilities.
- Bottom-Up Recognition: Training the neural network to find partial solutions makes the system resilient to "curriculum" issues, allowing it to find small patterns in complex shapes from the start.
Results and Evaluation
ShapeCoder was evaluated on PartNet (3D cuboid decompositions), unsupervised primitives from ShapeNet, and a 2D toy dataset.
- Superior Compression: ShapeCoder significantly outperformed previous state-of-the-art methods like ShapeMOD. In the "Chair" category, it reduced program complexity from 146.0 to 63.6.
- Generalization: Abstractions learned on one set of shapes successfully generalized to unseen data, effectively "compressing" new instances using discovered concepts.
- Downstream Benefits: Generative models trained on ShapeCoder’s abstracted programs produced more realistic shapes (improving Frechet Distance from 17.1 to 13.8). Furthermore, programs using these abstractions are significantly easier to edit; when parameters are perturbed, abstracted programs maintain their structural integrity better than raw primitive lists.
Limitations and Future Directions
While successful, the system sometimes produces redundant abstractions for the same semantic concept. Additionally, for extremely complex inputs, e-graph saturation remains a challenge. Future work may involve "executing" programs to compare geometric outputs directly and extending the framework beyond cuboids to Constructive Solid Geometry (CSG) or 2D sketches.
Summary updated