Skip to content

Instantly share code, notes, and snippets.

View luocfprime's full-sized avatar

Chaofan Luo luocfprime

View GitHub Profile
import time
import logging
from contextlib import ContextDecorator
from functools import wraps
logger = logging.getLogger(__name__)
class profiler(ContextDecorator):
def __init__(self, name=None, profiler_logger=None):
self.name = name
@luocfprime
luocfprime / instructions.txt
Created April 8, 2025 02:39 — forked from shawngraham/instructions.txt
installing nerfstudio on a mac
# https://github.com/nerfstudio-project/nerfstudio/issues/2438
conda create --name nerfstudio -y python=3.8
conda activate nerfstudio
python -m pip install --upgrade pip
pip uninstall torch torchvision functorch tinycudann
pip install torch==2.0.1 torchvision==0.15.2
git clone https://github.com/nerfstudio-project/nerfstudio.git
cd nerfstudio
from typing import Union
import matplotlib.pyplot as plt
import numpy as np
import torch
from PIL import Image
from torchvision.transforms import ToPILImage
def show_image(img: Union[torch.Tensor, np.ndarray, Image.Image]):
@luocfprime
luocfprime / grid_crop.py
Created May 19, 2024 15:07
grid_crop.py
import torch
import torchvision.transforms as T
from PIL import Image
from einops import rearrange
# input path here
img = Image.open("input/view0.png")
class GridDecompose:
@luocfprime
luocfprime / mutually_exclusive_arg_groups.py
Last active January 5, 2024 16:03
python mutually_exclusive_arg_groups decorator
import inspect
from functools import wraps
from typing import Any, Callable, Tuple
def mutually_exclusive_arg_groups(*arg_groups: Tuple[str, ...], must_match_one_group=False) -> Callable:
"""
Validate specified keyword arg group are mutually exclusive.
Args:
*arg_groups: Tuple[str, ...]
@luocfprime
luocfprime / debug.h
Created April 20, 2023 09:25
debug logger util
/*
* @Date: 2022-03-21 13:47:22
* @LastEditors: Lcf
* @LastEditTime: 2022-03-24 04:14:16
* @FilePath: /socket_programming/include/debug.h
*/
#ifndef __DEBUG_H__
#define __DEBUG_H__