Paper: Liu Y T, Guo Y C, Voleti V, et al. threestudio: a modular framework for diffusion-guided 3D generation[J].
Introduction:
Code: https://github.com/threestudio-project/threestudio
一. threestudio 简介
threestudio 是一个用于生成三维模型 (3D content generation) 的框架,支持文本提示、单一图像或少量图像等多种模态,核心就是将二维中的 text-to-image 模型提升到三维。threestudio 集成了多种前沿技术,包括 ProlificDreamer、DreamFusion、Magic3D、SJC、Latent-NeRF、Fantasia3D、TextMesh、Zero-1-to-3、Magic123、HiFA、InstructNeRF2NeRF、Control4D,用于生成和编辑高质量的 3D 内容。
threestudio-3dgs 是基于 threestudio 的一个扩展,用于 3D GS 的生成式任务,并且支持与其他扩展如 MVDream 和 Zero-123 集成,以增强三维模型的生成能力。
二. threestudio 复现
- 平台:AutoDL
- 显卡:RTX 4090 24G
- 镜像:PyTorch 2.0.0、Python 3.8(ubuntu20.04)、Cuda 11.8
- 源码:https://github.com/threestudio-project/threestudio
-
克隆仓库后安装虚拟环境:threestudio 使用的是 virtualenv 而非 conda,因此需要先安装 virtualenv:
pip install virtualenv
。然后创建虚拟环境并激活:. venv/bin/activate
,虚拟环境venv
位于 threestudio 文件夹下;
-
按照 README 安装 torch2.0.0+cu118、ninja 和相关依赖后,就可以使用 DreamFusion 创建 pancake bunny 模型:
-
导出 mesh 的过程中,疑似缺少
EGL/egl.h
头文件:
在命令行中增加参数system.exporter.context_type=cuda
即可 1:python launch.py --config outputs/dreamfusion-sd/a_zoomed_out_DSLR_photo_of_a_baby_bunny_sitting_on_top_of_a_stack_of_pancakes@20240523-190945/configs/parsed.yaml --export --gpu 0 resume=outputs/dreamfusion-sd/a_zoomed_out_DSLR_photo_of_a_baby_bunny_sitting_on_top_of_a_stack_of_pancakes@20240523-190945/ckpts/last.ckpt system.export er_type=mesh-exporter system.exporter.context_type=cuda
;
DreamFusion 创建的 pancake bunny 模型如下:
threestudio-DreamFusion生成结果
三. threestudio-3dgs 复现
- 平台:AutoDL
- 显卡:RTX 4090 24G
- 镜像:PyTorch 2.0.0、Python 3.8(ubuntu20.04)、Cuda 11.8
- 源码:https://github.com/DSaurus/threestudio-3dgs
- 复现 threestudio-3dgs 需要先安装 threestudio 环境,然后按照 README 进入 custom 文件夹,克隆 threestudio-3dgs 仓库并安装子模块即可。此外,还需要安装一些额外的包:
pip install mediapipe plyfile pymeshlab
; - 使用 GS 创建一个汉堡模型,然后可以导出 mesh:
python launch.py --config outputs/gs-sds-generation/a_delicious_hamburger@20240523-204741/configs/parsed.yaml --export --gpu 0 system.prompt_processor.prompt="a delicious hamburger" resume=outputs/gs-sds-generation/a_delicious_hamburger@20240523-204741/ckpts/last.ckpt
。导出过程中遇到 xFormers 与 PyTorch、CUDA 版本不匹配的问题,需要进行更新:pip3 install -U xformers --index-url https://download.pytorch.org/whl/cu118
;
然后又遇到找不到gaussian_3d_coeff
模块的问题:
这里不能简单地在gaussian_io.py
中添加from .gaussian_base import gaussian_3d_coeff
,因为gaussian_base.py
中有from .gaussian_io import GaussianIO
,这样会出现 循环导入!
因此需要将gaussian_base.py
中的gaussian_3d_coeff
函数放入gaussian_io.py
中 2,然后就能够成功导出 mesh:
3D GS 创建的汉堡模型如下:
threestudio-3dgs生成结果
四. 常见操作
1. 取消 save_code
功能
threestudio/utils/callbacks.py
中 CodeSnapshotCallback
类 save_code_snapshot()
函数注释掉即可。