Skip to content

Instantly share code, notes, and snippets.

@yashkant
yashkant / pippo_data.py
Created February 25, 2025 10:16
Code snippets of helper methods used in Pippo for generating plucker rays and spatial anchor.
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
"""
Contains helper functions (`fetch_plucker` and `fetch_spatial_anchor`) originally used in Pippo to create:
- Plucker Rays from camera KRT
- Spatial Anchor Image from camera KRT and headpose (provided in head-only Ava-256) or 3d keypoints (provided in full-body Goliath)
@yashkant
yashkant / spad_eval_prompts.json
Created November 8, 2024 01:19
1000 Evaluation prompts used for SPAD
[
"[tdv] a white Ford F-150 King Ranch pickup truck.",
"[tdv] a small white robot with blue eyes and a white sphere.",
"[tdv] A black and gold vase with geometric patterns.",
"[tdv] a blue and yellow fish from Finding Dory with a mask.",
"[tdv] a futuristic, large concrete building with a triangular roof, featuring a circular structure with a hole in the middle and a circular ceiling light fixture.",
"[tdv] White hot air balloon",
"[tdv] a gun",
"[tdv] a tool with a red and blue handle.",
"[tdv] a knight's armored metal helmet with gold trim and holes.",
@yashkant
yashkant / spad_prompts.json
Last active November 8, 2024 01:20
Text-to-3D evaluation prompts used in SPAD
{
"DF400": [
"a 20-sided die made out of glass",
"a bald eagle carved out of wood",
"a banana peeling itself",
"a beagle in a detective's outfit",
"a beautiful dress made out of fruit, on a mannequin. Studio lighting, high quality, high resolution",
"a beautiful dress made out of garbage bags, on a mannequin. Studio lighting, high quality, high resolution",
"a beautiful rainbow fish",
"a bichon frise wearing academic regalia",
@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.