--- pretty_name: OpenSCAD configs: - config_name: default data_files: - split: train path: dataset.parquet tags: - 3d - text - open-scad - cad - glb - code - hf - datasets size_categories: - 10K ## **OpenSCAD-Code-to-3D-HF** **OpenSCAD-Code-to-3D-HF** is a dataset built on top of [CodeCAD-HF-v2](https://huggingface.co/datasets/prithivMLmods/CodeCAD-HF-v2). It pairs natural language prompts with their corresponding OpenSCAD parametric code and references to rendered GLB (GL Transmission Format Binary) 3D model files. The dataset provides text-based descriptions, procedural 3D modeling code, and corresponding 3D assets. The GLB files are distributed separately in a ZIP archive, `glb.zip`, with **~53,172 mapped data entries** identified through file mapping between the dataset records and the archived GLB files. The OpenSCAD code-to-GLB conversion infrastructure is powered by Hugging Face and HF Jobs, enabling the conversion of OpenSCAD parametric code into rendered GLB 3D model assets. ## Dataset Statistics | Property | Value | |----------|-------| | Dataset Repository | `prithivMLmods/OpenSCAD-Code-to-3D-HF` | | Number of Mapped Data Entries | ~53,172 | | GLB Storage | `glb.zip` | | Main Dataset File | `dataset.parquet` | | Data Format | Parquet + ZIP archive | | Modalities | Text, 3D | ## Dataset Structure | Column | Type | Description | |--------|------|-------------| | `Prompt` | string | Natural language description of the 3D model | | `Code` | string | OpenSCAD parametric code that generates the model | | `3d_glb` | string | File path reference to the corresponding rendered `.glb` 3D model inside the ZIP archive | ## GLB File Mapping The GLB assets are stored in `glb.zip` rather than as individual files directly in the dataset repository. The `3d_glb` column contains references that can be mapped to the corresponding files in the archive. The dataset mapping procedure identifies matching GLB files by filename and generates the following reports: - `mapped_data.txt`: Dataset rows successfully mapped to GLB files in the ZIP archive. - `unmapped_data.txt`: Dataset rows with empty GLB references or references to files that were not found in the archive. - `zip_only_data.txt`: GLB archive filenames that are not referenced by any dataset row. A total of **53,172 mapped data entries** were identified through this process. ## Usage Install the required dependencies: ```bash pip install -U datasets pandas pyarrow ``` Load the dataset: ```python from datasets import load_dataset ds = load_dataset( "prithivMLmods/OpenSCAD-Code-to-3D-HF", data_files="dataset.parquet" ) print(ds["train"][0]) ``` To access the GLB assets, download `glb.zip` from the dataset repository and extract the archive. The `3d_glb` references can then be matched to the extracted files using the mapping procedure. ## Dataset and GLB File Mapping ``` pip install -U huggingface_hub ``` ```py import os import subprocess import pandas as pd from collections import defaultdict from huggingface_hub import hf_hub_download REPO_ID = "prithivMLmods/OpenSCAD-Code-to-3D-HF" WORK_DIR = "openscad_check" EXTRACT = os.path.join(WORK_DIR, "extracted") MAPPED = "mapped_data.txt" UNMAPPED = "unmapped_data.txt" ZIP_ONLY = "zip_only_data.txt" os.makedirs(EXTRACT, exist_ok=True) # 1. Download parquet_path = hf_hub_download(repo_id=REPO_ID, filename="dataset.parquet", repo_type="dataset", local_dir=WORK_DIR) zip_path = hf_hub_download(repo_id=REPO_ID, filename="glb.zip", repo_type="dataset", local_dir=WORK_DIR) # 2. Unzip using native system unzip command print(f"Extracting {zip_path} via system unzip...") try: subprocess.run(["unzip", "-o", "-q", zip_path, "-d", EXTRACT], check=True) print("Extraction complete.") except subprocess.CalledProcessError as e: print(f"System unzip failed: {e}") # 3. Index every file in the extracted folder by FILE NAME zip_index = defaultdict(list) for root, _, files in os.walk(EXTRACT): for fn in files: rel = os.path.relpath(os.path.join(root, fn), EXTRACT).replace("\\", "/") zip_index[fn].append(rel) total_zip_files = sum(len(v) for v in zip_index.values()) print(f"Files in zip folder : {total_zip_files}") print(f"Unique file names : {len(zip_index)}") # 4. Load parquet df = pd.read_parquet(parquet_path) total_rows = len(df) print(f"Rows in parquet : {total_rows}") print(f"Columns : {list(df.columns)}") # 5. Map 3d_glb file names -> zip file names mapped, unmapped = [], [] empty_count = 0 # 3d_glb is null / empty missing_count = 0 # 3d_glb has a value but file not found in zip used_names = set() glb_name_counts = defaultdict(int) for idx, val in df["3d_glb"].items(): if val is None or (isinstance(val, float) and pd.isna(val)) or str(val).strip() == "": unmapped.append((idx, "")) empty_count += 1 continue col_path = str(val).strip().replace("\\", "/") fname = os.path.basename(col_path) glb_name_counts[fname] += 1 if fname in zip_index: used_names.add(fname) mapped.append((idx, col_path, ", ".join(zip_index[fname]))) else: unmapped.append((idx, col_path)) missing_count += 1 # 6. Files in zip that no row points to zip_only = sorted(set(zip_index.keys()) - used_names) # 7. Write outputs with open(MAPPED, "w", encoding="utf-8") as f: for idx, col_path, zip_rel in mapped: f.write(f"{idx}\t{col_path}\t{zip_rel}\n") with open(UNMAPPED, "w", encoding="utf-8") as f: for idx, col_path in unmapped: f.write(f"{idx}\t{col_path}\n") with open(ZIP_ONLY, "w", encoding="utf-8") as f: for fn in zip_only: f.write(f"{fn}\n") # 8. Summary mapped_n = len(mapped) unmapped_n = len(unmapped) non_empty = total_rows - empty_count dup_rows = sum(c for c in glb_name_counts.values() if c > 1) dup_names = sum(1 for c in glb_name_counts.values() if c > 1) def pct(n, d): return f"{(n / d * 100):.2f}%" if d else "n/a" print("\n===== SUMMARY =====") print(f"Total rows : {total_rows}") print(f"MAPPED (file found in zip) : {mapped_n} ({pct(mapped_n, total_rows)})") print(f"UNMAPPED (total) : {unmapped_n} ({pct(unmapped_n, total_rows)})") print(f" - 3d_glb empty / null : {empty_count}") print(f" - file name not in zip : {missing_count}") print(f"Non-empty 3d_glb rows : {non_empty}") print(f"Mapped among non-empty rows : {mapped_n}/{non_empty} ({pct(mapped_n, non_empty)})") print(f"Unique zip files used : {len(used_names)}") print(f"Zip files not in any row : {len(zip_only)}") print(f"Rows sharing a GLB file name : {dup_rows} (across {dup_names} file names)") print(f"\nSaved -> {MAPPED} (row_index | 3d_glb value | path in zip folder)") print(f"Saved -> {UNMAPPED} (row_index | 3d_glb value)") print(f"Saved -> {ZIP_ONLY} (file names present in zip but not referenced)") ``` ## Source Dataset This dataset is derived from [CodeCAD-HF-v2](https://huggingface.co/datasets/prithivMLmods/CodeCAD-HF-v2). ## License Please refer to the original [CodeCAD paper](https://dl.acm.org/doi/10.1145/3770855.3817592) for source data license terms.