Skip to content

Instantly share code, notes, and snippets.

View devarshi16's full-sized avatar
💭
Curiosity, always there

Devarshi Aggarwal devarshi16

💭
Curiosity, always there
View GitHub Profile
" Personal neovim config file. NOTETOSELF: paste in ~/.config/nvim/
:set number
:set autoindent
:set tabstop=4
:set shiftwidth=4
:set smarttab
:set softtabstop=4
:set mouse=a
call plug#begin('~/.config/nvim/plugged')
import os
import numpy as np
import time
import matplotlib.pyplot as plt
from tqdm import tqdm
import requests
import gzip
from numpy import loadtxt,savetxt
np.seterr(divide='ignore',invalid='ignore')
@devarshi16
devarshi16 / one_hot_compare.py
Created July 11, 2021 11:10
Compare execution times of two different one hot encoding algorithms using numpy and python
import numpy as np
import matplotlib.pyplot as plt
import random
import time
def one_hot(Y):
data_size=Y.shape[0]
classes=np.unique(Y).reshape(-1,1)
num_classes=classes.shape[0]
class_mappings=np.arange(0,max(Y)+1)
import cv2
import numpy as np
# Finds distance between two points
def points_distance(pt1,pt2):
return (((pt1[0]-pt2[0])**2 + (pt1[1]-pt2[1])**2)**(1/2))
# Orders points clockwise
# Credits pyimagesearch.com
def order_points(pts):
@devarshi16
devarshi16 / text_overlay.py
Created February 27, 2020 10:44
Vectorly interview assignment, first round
# This is the problem for First technical round for the role of Computer Vision Engineer at Vectorly
# More details at https://www.linkedin.com/jobs/view/1629909785/
#
# Write a function which will segment and extract the text overlay "Bart & Homer's EXCELLENT Adventure"
# Input image is at https://vectorly.io/demo/simpsons_frame0.png
# Output : Image with only the overlay visible and everything else white
#
# Note that you don't need to extract the text, the output is an image with only
# the overlay visible and everything else (background) white
#
@devarshi16
devarshi16 / json_maker2.py
Created January 13, 2020 09:56
Create train_val_test_split.json file in Visual template free parsing model. (Expects packets of 25 images + jsons(can be changed))
import os
import json
import sys
import random
data = {}
dir_names = sys.argv[1:]
current_dir = os.getcwd()
train = {}
@devarshi16
devarshi16 / json_format.py
Created January 13, 2020 09:53
Convert Form Labeller output json format to NAF data json format
import os
import json
import cv2
import sys
textBB_items = ["Printed Key","Written Key","Check Box Key","Comment/Info" ]
fieldBB_items = [None,"detectorPrediction","None","Printed Value", "Written Value", "Check Box Value", "Logo", "Signature", "Photograph"]
extensions = ['.JPEG','.png','.jpg','.tif','.tiff']
folder_names = ['internal28','internal17','internal7','internal8','internal9']
#folder_names = ['internal7']
@devarshi16
devarshi16 / packets.py
Last active December 19, 2019 13:17
For dividing images from given folder proportionately into folders of given size
import os
import random
TASK_SIZE = 25
dir_names = [
"cheque",
"nach",
"pan_and_aadhaar"
]
@devarshi16
devarshi16 / pdf_convert.py
Last active December 19, 2019 13:22
Convert pdfs in a directory to images
from pdf2image import convert_from_path, convert_from_bytes
from PIL import Image
import os
files = os.listdir()
for f in files:
if '.PDF' in f:
imgs = convert_from_path(f)
for i,im in enumerate(imgs):
im.save('.'.join(f.split('.')[:-1])+"_"+str(i)+".JPEG","JPEG")
@devarshi16
devarshi16 / aocr_test.ipynb
Last active December 19, 2019 13:18
aocr package usage on colab
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.