Skip to content

Instantly share code, notes, and snippets.

View ivbhatt's full-sized avatar
💙
Trying

Ishan Bhatt ivbhatt

💙
Trying
View GitHub Profile
@ivbhatt
ivbhatt / repo_flatten.py
Created December 29, 2024 07:03
this utility script can be used to flatten a repo/directory into a single code file to establish context in LLMs!
import os
def create_code_context(directory, output_file):
code_extensions = {
'.py', '.java', '.cpp', '.c', '.h', '.hpp', '.js', '.ts',
'.jsx', '.tsx', '.go', '.rs', '.rb', '.php', '.cs', '.md'
}
with open(output_file, 'w', encoding='utf-8') as outfile:
for root, _, files in os.walk(directory):
@ivbhatt
ivbhatt / ip_cv_demos.ipynb
Created December 16, 2023 05:33
IP_CV_demos.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ivbhatt
ivbhatt / ASCIIfyCore.py
Last active June 8, 2021 03:32
Core ASCIIfy logic
# Output blank canvas
output = np.zeros_like(image)
# Making the blank canvas usable with Pillow
pillow_output = Image.fromarray(output)
pillow_drawer = ImageDraw.Draw(pillow_output)
for i in range(int(image_height / font_height)):
for j in range(int(image_width / font_width)):
# finding the bounding box for the next character to be inserted
@ivbhatt
ivbhatt / unOrderedMapKeyExistsCheck.cpp
Last active May 30, 2021 02:17
Check if a key-value pair exists in your C++ STL unordered_map in constant time
/* Our plan is to simply check if accessing the candidate key throws an exception.
If an exception is not thrown, then key is present
Otherwise, the key is not present in our HashMap
*/
// including everything
#include <bits/stdc++.h>
using namespace std;
bool checkIfKeyPresent (unordered_map<int, int> hashMap, int candidate_key){
@ivbhatt
ivbhatt / NullProcess-VideoPipeLine.py
Last active August 9, 2020 18:39
This gist shows how to read, write and display video files on Windows and Linux in mp4 format
import sys
import cv2
OUTFILE = "output.mp4"
FRAME_FPS = 10.0
FRAME_WIDTH = 640
FRAME_HEIGHT = 480
WINDOW_NAME = "Output Window"
@ivbhatt
ivbhatt / Viztrick.py
Created August 1, 2020 13:07
The trick-part of the visualization blog
# Now let's test out the model on our selected images
# We will save all our results in a directory called "results"
# First we create "results" directory if it does not exist
if not (os.path.exists("results")):
os.mkdir("results")
# We traverse through all the files in "images"
for image_name in os.listdir("images"):
# We process only files that have one of our ALLOWED_EXTENSIONS
@ivbhatt
ivbhatt / importCONV-FE.py
Last active August 1, 2020 13:28
Gist to import CONV-FE in python
# Since we're using Convolutional Feature Extractors available in keras.applications;
# We need to import them as modules
# Only un-comment ONE of the following code-block
# Uncomment below lines if you want to try out VGG-16
from tensorflow.keras.applications.vgg16 import VGG16, preprocess_input
model = VGG16(weights='imagenet', include_top = False, input_shape=(256, 256, 3))
# # Uncomment below lines if you want to try out MobileNetV2
# from tensorflow.keras.applications.mobilenet_v2 import MobileNetV2, preprocess_input