1from transformers import Qwen3VLForConditionalGeneration, AutoProcessor
2from datasets import load_dataset
3from PIL import Image
4import io
5
6
7model_name = "ADSKAILab/Zero-To-CAD-Qwen3-VL-2B"
8model = Qwen3VLForConditionalGeneration.from_pretrained(model_name, torch_dtype="auto", device_map="auto")
9processor = AutoProcessor.from_pretrained(model_name)
10
11# Load 8 rendered views from the dataset
12ds = load_dataset("ADSKAILab/Zero-To-CAD-1m", split="train", streaming=True)
13sample = next(iter(ds))
14views = [
15 Image.open(io.BytesIO(sample[f"image_{i}"])) if isinstance(sample[f"image_{i}"], bytes)
16 else sample[f"image_{i}"]
17 for i in range(8)
18]
19
20# Or load 8 views from local files:
21# views = [Image.open(f"view_{i}.png") for i in range(8)]
22
23messages = [
24 {
25 "role": "system",
26 "content": "You are a CAD code assistant. Given multiple rendered views of a 3D shape, generate clean, well-structured CadQuery Python code that accurately reproduces the geometry."
27 },
28 {
29 "role": "user",
30 "content": [
31 *[{"type": "image", "image": view} for view in views],
32 {"type": "text", "text": "Generate CadQuery code for this shape."}
33 ]
34 }
35]
36
37text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
38inputs = processor(text=text, images=views, return_tensors="pt").to(model.device)
39
40output_ids = model.generate(**inputs, max_new_tokens=4096)
41output_text = processor.batch_decode(output_ids[:, inputs.input_ids.shape[1]:], skip_special_tokens=True)[0]
42
43print(output_text)
1import cadquery as cq
2
3exec(output_text)
4# `result` contains the reconstructed CadQuery solid
5
6# Export
7cq.exporters.export(result, "output.step")
8cq.exporters.export(result, "output.stl")
1@misc{ataei2026zerotocadagenticsynthesisinterpretable,
2 title={Zero-to-CAD: Agentic Synthesis of Interpretable CAD Programs at Million-Scale Without Real Data},
3 author={Mohammadmehdi Ataei and Farzaneh Askari and Kamal Rahimi Malekshan and Pradeep Kumar Jayaraman},
4 year={2026},
5 eprint={2604.24479},
6 archivePrefix={arXiv},
7 primaryClass={cs.CV},
8 url={https://arxiv.org/abs/2604.24479}
9}
This model is released under the
Apache License 2.0.