IC Layout Skeleton Generation (prototype)
This repo provides a prototype pipeline to handle strictly-Manhattan binary IC layout images: extract skeletons, vectorize skeletons into Manhattan polylines, train a skeleton-generation model, and expand skeletons back to images.
Project Structure
scripts/: Core processing scripts.skeleton_extract.py: Binarize & extract skeleton PNG.vectorize_skeleton.py: Trace skeleton PNG into JSON polylines.expand_skeleton.py: Rasterize polyline JSON back to a PNG.
models/: PyTorch models (e.g.,SkeletonVAE).train/: Training scripts.datasets/: Dataset building helpers.out/: Output directory for generated data and logs (ignored by git).
Setup
This project uses uv for dependency management.
-
Install uv:
curl -LsSf https://astral.sh/uv/install.sh | sh -
Install dependencies:
uv sync
Usage
1. Prepare Data
Ensure your dataset is available. For example, link your data folder:
ln -s ~/Documents/data/ICCAD2019/img ./ICCAD2019/img
(Note: The workspace already contains a link to ICCAD2019 if configured).
2. Run the Pipeline
You can run individual scripts using uv run.
Extract Skeleton:
uv run scripts/skeleton_extract.py path/to/image.png out/result_dir --denoise 3
Vectorize Skeleton:
uv run scripts/vectorize_skeleton.py out/result_dir/image_sk.png out/result_dir/image_vec.json
Expand (Reconstruct) Image:
uv run scripts/expand_skeleton.py out/result_dir/image_vec.json out/result_dir/image_recon.png
3. Build Dataset
Batch process a folder of images:
uv run datasets/build_skeleton_dataset.py ICCAD2019/img out/dataset_processed
4. Train Model
Train the VAE on the processed skeletons:
uv run train/train_skeleton_vae.py out/dataset_processed --epochs 20 --batch 16
Debugging
A debug script is provided to run the full pipeline on a few random images from the dataset:
uv run debug_pipeline.py
Results will be in out/debug.