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
@devarshi16
devarshi16 / cloth-generator-64.ipynb
Created April 30, 2019 09:05
cloth generator 64.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@devarshi16
devarshi16 / quick_and_easy_annotator.py
Created November 12, 2019 12:32
Quickly annotate cropped text images for training your OCR-model
import os
from tkinter import *
from tkinter import ttk
import sys
import pandas as pd
from PIL import ImageTk,Image
base = Tk()
base.geometry("500x500")
base.resizable(width = True, height = True)
import os
import random as rand
import shutil
if not os.path.exists('val'):
os.makedirs('val')
if not os.path.exists('test'):
os.makedirs('test')
@devarshi16
devarshi16 / img_crop_save.py
Created November 26, 2019 08:55
Script for cropping images using bounding boxes in correspoding json file
import json
import numpy as np
import os
import cv2
import matplotlib.image as mpimg
current_dir = os.getcwd()
files = os.listdir(current_dir)
@devarshi16
devarshi16 / gocr_image_annotation.py
Last active November 26, 2019 10:53
Annotate text images using GOCR
from google.cloud import vision
import io
import os
import os
os.environ["GOOGLE_APPLICATION_CREDENTIALS"]="/home/devarshi/gcloud.json"
def detect_text(path):
"""Detects text in the file."""
client = vision.ImageAnnotatorClient()
@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.
@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 / 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 / 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 / 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 = {}