Code release for the paper "OctFusion: Octree-based Diffusion Models for 3D Shape Generation".
Clone this repository
git clone https://github.com/octree-nn/octfusion.git
cd octfusion
Create a Conda
environment.
conda create -n octfusion python=3.11 -y && conda activate octfusion
Install PyTorch with Conda
conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia
Install other requirements.
pip3 install -r requirements.txt
We provide the pretrained models for the category-conditioned generation and sketch-conditioned generation. Please download the pretrained models from Google Drive or Baidu Netdisk and put them in saved_ckpt/diffusion-ckpt
and saved_ckpt/vae-ckpt
.
airplane
, car
, chair
, rifle
, table
.
sh scripts/run_snet_uncond.sh generate hr $category
# Example
sh scripts/run_snet_uncond.sh generate hr airplane
2. Category-conditioned generation
sh scripts/run_snet_cond.sh generate hr $category
sh scripts/run_snet_cond.sh generate hr chair
## 3. Train from scratch
### 3.1 Data Preparation
1. Download `ShapeNetCore.v1.zip` (31G) from [ShapeNet](https://shapenet.org/) and place it in `data/ShapeNet/ShapeNetCore.v1.zip`. Download `filelist` from [Google Drive](https://drive.google.com/drive/folders/140U_xzAy1MobUqurN67Fm2Y-3oWrZQ1m?usp=drive_link) or [Baidu Netdisk](https://pan.baidu.com/s/15-jp9Mwtw4soch8GAC7qgQ?pwd=rhui) and place it in `data/ShapeNet/filelist`.
2. Convert the meshes in `ShapeNetCore.v1` to signed distance fields (SDFs).
We use the same data preparation as [DualOctreeGNN](https://github.com/microsoft/DualOctreeGNN.git). Note that this process is relatively slow, it may take several days to finish converting all the meshes from ShapeNet.
```bash
python tools/repair_mesh.py --run convert_mesh_to_sdf
python tools/repair_mesh.py --run generate_dataset
VAE Training. We provide pretrained weights in saved_ckpt/vae-ckpt/vae-shapenet-depth-8.pth
.
sh scripts/run_snet_vae.sh train vae im_5
Train the first stage model. We provide pretrained weights in saved_ckpt/diffusion-ckpt/$category/df_steps-split.pth
.
sh scripts/run_snet_uncond.sh train lr $category
Load the pretrained first stage model and train the second stage. We provide pretrained weights in saved_ckpt/diffusion-ckpt/$category/df_steps-union.pth
.
sh scripts/run_snet_uncond.sh train hr $category
If you find this code helpful, please consider citing:
@article{xiong2024octfusion,
author = {Xiong, Bojun and Wei, Si-Tong and Zheng, Xin-Yang and Cao, Yan-Pei and Lian, Zhouhui and Wang, Peng-Shuai},
title = {{OctFusion}: Octree-based Diffusion Models for 3D Shape Generation},
journal = {arXiv},
year = {2024},
}
Coming soon!
This code borrows heavely from SDFusion, LAS-Diffusion, DualOctreeGNN. We thank the authors for their great work. The followings packages are required to compute the SDF: mesh2sdf.