Skip to content

SoftRasterizer enhancement to learn 3D from RGB only #1268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
monniert opened this issue Jul 26, 2022 · 2 comments
Open

SoftRasterizer enhancement to learn 3D from RGB only #1268

monniert opened this issue Jul 26, 2022 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@monniert
Copy link

monniert commented Jul 26, 2022

🚀 Feature

Add the layered blending function of https://arxiv.org/abs/2204.10310 to make SoftRasterizer work using RGB loss only

Motivation

SoftRasterizer does not work without silhouettes (see #359, #507, #839, #840, #1004). The work (appendix A) analyses why (TLDR: the original softmax-like blending function annihilates the differentiability wrt the opacity maps - and thus wrt the vertex positions - because opacity maps appear in both the numerator and denominator of the softmax) and presents a simple modification to SoftRas based on a new layered aggregation function. The resulting Layered SoftRasterizer can successfully learn from RGB loss only.

Pitch

A version of this layered blending function is implemented here. Similar to the original softmax_rgb_blend, this function layered_rgb_blend could be placed in pytorch3d/renderer/blending.py and handled by the different shaders given a dedicated argument.

Using the resulting shader in the fit_textured_mesh.ipynb tutorial enables to learn 3D meshes using RGB only. This zip file contains the ipynb + html versions of the tutorial showing that:

1. SoftRas with silhouette works

silhouette.png

2. SoftRas with silhouette + RGB works

silhouette_rgb.png

3. SoftRas with RGB diverges

rgb.png

4. Layered SoftRas with RGB works

rgb_layered.png

@bottler bottler self-assigned this Jan 4, 2023
@bottler bottler added the enhancement New feature or request label Jan 4, 2023
@ykzzyk
Copy link

ykzzyk commented Aug 31, 2023

Hello @monniert , thank you for the amazing work! Can u elaborate more on how to layered_rgb_blend function? I am currently trying to perform camera pose estimation with only RGB channels, and I noticed they cannot converge.

@monniert
Copy link
Author

monniert commented Sep 2, 2023

Hi @ykzzyk, sure you should have a look at this file for an example on how to use this layered_rgb_blend function.

Specifically, you should redefine a pytorch3d Shader class (called LayeredShader) and reuse it inside the classical MeshRenderer class. I also noticed it do not converge for pose estimation, and in my case this fix makes the optimization for pose estimation work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants