synthesiaresearch / humanrf

Official code for "HumanRF: High-Fidelity Neural Radiance Fields for Humans in Motion"
http://actors-hq.com
Other
449 stars 28 forks source link

The use of xyzt_vectors #8

Closed sora158 closed 1 year ago

sora158 commented 1 year ago

self.vectors = torch.nn.Parameter( torch.randn((4, vectors_finest_resolution, feature_size), dtype=torch.float) * 0.1 ) However, I don't understand why xyzt_vectors is a random tensor but also have gradients.

And the next question is In tensor_composition.cu, why time dimension is also multipied by finest_resolution:

for (int i = 0; i < 4; ++i)
    {
        // Following routine corresponds to align_corners=True in PyTorch's grid_sample.
        // TensoRF does the same.
        // Cuda's texture fetch linear mode does the same: https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#linear-filtering
        // xyzt_coordinates are assumed to be in [0, 1].
        auto coord = xyzt_coordinates[sample_index][i] * finest_resolution - 0.5f;
        auto coord_floor = floorf(coord);
        auto coord_frac = coord - coord_floor;

        int coord0 = fmaxf(coord_floor, 0.0f);
        int coord1 = fminf(coord_floor + 1.0f, finest_resolution - 1);
        auto val0 = xyzt_vectors[i][coord0][feature_index];
        auto val1 = xyzt_vectors[i][coord1][feature_index];
        sampled_vectors[i] = val0 + coord_frac * (val1 - val0);

        auto dval = features[i] * d_output;
        atomicAdd(&d_xyzt_vectors[i][coord0][feature_index], dval * (1 - coord_frac));
        atomicAdd(&d_xyzt_vectors[i][coord1][feature_index], dval * coord_frac);
    }
isikmustafa commented 1 year ago

self.vectors is part of the 4D-decomposed feature grid and its weights need to be optimized as well. torch.randn((4, vectors_finest_resolution, feature_size), dtype=torch.float) * 0.1 is just a convenient way to initialize the weights.