MCPcopy Index your code
hub / github.com/ferdous-alam/GenCAD

github.com/ferdous-alam/GenCAD @main sqlite

repository ↗ · DeepWiki ↗
559 symbols 1,536 edges 43 files 126 documented · 23%
README

GenCAD

Image-conditioned Computer-Aided Design Generation with Transformer-based Contrastive Representation and Diffusion Priors


GenCAD Demo


📁 Dataset

Download from here and place it in the data/ directory.


📦 Pretrained Models

Download from here and place them in data/ckpt/.


🔧 Setup Options

First download the checkpoints and the dataset and put them in their respective directories.

Option 1: Docker (Recommended)

  1. Clone the repo: bash git clone https://github.com/ferdous-alam/GenCAD cd GenCAD

  2. Build the Docker image: bash docker build -t gencad:latest .

  3. Run a script, for example training CSR: bash docker run -it gencad:latest conda run -n gencad_env python train_gencad.py csr -name test -gpu 0

  4. For headless visualization (inference):

First, enter the container with GPU access and mount the appropriate folders:

bash docker run --gpus all \ -v $(pwd)/data/images:/app/data/images \ -v $(pwd)/assets:/app/assets \ -v $(pwd)/results:/app/results \ -it gencad:latest /bin/bash

Then inside the container, run:

bash xvfb-run --server-args="-screen 0 2048x2048x24" python inference_gencad.py -image_path data/images -export_img


Option 2: Manual (conda + pip)

  1. Create and activate a virtual environment with GPU support: ```bash conda create -n gencad_env python=3.10 -y conda activate gencad_env

  2. Install pythonocc-core using conda: bash conda install -c conda-forge pythonocc-core=7.9.0

  3. Install the rest via pip: bash pip install -r requirements.txt

  4. Now run training or inference: bash python train_gencad.py csr -name test -gpu 0


🚀 Training

CSR Model

python train_gencad.py csr -name test -gpu 0

Optional checkpoint:

python train_gencad.py csr -name test -gpu 0 -ckpt "model/ckpt/ae_ckpt_epoch1000.pth"

CCIP Model

python train_gencad.py ccip -name test -gpu 0 -cad_ckpt "model/ckpt/ae_ckpt_epoch1000.pth"

Diffusion Prior

python train_gencad.py dp -name test -gpu 0 -cad_emb 'data/embeddings/cad_embeddings.h5' -img_emb 'data/embeddings/sketch_embeddings.h5'

🧪 Inference

For headless systems (e.g. servers):

xvfb-run python inference_gencad.py

🖼 STL Visualization

Convert STL to PNG:

python stl2img.py -src path/to/stl/files -dst path/to/save/images

📊 Evaluation

Coming soon.

Core symbols most depended-on inside this repo

load
called by 22
model/cond_ldm.py
extract
called by 15
model/cond_ldm.py
step
called by 13
utils/scheduler.py
angle_from_vector_to_x
called by 9
cadlib/math_utils.py
update
called by 9
utils/model_utils.py
from_dict
called by 7
cadlib/curves.py
sample
called by 7
model/cond_ldm.py
normalize
called by 6
cadlib/sketch.py

Shape

Method 351
Function 126
Class 82

Languages

Python100%

Modules by API surface

cadlib/curves.py62 symbols
model/ccip_model.py61 symbols
utils/cad_dataset.py54 symbols
model/cond_ldm.py41 symbols
model/denoising_net.py35 symbols
cadlib/sketch.py35 symbols
cadlib/extrude.py34 symbols
model/mlp_prior.py33 symbols
model/autoencoder.py28 symbols
utils/model_utils.py18 symbols
model/image_encoder.py16 symbols
trainer/ldm_trainer.py13 symbols

For agents

$ claude mcp add GenCAD \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact