- [2025-09-18] 🎉 Our work is accepted by NeurIPS 2025.
# Clone the repository
git clone https://github.com/WesKwong/VecFormer.git
cd VecFormer
# Create conda environment
conda create -n vecformer python=3.9 -y
conda activate vecformer
# Install torch
pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cu118
# Install torch-scatter
pip install torch-scatter -f https://data.pyg.org/whl/torch-2.5.0+cu118.html
# Install flash-attention (we recommend building from source)
pip install packaging ninja
git clone https://github.com/Dao-AILab/flash-attention.git
cd flash-attention
MAX_JOBS=64 python setup.py install # Change `MAX_JOBS` to fit your machine
cd ..
# Install other requirements
pip install -r requirements.txtIn VecFormer/, run the following command to download the FloorPlanCAD dataset:
# Install gdown
pip install gdown
# Download the FloorPlanCAD dataset and unzip it
mkdir -p datasets && cd datasets
gdown "https://drive.google.com/uc?id=1wsOQxIXjsqYzMlUpPNRjyQiMnwgVbtJG"
unzip FloorPlanCAD.zip
cd ..In VecFormer/, run the following command to preprocess the data to json for training:
export PYTHONPATH=$(pwd):$PYTHONPATH
python data/floorplancad/preprocess.py \
--input_dir=$(pwd)/datasets/FloorPlanCAD \
--output_dir=$(pwd)/datasets/FloorPlanCAD-sampled-as-line-jsons \
--dynamic_sampling \
--connect_lines \
--use_progress_barFor point-style sampling, remove the --connect_lines arg:
export PYTHONPATH=$(pwd):$PYTHONPATH
python data/floorplancad/preprocess.py \
--input_dir=$(pwd)/datasets/FloorPlanCAD \
--output_dir=$(pwd)/datasets/FloorPlanCAD-sampled-as-point-jsons \
--dynamic_sampling \
--use_progress_barTo visualize the sampled svgs, use arg --save_type=svg.
export PYTHONPATH=$(pwd):$PYTHONPATH
python data/floorplancad/preprocess.py \
--input_dir=$(pwd)/datasets/FloorPlanCAD \
--output_dir=$(pwd)/datasets/FloorPlanCAD-sampled-as-svgs \
--dynamic_sampling \
--save_type=svg# Train the model
bash scripts/train.sh
# Evaluate the model
bash scripts/test.shBy default, the script loads ${OUTPUT_DIR}/latest/checkpoint-best. You can change the resume_from_checkpoint argument to test a specific checkpoint.
Sometimes the training process will crash mid-epoch. To resume training from a checkpoint:
bash scripts/resume.shBy default, the script loads ${OUTPUT_DIR}/latest/checkpoint-best. To specify a different checkpoint, you can change the resume_from_checkpoint argument.
Note: The resume mode preserves the optimizer state and continues training from where it left off.
To continue training from a checkpoint but start a new training run (resetting optimizer state):
bash scripts/continue.shNote: Different from resume mode, the continue mode loads checkpoint weights but resets the optimizer and starts a new training session.
Our work is built with reference to the following projects: transformers, FloorPlanCAD, CADTransformer, SymPoint V2, PointTransformer V3.
Thanks for their excellent works!
Our work is licensed under the Apache License 2.0.
@article{wei2025vecformer,
title={Point or Line? Using Line-based Representation for Panoptic Symbol Spotting in CAD Drawings},
author={Wei, Xingguang and Wang, Haomin and Ye, Shenglong and Luo, Ruifeng and Zhang, Yanting and Gu, Lixin and Dai,
Jifeng and Qiao, Yu and Wang, Wenhai and Zhang, Hongjie},
journal={arXiv preprint arXiv:2505.23395},
year={2025}
}