Skip to content

Commit

Permalink
Use CUDA instead OpenGL for nvdiffrast by default to simplify install…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
ShenhanQian committed Oct 29, 2024
1 parent d3c2e82 commit 4395551
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 17 deletions.
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,11 @@ pip install -e .
```

> [!NOTE]
> - We use an adjusted version of [nvdiffrast](https://github.com/ShenhanQian/nvdiffrast/tree/backface-culling) for backface-culling. To completely remove previous versions and compiled pytorch extensions, you can execute
>
> ```shell
> pip uninstall nvdiffrast
> rm -r ~/.cache/torch_extensions/*/nvdiffrast*
> ```
>
> - We use an adjusted version of [nvdiffrast](https://github.com/ShenhanQian/nvdiffrast/tree/backface-culling) for backface-culling. If you have other versions installed before, you can reinstall as follows:
> ```shell
> pip install nvdiffrast@git+https://github.com/ShenhanQian/nvdiffrast@backface-culling --force-reinstall
> rm -r ~/.cache/torch_extensions/*/nvdiffrast*
> ```
> - We use [STAR](https://github.com/ShenhanQian/STAR/) for landmark detection by default. Alterntively, [face-alignment](https://github.com/1adrianb/face-alignment) is faster but less accurate.
## Download
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ include = ["vhap/**/*.py"]

[project]
name = "VHAP"
version = "0.0.1"
version = "0.0.2"
requires-python = ">=3.9"
dependencies = [
"tyro",
Expand Down
2 changes: 1 addition & 1 deletion vhap/config/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class ModelConfig(Config):
class RenderConfig(Config):
backend: Literal['nvdiffrast', 'pytorch3d'] = 'nvdiffrast'
"""The rendering backend"""
use_opengl: bool = True
use_opengl: bool = False
"""Use OpenGL for NVDiffRast"""
background_train: Literal['white', 'black', 'target'] = 'target'
"""Background color/image for training"""
Expand Down
2 changes: 1 addition & 1 deletion vhap/export_as_nerf_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ def __init__(self, cfg_model: ModelConfig, tgt_folder, background_color: str) ->

self.flame_model = FlameHead(cfg_model.n_shape, cfg_model.n_expr, add_teeth=True)

self.mesh_renderer = NVDiffRenderer(use_opengl=True)
self.mesh_renderer = NVDiffRenderer(use_opengl=False)

@torch.no_grad()
def write(self):
Expand Down
4 changes: 2 additions & 2 deletions vhap/flame_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Config:
"""default GUI camera fovy"""
background_color: tuple[float] = (1., 1., 1.)
"""default GUI background color"""
use_opengl: bool = True
use_opengl: bool = False
"""use OpenGL or CUDA rasterizer"""


Expand Down Expand Up @@ -64,7 +64,7 @@ def __init__(self, cfg: Config):
self.drag_button = None

# rendering settings
self.mesh_renderer = NVDiffRenderer(use_opengl=False, lighting_space='camera')
self.mesh_renderer = NVDiffRenderer(use_opengl=cfg.use_opengl, lighting_space='camera')

self.define_gui()

Expand Down
4 changes: 2 additions & 2 deletions vhap/flame_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Config:
"""default GUI camera fovy"""
background_color: tuple[float] = (1., 1., 1.)
"""default GUI background color"""
use_opengl: bool = True
use_opengl: bool = False
"""use OpenGL or CUDA rasterizer"""


Expand All @@ -56,7 +56,7 @@ def __init__(self, cfg: Config):
self.drag_button = None

# rendering settings
self.mesh_renderer = NVDiffRenderer(use_opengl=False, lighting_space='camera')
self.mesh_renderer = NVDiffRenderer(use_opengl=cfg.use_opengl, lighting_space='camera')
self.num_timesteps = 1
self.timestep = 0

Expand Down
2 changes: 1 addition & 1 deletion vhap/generate_flame_uvmask.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


def main(
use_opengl: bool = True,
use_opengl: bool = False,
device: Literal['cuda', 'cpu'] = 'cuda',
):
n_shape = 300
Expand Down
2 changes: 1 addition & 1 deletion vhap/util/render_nvdiffrast.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def get_SH_shading(normals, sh_coefficients, sh_const):
class NVDiffRenderer(torch.nn.Module):
def __init__(
self,
use_opengl: bool = True,
use_opengl: bool = False,
lighting_type: Literal['constant', 'front', 'front-range', 'SH'] = 'front',
lighting_space: Literal['camera', 'world'] = 'world',
disturb_rate_fg: Optional[float] = 0.5,
Expand Down
2 changes: 1 addition & 1 deletion vhap/util/render_uvmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def render_uvmap_texmap(glctx, pos, pos_idx, verts_uv, faces_uv, tex, resolution

def main(
use_texmap: bool = False,
use_opengl: bool = True,
use_opengl: bool = False,
):
n_shape = 300
n_expr = 100
Expand Down

0 comments on commit 4395551

Please sign in to comment.