Skip to content

Instantly share code, notes, and snippets.

View spillai's full-sized avatar

Sudeep Pillai spillai

View GitHub Profile
You are ChatGPT, a large language model based on the GPT-5 model and trained by OpenAI.
Knowledge cutoff: 2024-06
Current date: 2025-08-08
Image input capabilities: Enabled
Personality: v2
Do not reproduce song lyrics or any other copyrighted material, even if asked.
You're an insightful, encouraging assistant who combines meticulous clarity with genuine enthusiasm and gentle humor.
Supportive thoroughness: Patiently explain complex topics clearly and comprehensively.
Lighthearted interactions: Maintain friendly tone with subtle humor and warmth.
@spillai
spillai / invoice-batch.py
Created April 23, 2025 14:35
Invoice extraction (batch)
from pathlib import Path
from vlmrun.client import VLMRun
from vlmrun.client.types import PredictionResponse
# Instantiate the client
client = VLMRun(api_key="<VLMRUN_API_KEY>")
response = client.document.generate(
file=Path("<path>.pdf"),
domain="document.invoice",
batch=True
@spillai
spillai / invoice.py
Created April 12, 2025 20:25
VLM Run - Invoice extraction with grounding
from PIL import Image
from vlmrun.client import VLMRun
from vlmrun.client.types import GenerationConfig
image = Image.open("test.jpg")
client = VLMRun(api_key="...")
response = client.image.generate(
images=[image],
@spillai
spillai / schema.py
Created December 3, 2024 03:32
Invoice Schema
from pydantic import BaseModel, Field
class StockItem(BaseModel):
item_description: str | None = Field(None, title="Description of the item.")
opening_stock_quantity: int | None = Field(None, title="Opening stock quantity of the item.")
opening_stock_value: float | None = Field(None, title="Opening stock value of the item.")
opening_stock_quantity_unit: str | None = Field(None, title="Opening stock quantity unit of the item.")
incoming_stock_quantity: int | None = Field(None, title="Incoming stock quantity of the item.")
incoming_stock_value: float | None = Field(None, title="Incoming stock value of the item.")
@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 <[email protected]>
# 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