-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Render without background #542
Comments
too may lines need modification.
I have another idea: |
I think I may have figured out a rather hacky way to do it, but here goes: rasterize_points.cu torch::Tensor out_color = torch::full({NUM_CHANNELS + 1, H, W}, 0.0, float_opts); forward.cu float C[CHANNELS + 1] = { 0 }; line 354: for (int ch = 0; ch < CHANNELS; ch++)
C[ch] += features[collected_id[j] * CHANNELS + ch] * alpha * T;
C[CHANNELS] += alpha * T; line 372: for (int ch = 0; ch < CHANNELS + 1; ch++)
out_color[ch * H * W + pix_id] = C[ch]; backward.cu float accum_alpha = 0;
float accum_rec[C] = { 0 };
float dL_dpixel[C+1];
if (inside)
for (int i = 0; i < C+1 + 1; i++)
dL_dpixel[i] = dL_dpixels[i * H * W + pix_id];
float last_alpha = 0;
float last_alpha_color = 0;
float last_color[C] = { 0 }; line 527: accum_alpha = last_alpha * last_alpha_color + (1.f - last_alpha) * accum_alpha;
last_alpha_color = 1;
dL_dalpha += (1 - accum_alpha) * dL_dpixel[C];
dL_dalpha *= T;
// Update last alpha (to be used in the next iteration)
last_alpha = alpha; line 536: //float bg_dot_dpixel = 0;
// for (int i = 0; i < C; i++)
// bg_dot_dpixel += bg_color[i] * dL_dpixel[i];
// dL_dalpha += (-T_final / (1.f - alpha)) * bg_dot_dpixel;
// dL_dalpha += alpha * dL_dpixel[C + 1]; In essence, I am treating the 4th channel like another colour channel. Except the "feature" colour from the gaussian is constant (1.f). Allows me to copy the code used to compute the existing colour channels. |
It's exported inside imgBuffer, I will do some testing to figure out how to read it. |
Could be possibly extracted as:
In diff_gaussian_resterization/init.py at line 99. I still have to verify if this works. |
Ok, its working well. Here is the fork if you want it: |
I tried this fork and it worked great. But I made a mistake: I assumed that gradients with respect to "accumulation" would flow correctly, but that was not the case since backward wasn't implemented -- so I got, silently, the wrong gradients. Would it be helpful to add an error/warning or implement the backward pass? |
how it is rendering without background? please explain. |
If you set the background colour to black then you get rgb image and accumulation - basically rgba image |
@jkulhanek @pknmax |
Is there a better solution to this problem now? I'm working on something similar.... |
I am trying to figure out how to return an RGBA image without combining with the solid background colour inside the rasterizer.
I've adjusted the out_color variable to have an extra channel, and in the forward pass (forward.cu) it is simple enough to make the change:
But I am unsure about how to make the change in the backward pass. Any ideas how this might be implemented?
The text was updated successfully, but these errors were encountered: