model_mlp_med.pt)This repo hosts the trained loop-filtering model used by CADFit, our framework for precise mesh-to-CAD program generation via hybrid optimization (ICML 2026).
model_mlp_med.pt — 3-layer MLP classifier weights + checkpoint metadata (≈ 8.7 MB)normalization.npz — input feature mean/std for standardization (≈ 33 KB)CADFit recovers complex, editable CAD construction sequences from watertight meshes by incrementally fitting and validating parametric operations using geometric feedback. Instead of predicting a program in one forward pass, CADFit formulates reconstruction as an explicit IoU-driven optimization over executable CAD programs, supporting a rich operator set (extrusions, revolutions, fillets, chamfers) composed with Boolean union and cut.
Pipeline:
extract_planar_contours.py, extract_sketches.py).The result is a clean, editable, executable CAD program (Python via CadQuery).
model_mlp_med.pt is a 3-layer MLP that takes:
Total input: 4 × 1024 + 17 = 4113-d. Standardized with (mu, sd) from normalization.npz, then passed through:
Linear(4113 → h₁) → GELU → Dropout
Linear(h₁ → h₂) → GELU → Dropout
Linear(h₂ → 1) → sigmoid
(h₁, h₂, and dropout p are stored in ckpt["arch"].)
The output sigmoid probability ≥ threshold (default 0.425, also stored in the checkpoint) is the keep decision.
In CADFit the filter slots in between loop extraction and translation/revolve analysis, shrinking the candidate search space and keeping the greedy reconstruction focused on loops that have a chance of corresponding to a real CAD sketch primitive.
# Install CADFit and the optional filter dependencies
pip install -r requirements.txt
pip install torch pyvista Pillow huggingface-hub
# Headless Linux only — install Xvfb for off-screen PyVista rendering:
sudo apt-get install xvfb
# Run the pipeline with the filter enabled.
# Model weights auto-download from this repo on first call.
python run_pipeline.py mesh_folder/ --output-folder runs/ --filter-sketches
from huggingface_hub import hf_hub_download
from filter_loops import filter_jsons_inplace
# Filter a loops_split.json in place; weights cached after first call.
filter_jsons_inplace(
stl_path="mesh.stl",
json_paths=["loops_split.json"],
threshold=0.425,
)
from huggingface_hub import hf_hub_download
mlp = hf_hub_download("ghadinehme/CADFit", "model_mlp_med.pt")
norm = hf_hub_download("ghadinehme/CADFit", "normalization.npz")
@article{nehme2026cadfit,
title = {CADFit: Precise Mesh-to-CAD Program Generation with Hybrid Optimization},
author = {Nehme, Ghadi and Whalen, Eamon and Ahmed, Faez},
journal = {arXiv preprint arXiv:2605.01171},
year = {2026}
}
Released under the Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0) license. Free for academic and research use; commercial licensing inquiries to ghadi@mit.edu.
Questions, feedback, or collaboration: ghadi@mit.edu.
4 commits
model_mlp_med.pt)This repo hosts the trained loop-filtering model used by CADFit, our framework for precise mesh-to-CAD program generation via hybrid optimization (ICML 2026).
model_mlp_med.pt — 3-layer MLP classifier weights + checkpoint metadata (≈ 8.7 MB)normalization.npz — input feature mean/std for standardization (≈ 33 KB)CADFit recovers complex, editable CAD construction sequences from watertight meshes by incrementally fitting and validating parametric operations using geometric feedback. Instead of predicting a program in one forward pass, CADFit formulates reconstruction as an explicit IoU-driven optimization over executable CAD programs, supporting a rich operator set (extrusions, revolutions, fillets, chamfers) composed with Boolean union and cut.
Pipeline:
extract_planar_contours.py, extract_sketches.py).The result is a clean, editable, executable CAD program (Python via CadQuery).
model_mlp_med.pt is a 3-layer MLP that takes:
Total input: 4 × 1024 + 17 = 4113-d. Standardized with (mu, sd) from normalization.npz, then passed through:
Linear(4113 → h₁) → GELU → Dropout
Linear(h₁ → h₂) → GELU → Dropout
Linear(h₂ → 1) → sigmoid
(h₁, h₂, and dropout p are stored in ckpt["arch"].)
The output sigmoid probability ≥ threshold (default 0.425, also stored in the checkpoint) is the keep decision.
In CADFit the filter slots in between loop extraction and translation/revolve analysis, shrinking the candidate search space and keeping the greedy reconstruction focused on loops that have a chance of corresponding to a real CAD sketch primitive.
# Install CADFit and the optional filter dependencies
pip install -r requirements.txt
pip install torch pyvista Pillow huggingface-hub
# Headless Linux only — install Xvfb for off-screen PyVista rendering:
sudo apt-get install xvfb
# Run the pipeline with the filter enabled.
# Model weights auto-download from this repo on first call.
python run_pipeline.py mesh_folder/ --output-folder runs/ --filter-sketches
from huggingface_hub import hf_hub_download
from filter_loops import filter_jsons_inplace
# Filter a loops_split.json in place; weights cached after first call.
filter_jsons_inplace(
stl_path="mesh.stl",
json_paths=["loops_split.json"],
threshold=0.425,
)
from huggingface_hub import hf_hub_download
mlp = hf_hub_download("ghadinehme/CADFit", "model_mlp_med.pt")
norm = hf_hub_download("ghadinehme/CADFit", "normalization.npz")
@article{nehme2026cadfit,
title = {CADFit: Precise Mesh-to-CAD Program Generation with Hybrid Optimization},
author = {Nehme, Ghadi and Whalen, Eamon and Ahmed, Faez},
journal = {arXiv preprint arXiv:2605.01171},
year = {2026}
}
Released under the Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0) license. Free for academic and research use; commercial licensing inquiries to ghadi@mit.edu.
Questions, feedback, or collaboration: ghadi@mit.edu.
4 commits