GenCAD: Image-Conditioned Computer-Aided Design Generation with Transformer-Based Contrastive Representation and Diffusion Priors

Md Ferdous Alam, Faez Ahmed

Abstract

GenCAD is a novel generative framework designed to bridge the gap between 2D visual inputs and editable 3D CAD models. By representing CAD commands as a sequence of tokens, the model utilizes a transformer-based architecture combined with contrastive learning and latent diffusion priors. This approach enables the transformation of sketches or images into parametric Boundary Representations (B-reps), facilitating professional engineering workflows. GenCAD demonstrates state-of-the-art performance in conditional generation and achieves a 15x improvement in CAD model retrieval accuracy compared to standard image-based methods.

Introduction

In engineering and manufacturing, 3D models are typically represented as Boundary Representations (B-reps). Unlike meshes or point clouds, B-reps store the parametric history—such as lines, arcs, and extrusions—required for iterative design in professional CAD software. However, creating these models manually is time-consuming and requires significant expertise.

The GenCAD pipeline converts 2D sketches or images into editable CAD programs and final 3D B-rep models.

GenCAD addresses the challenge of "unconditional" generation by allowing users to provide visual intent via images or sketches. It treats CAD modeling as a sequence-to-sequence problem, translating visual features into the "language" of engineering commands.

Methodology

The GenCAD framework consists of a multi-stage training and inference pipeline designed to align visual and geometric latent spaces.

The GenCAD architecture: Step 1 involves command sequence reconstruction (CSR); Step 2 performs contrastive CAD-image pre-training (CCIP); the final inference uses a diffusion prior to map image latents to CAD latents.

1. Command Sequence Reconstruction (CSR)

The model first learns a robust latent representation ($z_{CAD}$) of CAD command sequences. Using a transformer-based encoder-decoder architecture, it treats geometric operations (e.g., "draw line," "extrude") as discrete tokens, similar to natural language processing.

2. Contrastive CAD-Image Pre-training (CCIP)

To enable image-conditioned generation, GenCAD aligns the CAD latent space with a visual latent space. Inspired by the CLIP architecture, a ResNet-18 image encoder and the CAD transformer encoder are trained using contrastive loss. This ensures that an image of a part and its corresponding CAD command sequence are mapped to similar regions in the latent space.

3. CAD Diffusion Prior (CDP)

A latent diffusion model serves as the bridge between visual input and geometric output. The CDP predicts the CAD latent ($z_{CAD}$) given an image latent ($z_{img}$). This diffusion-based approach effectively manages the "one-to-many" ambiguity, where a single 2D sketch could correspond to multiple valid 3D interpretations.

4. Decoding and Generation

During inference, the predicted $z_{CAD}$ is passed through a frozen transformer decoder to produce a sequence of parametric commands. These commands are then processed by a geometry kernel to generate the final 3D B-rep model.

Experimental Results

The authors evaluated GenCAD using the DeepCAD dataset, which contains approximately 178,000 CAD designs. Key findings include:

  • Reconstruction Accuracy: GenCAD achieved a command accuracy of 99.51%, outperforming previous benchmarks like DeepCAD, particularly on complex sequences.
  • Retrieval Performance: The contrastive pre-training allowed for highly accurate multimodal retrieval. GenCAD was 15x more accurate than standard ResNet-18 image-to-image search, identifying correct CAD models with ~91% accuracy in a batch of 128.
  • Generative Quality: The model achieved a Fréchet Inception Distance (FID) of 0.13 for image-conditional generation, significantly lower than unconditional (0.22) or GAN-based (0.87) alternatives.

Conclusion and Future Work

GenCAD demonstrates the power of combining transformer-based sequence modeling with diffusion priors for engineering design. While currently limited to "sketch and extrude" operations, future work aims to expand the command vocabulary to include complex features like revolves and fillets. Additionally, integrating a closed-loop geometry kernel for real-time validity checks could further enhance the manufacturability of AI-generated designs.

Summary updated

BibTeX
@article{alam2025gencad,
  author = {Md Ferdous Alam and Faez Ahmed},
  title = {{GenCAD: Image-Conditioned Computer-Aided Design Generation with Transformer-Based Contrastive Representation and Diffusion Priors}},
  journal = {Trans. Mach. Learn. Res.},
  year = {2025},
}
Figure