forked from yfeng95/DECA
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
598 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,9 +41,8 @@ Thumbs.db | |
__pycache__ | ||
|
||
## deca data | ||
results | ||
*results* | ||
# *_vis.jpg | ||
|
||
## internal use | ||
cluster_scripts | ||
internal |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-69 KB
TestSamples/examples/results/id04657-PPHljWCZ53c-000565_inputs_inputs_vis.jpg
Binary file not shown.
Binary file removed
BIN
-75.4 KB
TestSamples/examples/results/id06692-Hlahj5abifM-002721_inputs_inputs_vis.jpg
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
## Install | ||
from standard_rasterize_cuda import standard_rasterize | ||
# from .rasterizer.standard_rasterize_cuda import standard_rasterize | ||
|
||
in this folder, run | ||
```python setup.py build_ext -i ``` | ||
|
||
then remember to set --rasterizer_type=standard when runing demos :) | ||
|
||
## Alg | ||
https://www.scratchapixel.com/lessons/3d-basic-rendering/rasterization-practical-implementation | ||
|
||
## Speed Comparison | ||
runtime for raterization only | ||
In PIXIE, number of faces in SMPLX: 20908 | ||
|
||
for image size = 1024 | ||
pytorch3d: 0.031s | ||
standard: 0.01s | ||
|
||
for image size = 224 | ||
pytorch3d: 0.0035s | ||
standard: 0.0014s | ||
|
||
why standard rasterizer is faster than pytorch3d? | ||
Ref: https://github.com/facebookresearch/pytorch3d/blob/master/pytorch3d/csrc/rasterize_meshes/rasterize_meshes.cu | ||
pytorch3d: for each pixel in image space (each pixel is parallel in cuda), loop through the faces, check if this pixel is in the projection bounding box of the face, then sorting faces according to z, record the face id of closest K faces. | ||
standard rasterization: for each face in mesh (each face is parallel in cuda), loop through pixels in the projection bounding box (normally a very samll number), compare z, record face id of that pixel | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# To install, run | ||
# python setup.py build_ext -i | ||
# Ref: https://github.com/pytorch/pytorch/blob/11a40410e755b1fe74efe9eaa635e7ba5712846b/test/cpp_extensions/setup.py#L62 | ||
|
||
from setuptools import setup | ||
from torch.utils.cpp_extension import BuildExtension, CUDAExtension | ||
import os | ||
|
||
# USE_NINJA = os.getenv('USE_NINJA') == '1' | ||
os.environ["CC"] = "gcc-7" | ||
os.environ["CXX"] = "gcc-7" | ||
|
||
USE_NINJA = os.getenv('USE_NINJA') == '1' | ||
|
||
setup( | ||
name='standard_rasterize_cuda', | ||
ext_modules=[ | ||
CUDAExtension('standard_rasterize_cuda', [ | ||
'standard_rasterize_cuda.cpp', | ||
'standard_rasterize_cuda_kernel.cu', | ||
]) | ||
], | ||
cmdclass={'build_ext': BuildExtension.with_options(use_ninja=USE_NINJA)} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include <torch/torch.h> | ||
#include <vector> | ||
#include <iostream> | ||
|
||
std::vector<at::Tensor> forward_rasterize_cuda( | ||
at::Tensor face_vertices, | ||
at::Tensor depth_buffer, | ||
at::Tensor triangle_buffer, | ||
at::Tensor baryw_buffer, | ||
int h, | ||
int w); | ||
|
||
std::vector<at::Tensor> standard_rasterize( | ||
at::Tensor face_vertices, | ||
at::Tensor depth_buffer, | ||
at::Tensor triangle_buffer, | ||
at::Tensor baryw_buffer, | ||
int height, int width | ||
) { | ||
return forward_rasterize_cuda(face_vertices, depth_buffer, triangle_buffer, baryw_buffer, height, width); | ||
} | ||
|
||
std::vector<at::Tensor> forward_rasterize_colors_cuda( | ||
at::Tensor face_vertices, | ||
at::Tensor face_colors, | ||
at::Tensor depth_buffer, | ||
at::Tensor triangle_buffer, | ||
at::Tensor images, | ||
int h, | ||
int w); | ||
|
||
std::vector<at::Tensor> standard_rasterize_colors( | ||
at::Tensor face_vertices, | ||
at::Tensor face_colors, | ||
at::Tensor depth_buffer, | ||
at::Tensor triangle_buffer, | ||
at::Tensor images, | ||
int height, int width | ||
) { | ||
return forward_rasterize_colors_cuda(face_vertices, face_colors, depth_buffer, triangle_buffer, images, height, width); | ||
} | ||
|
||
PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { | ||
m.def("standard_rasterize", &standard_rasterize, "RASTERIZE (CUDA)"); | ||
m.def("standard_rasterize_colors", &standard_rasterize_colors, "RASTERIZE COLORS (CUDA)"); | ||
} | ||
|
||
// TODO: backward |
Oops, something went wrong.