Skip to content

Instantly share code, notes, and snippets.

View spillai's full-sized avatar

Sudeep Pillai spillai

View GitHub Profile
@spillai
spillai / vlm_tools_openai.py
Created March 31, 2024 16:19
Tools to interact with openai (gpt4, gpt4v)
import inspect
import os
from functools import lru_cache
from typing import Any, Dict, Literal, Union
import requests
from loguru import logger
from PIL import Image
from diskcache import Cache
@spillai
spillai / vlm_tools_youtube.py
Created March 28, 2024 19:52
Helper video reader utility for handling youtube URLs
import logging
from itertools import islice
from pathlib import Path
from typing import Iterable
from nos.common.io import VideoReader
from PIL import Image
from pytube import Playlist, YouTube
logger = logging.getLogger(__name__)
@spillai
spillai / vlm_tools_image.py
Created March 28, 2024 19:48
Helper image-processing utility for vlm API
import json
from base64 import b64encode
from io import BytesIO
from typing import Literal, Union
import requests
from PIL import Image
def pprint(data):
"""Basic dataset reader"""
# Author: Sudeep Pillai <spillai@csail.mit.edu>
# License: MIT
import cv2
import numpy as np
import os, fnmatch, time
import re
from itertools import izip, imap, chain
from collections import defaultdict, namedtuple
// Compile with:
// clang++ -std=c++11 -shared -l boost_python3 -I /usr/include/python3.2mu -fPIC -o bptuple.so tuple-test.cpp
#include <tuple>
#include <string>
#include <boost/python.hpp>
namespace py = boost::python;
using std::string;
#!/bin/bash
sudo apt-get update
sudo apt-get install gcc
wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1204/x86_64/cuda-repo-ubuntu1204_5.5-0_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1204_5.5-0_amd64.deb
sudo apt-get update
sudo apt-get install cuda
export PATH=/usr/local/cuda-5.5/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-5.5/lib64:$LD_LIBRARY_PATH
sudo apt-get install opencl-headers python-pip python-dev python-numpy python-mako
### MATPLOTLIBRC FORMAT
# This is a sample matplotlib configuration file - you can find a copy
# of it on your system in
# site-packages/matplotlib/mpl-data/matplotlibrc. If you edit it
# there, please note that it will be overridden in your next install.
# If you want to keep a permanent local copy that will not be
# over-written, place it in HOME/.matplotlib/matplotlibrc (unix/linux
# like systems) and C:\Documents and Settings\yourname\.matplotlib
# (win32 systems).
@spillai
spillai / tmux.md
Created August 16, 2013 15:49 — forked from andreyvit/tmux.md

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

import numpy as np, numpy.linalg as linalg
def fast_svd(M, k):
p = k+5
Y = np.dot(M, np.random.normal(size=(M.shape[1],p)))
Q,r = linalg.qr(Y)
B = np.dot(Q.T,M)
Uhat, s, v = linalg.svd(B, full_matrices=False)
U = np.dot(Q, Uhat)
return U.T[:k].T, s[:k], v[:k]
import numpy as np, numpy.linalg as linalg
def fast_svd(M, k):
p = k+5
Y = np.dot(M, np.random.normal(size=(M.shape[1],p)))
Q,r = linalg.qr(Y)
B = np.dot(Q.T,M)
Uhat, s, v = linalg.svd(B, full_matrices=False)
U = np.dot(Q, Uhat)
return U.T[:k].T, s[:k], v[:k]