Skip to content

Instantly share code, notes, and snippets.

View yashkant's full-sized avatar
🐢

Yash Kant yashkant

🐢
View GitHub Profile
@yashkant
yashkant / epipolar_mask.py
Created January 11, 2024 16:56
Code snippet to create epipolar masks for the work — SPAD: Spatially Aware Multiview Diffusers
import numpy as np
import torch
import time
import imageio
import cv2
from tqdm import tqdm
import torch.nn.functional as Fu
from pytorch3d.implicitron.tools.point_cloud_utils import get_rgbd_point_cloud
from pytorch3d.renderer import (AlphaCompositor, MultinomialRaysampler,
NDCMultinomialRaysampler,
@yashkant
yashkant / ffcv_loader.py
Last active January 21, 2024 07:55
FFCV datamodule for pytorch lightning that can support iterating over many chunked beton files.
import pytorch_lightning as pl
class FFCVDataModule(pl.LightningDataModule):
def __init__(self, batch_size, train=None, reg = None, validation=None, test=None, predict=None,
wrap=False, num_workers=None, shuffle_test_loader=False, use_worker_init_fn=False,
shuffle_val_dataloader=False, beton_path=None, **kwargs):
super().__init__()
self.batch_size = batch_size
self.num_workers = num_workers if num_workers is not None else batch_size * 2
@yashkant
yashkant / splat.py
Last active August 9, 2024 16:24
Code snippet to create partial views for the work — iNVS : Repurposing Diffusion Inpainters for Novel View Synthesis, SIGGRAPH 2023
import numpy as np
import torch
import time
import imageio
import cv2
from tqdm import tqdm
import torch.nn.functional as Fu
from pytorch3d.implicitron.tools.point_cloud_utils import get_rgbd_point_cloud
from pytorch3d.renderer import (AlphaCompositor, MultinomialRaysampler,
NDCMultinomialRaysampler,
@yashkant
yashkant / join_videos.py
Last active February 2, 2022 06:43
Join videos quickly row-wise or column-wise using Python
import cv2
import argparse
import glob
from torchvision.io import write_video
import numpy as np
import os
"""
A quick piece of code I put together to join some video samples I had for creating visualizations.