Skip to content

Instantly share code, notes, and snippets.

View abhaymise's full-sized avatar

Abhay Kumar abhaymise

View GitHub Profile
@abhaymise
abhaymise / multithread_process_utils.py
Created February 3, 2023 11:11
Common utils for multi threading and processing
import multiprocessing
import threading
from concurrent import futures
import random
max_workers = multiprocessing.cpu_count() - 2
def compute():
return sum(
[random.randint(1, 100) for i in range(1000000)])
'''
modeling_preparation.py
'''
from .project_imports import *
from .utilties import *
from .model_store import *
def train_val_test_split(trainable_df, train_percent, val_percent,
test_percent):
def intialise_model(weight_path):
return model_obj
class Inference():
def __init__(self,weight_path):
self.model_obj = None
self.weight_path = weight_path
def __load_model(self):
@abhaymise
abhaymise / filter_and_feature_map_visualization.ipynb
Last active August 1, 2021 03:08
filter_and_feature_map_visualization_keras.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@abhaymise
abhaymise / embedding_projector.py
Created July 26, 2021 04:02
This gits contains the steps and libraries required to visualise image embedding on an embedding projection tool. The embedding are respresented by their visaul represtation to make the projection meaningful for anyone.
import pandas as pd
import numpy as np
import cv2
import os
from PIL import Image
import glob
from keras.applications.inception_v3 import InceptionV3
from keras.applications.inception_v3 import preprocess_input, decode_predictions
@abhaymise
abhaymise / in_memory_video_readers.ipynb
Created April 4, 2021 06:49
Efficiently reading a video frame
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@abhaymise
abhaymise / video_to_frames.py
Created February 8, 2021 05:18 — forked from HaydenFaulkner/video_to_frames.py
Fast frame extraction from videos using Python and OpenCV
from concurrent.futures import ProcessPoolExecutor, as_completed
import cv2
import multiprocessing
import os
import sys
def print_progress(iteration, total, prefix='', suffix='', decimals=3, bar_length=100):
"""
Call in a loop to create standard out progress bar
import numpy as np
import json
import base64
encode_array = lambda nparray : [str(nparray.dtype.name), nparray.tobytes(), nparray.shape]
def decode_array(encStr):
#get the encoded json dump
enc = encStr
# build the numpy data type
dataType = np.dtype(enc[0])
## Plotting the compressed feature
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import colors as mcolors
import seaborn as sns
### 2D
compressed_frame = pd.DataFrame(indexing_features,columns=['x','y','z'])
from PIL import Image
def check_image_with_pil(path):
try:
Image.open(path)
except IOError:
return False
return True