This file contains hidden or 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
def raw2outputs( | |
raw: torch.Tensor, | |
z_vals: torch.Tensor, | |
rays_d: torch.Tensor, | |
raw_noise_std: float = 0.0, | |
white_bkgd: bool = False | |
) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor]: | |
r""" | |
Convert the raw NeRF output into RGB and other maps. | |
""" |
This file contains hidden or 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
class PositionalEncoder(nn.Module): | |
r""" | |
Sine-cosine positional encoder for input points. | |
""" | |
def __init__( | |
self, | |
d_input: int, | |
n_freqs: int, | |
log_space: bool = False | |
): |
This file contains hidden or 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
import time | |
import threading | |
import numpy as np | |
import cv2 as cv | |
def _is_window_open(win_name): | |
return cv.getWindowProperty(win_name, cv.WND_PROP_VISIBLE) > 0 | |
class VideoGetter(): |
This file contains hidden or 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
# adapted from https://github.com/autonomousvision/giraffe (MIT License) | |
weights = self.calc_volume_weights(di, ray_vector, sigma_sum) | |
feat_map = torch.sum(weights.unsqueeze(-1) * feat_weighted, dim=-2) |
This file contains hidden or 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
# adapted from https://github.com/autonomousvision/giraffe (MIT License) | |
sigma_sum, feat_weighted = self.composite_function(sigma, feat) |
This file contains hidden or 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
# adapted from https://github.com/autonomousvision/giraffe (MIT License) | |
z_shape_obj, z_app_obj, z_shape_bg, z_app_bg = latent_codes |
This file contains hidden or 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
# adapted from https://github.com/autonomousvision/giraffe (MIT License) | |
from im2scene.giraffe.models import generator | |
# ... | |
generator_dict = { | |
'simple': generator.Generator, | |
} |
This file contains hidden or 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
# adapted from https://github.com/autonomousvision/giraffe (MIT License) | |
n_iter = n_boxes if not_render_background else n_boxes + 1 | |
# ... | |
for i in range(n_iter): | |
if i < n_boxes: # Object | |
p_i, r_i = self.get_evaluation_points(pixels_world, | |
camera_world, di, transformations, i) | |
z_shape_i, z_app_i = z_shape_obj[:, i], z_app_obj[:, i] | |
feat_i, sigma_i = self.decoder(p_i, r_i, z_shape_i, z_app_i) | |
# ... |
This file contains hidden or 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
# adapted from https://github.com/autonomousvision/giraffe (MIT License) | |
class Generator(nn.Module): | |
# ... | |
def get_latent_codes(self, batch_size=32, tmp=1.): | |
z_dim, z_dim_bg = self.z_dim, self.z_dim_bg | |
n_boxes = self.get_n_boxes() | |
def sample_z(x): return self.sample_z(x, tmp=tmp) | |
z_shape_obj = sample_z((batch_size, n_boxes, z_dim)) | |
z_app_obj = sample_z((batch_size, n_boxes, z_dim)) | |
z_shape_bg = sample_z((batch_size, z_dim_bg)) |
This file contains hidden or 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
# adapted from https://github.com/autonomousvision/giraffe (MIT License) | |
class Renderer(object): | |
# ... | |
def render_object_rotation(self, img_out_path, batch_size=15, n_steps=32): | |
gen = self.generator | |
bbox_generator = gen.bounding_box_generator | |
n_boxes = bbox_generator.n_boxes | |
# Set rotation range |