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
from typing import Callable | |
import torch | |
from torch import nn | |
import torch.nn.functional as F | |
class TNet(nn.Module): | |
""" | |
Transformation network module of PointNet |
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
ModelNet10/sofa/test/sofa_0780.off,sofa | |
ModelNet10/bed/test/bed_0545.off,bed | |
ModelNet10/dresser/test/dresser_0264.off,dresser | |
ModelNet10/dresser/test/dresser_0239.off,dresser | |
ModelNet10/table/test/table_0420.off,table | |
ModelNet10/table/test/table_0425.off,table | |
ModelNet10/monitor/test/monitor_0535.off,monitor | |
ModelNet10/table/test/table_0428.off,table | |
ModelNet10/dresser/test/dresser_0211.off,dresser | |
ModelNet10/monitor/test/monitor_0553.off,monitor |
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
ModelNet10/chair/train/chair_0381.off,chair | |
ModelNet10/bed/train/bed_0463.off,bed | |
ModelNet10/bathtub/train/bathtub_0031.off,bathtub | |
ModelNet10/monitor/train/monitor_0101.off,monitor | |
ModelNet10/sofa/train/sofa_0128.off,sofa | |
ModelNet10/dresser/train/dresser_0115.off,dresser | |
ModelNet10/sofa/train/sofa_0250.off,sofa | |
ModelNet10/dresser/train/dresser_0104.off,dresser | |
ModelNet10/sofa/train/sofa_0579.off,sofa | |
ModelNet10/bed/train/bed_0062.off,bed |
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
""" | |
Remove a person from an image using a stable diffusion server | |
This short demo accompanies the Medium article "Stable Diffusion as an API: Make a Person-Removing Microservice". | |
The full article can be found here: https://towardsdatascience.com/stable-diffusion-as-an-api-5e381aec1f6 | |
Example usage: | |
python inpaint-person.py my-image.jpg -W 768 -H 768 -o my-output.png | |
""" |
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
def sample_hierarchical( | |
rays_o: torch.Tensor, | |
rays_d: torch.Tensor, | |
z_vals: torch.Tensor, | |
weights: torch.Tensor, | |
n_samples: int, | |
perturb: bool = False | |
) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]: | |
r""" | |
Apply hierarchical sampling to the rays. |
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
def sample_stratified( | |
rays_o: torch.Tensor, | |
rays_d: torch.Tensor, | |
near: float, | |
far: float, | |
n_samples: int, | |
perturb: Optional[bool] = True, | |
inverse_depth: bool = False | |
) -> Tuple[torch.Tensor, torch.Tensor]: | |
r""" |
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
class NeRF(nn.Module): | |
r""" | |
Neural radiance fields module. | |
""" | |
def __init__( | |
self, | |
d_input: int = 3, | |
n_layers: int = 8, | |
d_filter: int = 256, | |
skip: Tuple[int] = (4,), |
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
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 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 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(): |
NewerOlder