diff --git a/200310484280_AdmitCard.pdf b/200310484280_AdmitCard.pdf new file mode 100644 index 0000000..093605b Binary files /dev/null and b/200310484280_AdmitCard.pdf differ diff --git a/ALLOTMENT LETER.pdf b/ALLOTMENT LETER.pdf new file mode 100644 index 0000000..288bd02 Binary files /dev/null and b/ALLOTMENT LETER.pdf differ diff --git a/README.md b/README.md index 531e400..e69de29 100644 --- a/README.md +++ b/README.md @@ -1 +0,0 @@ -# similarity-detection-model- \ No newline at end of file diff --git a/__pycache__/main.cpython-310.pyc b/__pycache__/main.cpython-310.pyc new file mode 100644 index 0000000..4ed7e50 Binary files /dev/null and b/__pycache__/main.cpython-310.pyc differ diff --git a/__pycache__/ocr.cpython-310.pyc b/__pycache__/ocr.cpython-310.pyc new file mode 100644 index 0000000..abfb03d Binary files /dev/null and b/__pycache__/ocr.cpython-310.pyc differ diff --git a/__pycache__/svefy.cpython-310.pyc b/__pycache__/svefy.cpython-310.pyc new file mode 100644 index 0000000..4e36c58 Binary files /dev/null and b/__pycache__/svefy.cpython-310.pyc differ diff --git a/__pycache__/test.cpython-310.pyc b/__pycache__/test.cpython-310.pyc new file mode 100644 index 0000000..fa5ea26 Binary files /dev/null and b/__pycache__/test.cpython-310.pyc differ diff --git a/addharec.py b/addharec.py new file mode 100644 index 0000000..6293d85 --- /dev/null +++ b/addharec.py @@ -0,0 +1,2 @@ +import argumentor +p = Augmentor.Pipeline("/path/to/images") \ No newline at end of file diff --git a/adhar/20191018_074403.jpg b/adhar/20191018_074403.jpg new file mode 100644 index 0000000..025c583 Binary files /dev/null and b/adhar/20191018_074403.jpg differ diff --git a/adhar/73a8158ee961472799e57e72b1868f54.jpg b/adhar/73a8158ee961472799e57e72b1868f54.jpg new file mode 100644 index 0000000..8f504e3 Binary files /dev/null and b/adhar/73a8158ee961472799e57e72b1868f54.jpg differ diff --git a/adhar/Aadhar-Card.jpg b/adhar/Aadhar-Card.jpg new file mode 100644 index 0000000..12bf9cf Binary files /dev/null and b/adhar/Aadhar-Card.jpg differ diff --git a/adhar/Aadhar_Card.jpg b/adhar/Aadhar_Card.jpg new file mode 100644 index 0000000..f8a4824 Binary files /dev/null and b/adhar/Aadhar_Card.jpg differ diff --git a/adhar/Screenshot_20220218-123153-1.jpg b/adhar/Screenshot_20220218-123153-1.jpg new file mode 100644 index 0000000..fbe6f08 Binary files /dev/null and b/adhar/Screenshot_20220218-123153-1.jpg differ diff --git a/adhar/download (1).jfif b/adhar/download (1).jfif new file mode 100644 index 0000000..8c60757 Binary files /dev/null and b/adhar/download (1).jfif differ diff --git a/adhar/download.jfif b/adhar/download.jfif new file mode 100644 index 0000000..2be8943 Binary files /dev/null and b/adhar/download.jfif differ diff --git a/adhar/f99b3efadece9bde10e251760cc71b1c.jpg b/adhar/f99b3efadece9bde10e251760cc71b1c.jpg new file mode 100644 index 0000000..7c8fc26 Binary files /dev/null and b/adhar/f99b3efadece9bde10e251760cc71b1c.jpg differ diff --git a/adhar/ffa5e80e5c547686632c7bc9746fee87.jpg b/adhar/ffa5e80e5c547686632c7bc9746fee87.jpg new file mode 100644 index 0000000..1235ac9 Binary files /dev/null and b/adhar/ffa5e80e5c547686632c7bc9746fee87.jpg differ diff --git a/adhar/hqdefault.jpg b/adhar/hqdefault.jpg new file mode 100644 index 0000000..e9e95d1 Binary files /dev/null and b/adhar/hqdefault.jpg differ diff --git a/adhar/id-1505369822.jpg b/adhar/id-1505369822.jpg new file mode 100644 index 0000000..24e2a2a Binary files /dev/null and b/adhar/id-1505369822.jpg differ diff --git a/adhatest3.jpg b/adhatest3.jpg new file mode 100644 index 0000000..02316cb Binary files /dev/null and b/adhatest3.jpg differ diff --git a/allotletter.pdf b/allotletter.pdf new file mode 100644 index 0000000..f2c72d0 Binary files /dev/null and b/allotletter.pdf differ diff --git a/bhalu.jpeg b/bhalu.jpeg new file mode 100644 index 0000000..49363a0 Binary files /dev/null and b/bhalu.jpeg differ diff --git a/check.py b/check.py new file mode 100644 index 0000000..3d711da --- /dev/null +++ b/check.py @@ -0,0 +1,41 @@ +# import logging +# import sys +# import numpy as np +# import pandas as pd +# import mlops.ml_verify as mas +# for name in logging.Logger.manager.loggerDict.keys(): +# logging.getLogger(name).setLevel(logging.CRITICAL) + +# import os +# os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' +# from tkinter.tix import IMAGE +from ocr import ankocr + + +# image= 'subject2.jpeg' +# if(mas.check.check_similarity(image,'adhatest3.jpg')>0.70): +# # print("similar") +# t=ankocr.get_text(image) +# # print(t) +# if('GOVERNMENT OF INDIA' in t): +# print("all test passed") +# else: +# print('text not found') +# else: +# t=ankocr.get_text(image) +# # print(t) +# if('GOVERNMENT OF INDIA' in t): +# print('similarity test fail but text found') +# else: +# print('all test fail') + + +from test import tester + + + +print(tester.check_jee_allot('ALLOTMENT LETTER.pdf')) +# print(tester.check_jee_allot('200310484280_AdmitCard.pdf')) +# ankocr.delete('save.png') +# print(tester.check('testadha2.jpg')) +# print(tester.check_pan('riya_pan.jpeg')) diff --git a/gpu.py b/gpu.py new file mode 100644 index 0000000..d53e5af --- /dev/null +++ b/gpu.py @@ -0,0 +1,3 @@ +import tensorflow as tf +tf.test.is_built_with_cuda() +tf.test.is_gpu_available(cuda_only=False, min_cuda_compute_capability=None) \ No newline at end of file diff --git a/jee allot.jpg b/jee allot.jpg new file mode 100644 index 0000000..c6ce991 Binary files /dev/null and b/jee allot.jpg differ diff --git a/main.py b/main.py new file mode 100644 index 0000000..b070722 --- /dev/null +++ b/main.py @@ -0,0 +1,26 @@ +from fastapi import FastAPI, File, UploadFile + +app = FastAPI() + + +@app.post("/files/") +async def create_file(file: bytes | None = File(default=None)): + if not file: + return {"message": "No file sent"} + else: + return {"file_size": len(file)} + + +@app.post("/uploadfile/") +async def create_upload_file(file: UploadFile | None = None): + if not file: + return {"message": "No upload file sent"} + else: + return {"filename": file.filename} + + + +@app.get("/") +def model(file){ + +} diff --git a/mlcnn/__pycache__/mlverify2.cpython-310.pyc b/mlcnn/__pycache__/mlverify2.cpython-310.pyc new file mode 100644 index 0000000..7d003b1 Binary files /dev/null and b/mlcnn/__pycache__/mlverify2.cpython-310.pyc differ diff --git a/mlcnn/check.py b/mlcnn/check.py new file mode 100644 index 0000000..f416930 --- /dev/null +++ b/mlcnn/check.py @@ -0,0 +1,9 @@ +from mlverify2 import cnn_verify +import os +img_dir = '../data' +img_path_list = ['adhar.jpg'] +index = 0 +img_path = os.path.join(img_dir, img_path_list[index]) +model_name = 'vgg16' + +print(cnn_verify.make_prediction(model_name, img_path)) \ No newline at end of file diff --git a/mlcnn/data/adhar.jpg b/mlcnn/data/adhar.jpg new file mode 100644 index 0000000..7c8fc26 Binary files /dev/null and b/mlcnn/data/adhar.jpg differ diff --git a/mlcnn/mlverify2.py b/mlcnn/mlverify2.py new file mode 100644 index 0000000..32706c0 --- /dev/null +++ b/mlcnn/mlverify2.py @@ -0,0 +1,165 @@ +import os +import numpy as np +import matplotlib.pyplot as plt + +from keras.applications.vgg16 import VGG16 +from keras.applications.resnet import ResNet50 +from keras.applications.vgg16 import VGG16 +import tensorflow as tf +from keras.models import Model +from keras.models import model_from_json +from keras.utils import load_model +from keras.preprocessing import image +from keras.preprocessing.image import ImageDataGenerator +from keras.applications.imagenet_utils import preprocess_input, decode_predictions + +import cv2 +from IPython.display import HTML, display +from glob import glob +from PIL import Image +import time + +class cnn_verify: + def create_folder(folder_name): + # """ Create folder if there is not + # Args: + # folder_name: String, folder name + # Returns: + # None + # """ + if not os.path.isdir(f"../models/{folder_name}"): + os.makedirs(f"../models/{folder_name}") + print(f"Folder '../models/{folder_name}' created") + + def load_model(model_name, include_top=True): + # """ Load pre-trained Keras model + # Args: + # model_name: String, name of model to load + # include_top: String, the model is buildt with 'feature learning block' + 'classification block' + # Returns: + # model: Keras model instance + # """ + available_models = ['vgg16', 'resnet50'] + selected_model = 'vgg16' + + if selected_model in available_models: + # Load a Keras instance + try: + if model_name == 'vgg16': + model = VGG16(weights='imagenet', include_top=include_top) + elif model_name == 'resnet50': + model = ResNet50(weights='imagenet', include_top=include_top) + print(f">> '{model.name}' model successfully loaded!") + except: + print(f">> Error while loading model '{selected_model}'") + + # Wrong selected model + else: + print(f">> Error: there is no '{selected_model}' in {available_models}") + + return model + + def get_img_size_model(model = load_model('vgg16', include_top=True)): + # """Returns image size for image processing to be used in the model + # Args: + # model: Keras model instance + # Returns: + # img_size_model: Tuple of integers, image size + # """ + model_name = model + if model_name == "vgg16": + img_size_model = (224, 224) + elif model_name == "resnet50": + img_size_model = (224, 224) + else: + img_size_model = (224, 224) + print("Warning: model name unknown. Default image size: {}".format(img_size_model)) + + return img_size_model + + + def get_layername_feature_extraction(model = load_model('vgg16', include_top=True)): + # """ Return the name of last layer for feature extraction + # Args: + # model: Keras model instance + # Returns: + # layername_feature_extraction: String, name of the layer for feature extraction + # """ + model_name = model.name + if model_name == "vgg16": + layername_feature_extraction = 'fc2' + elif model_name == "resnet50": + layername_feature_extraction = 'predictions' + else: + layername_feature_extraction = '' + print("Warning: model name unknown. Default layername: '{}'".format(layername_feature_extraction)) + + return layername_feature_extraction + + + def get_layers_list(model): + # """Get a list of layers from a model + # Args: + # model: Keras model instance + # Returns: + # layers_list: List of string of layername + # """ + layers_list = [] + for i in range(len(model.layers)): + layer = model.layers[i] + layers_list.append(layer.name) + + return layers_list + + def image_processing(img_array): + # """ Preprocess image to be used in a keras model instance + # Args: + # img_array: Numpy array of an image which will be predicte + # Returns: + # processed_img = Numpy array which represents the processed image + # """ + # Expand the shape + img = np.expand_dims(img_array, axis=0) + + # Convert image from RGB to BGR (each color channel is zero-centered with respect to the ImageNet dataset, without scaling) + processed_img = preprocess_input(img) + + return processed_img + + + + def make_prediction(model, img_path, display_img=False): + """Make a prediction of an image by passing in the model + + Args: + model: Keras model instance used to do the classification. + img_path: String to the image path which will be predicted + display_img: Boolean to decid to show image. Defaults to True + + Returns: + predicted_class: String which represents the class of the predicted image from ImageNet + """ + img_type = os.path.basename(img_path).split(".")[0] + + # Image processing + img_size_model = cnn_verify.get_img_size_model(model) + img = image.load_img(img_path, target_size=img_size_model) + img_arr = np.array(img) + img_ = cnn_verify.image_processing(img_arr) + + preds = model.predict(img_) + top_preds = decode_predictions(preds) + predicted_class = top_preds[0][0][1] + predicted_class_percentage = top_preds[0][0][2]*100 + + # print('Top 5 predictions:') + for i in range(len(top_preds[0])): + print(" {} >>>>> {}".format(i+1, top_preds[0][i])) + + if display_img: + print() + plt.axis('off') + plt.title("({}) Original image: {}\nPrediction: {} ({:.2f}%)".format(model.name, img_type, predicted_class, predicted_class_percentage)) + plt.imshow(img_arr) + + return predicted_class \ No newline at end of file diff --git a/mlops/__pycache__/ml_verify.cpython-310.pyc b/mlops/__pycache__/ml_verify.cpython-310.pyc new file mode 100644 index 0000000..c957dbf Binary files /dev/null and b/mlops/__pycache__/ml_verify.cpython-310.pyc differ diff --git a/mlops/check.py b/mlops/check.py new file mode 100644 index 0000000..f823a5d --- /dev/null +++ b/mlops/check.py @@ -0,0 +1,2 @@ +from ml_verify import check +print(check.check_similarity('random2.jpeg', 'testadha2.jpg')) \ No newline at end of file diff --git a/mlops/ml_verify.py b/mlops/ml_verify.py new file mode 100644 index 0000000..6b65964 --- /dev/null +++ b/mlops/ml_verify.py @@ -0,0 +1,110 @@ +import tensorflow as tf +import tensorflow_hub as hub +import numpy as np +import os +import pandas as pd +import matplotlib.pyplot as plt +import base64 +from PIL import Image +import io +import math +from math import sqrt + + + + +global embed +embed = hub.KerasLayer(os.getcwd()) + + +class TensorVector(object): + + def __init__(self, FileName=None): + self.FileName = FileName + + def process(self): + + img = tf.io.read_file(self.FileName) + img = tf.io.decode_jpeg(img, channels=3) + img = tf.image.resize_with_pad(img, 224, 224) + img = tf.image.convert_image_dtype(img,tf.float32)[tf.newaxis, ...] + features = embed(img) + feature_set = np.squeeze(features) + return list(feature_set) + +class check: + def convertBase64(FileName): + """ + Return the Numpy array for a image + """ + with open(FileName, "rb") as f: + data = f.read() + + res = base64.b64encode(data) + + base64data = res.decode("UTF-8") + + imgdata = base64.b64decode(base64data) + + image = Image.open(io.BytesIO(imgdata)) + + return np.array(image) + + def cosineSim(a1,a2): + sum = 0 + suma1 = 0 + sumb1 = 0 + for i,j in zip(a1, a2): + suma1 += i * i + sumb1 += j*j + sum += i*j + cosine_sim = sum / ((sqrt(suma1))*(sqrt(sumb1))) + return cosine_sim + + + def jaccard_similarity(list1, list2): + intersection = len(list(set(list1).intersection(list2))) + union = (len(list1) + len(list2)) - intersection + return float(intersection) / union + + def average(x): + assert len(x) > 0 + return float(sum(x)) / len(x) + + def pearson_def(x, y): + assert len(x) == len(y) + n = len(x) + assert n > 0 + avg_x = check.average(x) + avg_y = check.average(y) + diffprod = 0 + xdiff2 = 0 + ydiff2 = 0 + for idx in range(n): + xdiff = x[idx] - avg_x + ydiff = y[idx] - avg_y + diffprod += xdiff * ydiff + xdiff2 += xdiff * xdiff + ydiff2 += ydiff * ydiff + + return diffprod / math.sqrt(xdiff2 * ydiff2) + + + + + def check_similarity(img1, img2): + # img1 = convertBase64(img1) + # img2 = convertBase64(img2) + helper1=TensorVector(img1) + helper2=TensorVector(img2) + vector = helper1.process() + vector2 = helper2.process() + + similarity = (check.jaccard_similarity(vector, vector2) + check.cosineSim(vector, vector2) + check.pearson_def(vector, vector2)) / 3 + # print(check.jaccard_similarity(vector, vector2)) + # print(check.cosineSim(vector, vector2)) + # print(check.pearson_def(vector, vector2)) + # img1 = TensorVector(img1).process() + # img2 = TensorVector(img2).process() + + return similarity \ No newline at end of file diff --git a/mlops/saved_model.pb b/mlops/saved_model.pb new file mode 100644 index 0000000..ed3007b Binary files /dev/null and b/mlops/saved_model.pb differ diff --git a/mlops/test.jpeg b/mlops/test.jpeg new file mode 100644 index 0000000..be4aab0 Binary files /dev/null and b/mlops/test.jpeg differ diff --git a/mlops/tf2-preview_mobilenet_v2_feature_vector_4 (1).tar.gz b/mlops/tf2-preview_mobilenet_v2_feature_vector_4 (1).tar.gz new file mode 100644 index 0000000..c438b6e Binary files /dev/null and b/mlops/tf2-preview_mobilenet_v2_feature_vector_4 (1).tar.gz differ diff --git a/mlops/variables/variables.data-00000-of-00001 b/mlops/variables/variables.data-00000-of-00001 new file mode 100644 index 0000000..37fd960 Binary files /dev/null and b/mlops/variables/variables.data-00000-of-00001 differ diff --git a/mlops/variables/variables.index b/mlops/variables/variables.index new file mode 100644 index 0000000..3dbd3db Binary files /dev/null and b/mlops/variables/variables.index differ diff --git a/mlverify.py b/mlverify.py new file mode 100644 index 0000000..dc4af73 --- /dev/null +++ b/mlverify.py @@ -0,0 +1,54 @@ +import tensorflow as tf +import tensorflow_hub as hub +import numpy as np +import os +import pandas as pd +import matplotlib.pyplot as plt +import base64 +from PIL import Image +import io +import math +from math import sqrt + +class TensorVector(object): + + def __init__(self, FileName=None): + self.FileName = FileName + + def process(self): + + img = tf.io.read_file(self.FileName) + img = tf.io.decode_jpeg(img, channels=3) + img = tf.image.resize_with_pad(img, 224, 224) + img = tf.image.convert_image_dtype(img,tf.float32)[tf.newaxis, ...] + features = embed(img) + feature_set = np.squeeze(features) + return list(feature_set) + + def convertBase64(FileName): + + # Return the Numpy array for a image + + with open(FileName, "rb") as f: + data = f.read() + + res = base64.b64encode(data) + + base64data = res.decode("UTF-8") + + imgdata = base64.b64decode(base64data) + + image = Image.open(io.BytesIO(imgdata)) + + return np.array(image) + + def cosineSim(a1,a2): + sum = 0 + suma1 = 0 + sumb1 = 0 + for i,j in zip(a1, a2): + suma1 += i * i + sumb1 += j*j + sum += i*j + cosine_sim = sum / ((sqrt(suma1))*(sqrt(sumb1))) + return cosine_sim \ No newline at end of file diff --git a/ocr.py b/ocr.py new file mode 100644 index 0000000..7afa95e --- /dev/null +++ b/ocr.py @@ -0,0 +1,112 @@ +# ocr module from easy ocr library + +''' + +How to use code +#from ocr import ankocr +#t=ankocr.get_text('test.jpeg') + + +t is the list of text detected in the document image +''' + + +# +from nis import cat +import convertapi +import requests +from PyPDF2 import PdfReader +import easyocr as eocr +import cv2 +import numpy as np +import os +import sys +import pickle as pkl +import PyPDF2 +import pdfplumber +from pdf2image import convert_from_path +class ankocr: + + def __init__(self): + print("kr raha hu ruk ja..") + + def get_text(image): + reader = eocr.Reader(['en']) + text = reader.readtext(image,detail=0) + return text + + def get_adharid(image): + t = ankocr.get_text(image) + try: + return t[t.index('MALE')+1] + except: + return [t.index('FEMALE')+1] + def get_adharname(image): + t=ankocr.get_text(image) + try: + return t[t.index('Government of India')+2] + except: + return t[t.index('GOVERNMENT OF INDIA')+2] + # pan + def get_panid(image): + t=ankocr.get_text(image) + try: + return t[t.index('Permanent Account Number Card')+1] + except: + prompt= "not found or wrong data! manual action required" + return prompt + + def get_panname(image): + t=ankocr.get_text(image) + try: + return t[t.index('NAME')+1] + except: + prompt= "not found or wrong data! manual action required" + return prompt + + # pdf extract + + + + + + + # jee allotment + def get_appno(image): + t=ankocr.get_text(image) + # print(t) + try: + return t[t.index('Application Number:')+1] + except: + prompt= "not found or wrong data! manual action required" + return prompt + # 12th marks + def get_12_roll(image): + t=ankocr.get_text(image) + # print(t) + try: + return t[t.index('12th Roll Number:')+1] + except: + prompt= "not found or wrong data! manual action required" + return prompt + + + + + +# print(ankocr.pdf_to_text('allotletter.pdf')) + # pdf to image by api + def api_p2i(file): + + convertapi.api_secret = 'cGujnI0KQ05odKHs' + convertapi.convert('png', { + 'File': 'allotletter.pdf' + }, from_format = 'pdf').save_files('save.png') + + return 'save.png' + + # delete image file + def delete(file): + os.remove(file) + return True + +# ankocr.delete('save.png') \ No newline at end of file diff --git a/original/admitcard.png b/original/admitcard.png new file mode 100644 index 0000000..919aff0 Binary files /dev/null and b/original/admitcard.png differ diff --git a/original/allot.png b/original/allot.png new file mode 100644 index 0000000..845ecc3 Binary files /dev/null and b/original/allot.png differ diff --git a/pan_musha.jpeg b/pan_musha.jpeg new file mode 100644 index 0000000..c245f75 Binary files /dev/null and b/pan_musha.jpeg differ diff --git a/roomkiphoto.jpeg b/roomkiphoto.jpeg new file mode 100644 index 0000000..f00f41e Binary files /dev/null and b/roomkiphoto.jpeg differ diff --git a/saved_model.pb b/saved_model.pb new file mode 100644 index 0000000..ed3007b Binary files /dev/null and b/saved_model.pb differ diff --git a/store.txt b/store.txt new file mode 100644 index 0000000..d0026e0 --- /dev/null +++ b/store.txt @@ -0,0 +1,3 @@ +adhar recogniser google collab + +https://colab.research.google.com/drive/1wTp7KWNQxYiNdRDlfSzAvSjdxlLQVepf?usp=sharing \ No newline at end of file diff --git a/svefy.py b/svefy.py new file mode 100644 index 0000000..1e0b113 --- /dev/null +++ b/svefy.py @@ -0,0 +1,52 @@ +import sewar.full_ref as sewa +import imgcompare +from PIL import Image +from skimage.metrics import structural_similarity +import cv2 +import numpy +class aina: + def isadhar(image): + image= Image.open(image) + newsize = (678, 381) + image = image.resize(newsize) + # ms=sewa.mse(image,'testadha3.jpg') + mssi=sewa.msssim(image,'testadha3.jpg') + si=sewa.ssim(image,'testadha3.jpg') + q=sewa.uqi(image,'testadha3.jpg') + vif=sewa.vifp(image,'testadha3.jpg') + if( mssi>0.9 and si>0.9 and q>0.9 and vif>0.9 ): + return True + else: + return False + + diff= imgcompare.image_diff_percent(image,'testadha3.jpg') + return diff<0.95 + +# def structural_sim(img1, img2): + +# sim, diff = structural_similarity(img1, img2, full=True) +# return sim + +# def orb_sim(img1, img2): +# # SIFT is no longer available in cv2 so using ORB + + +# orb = cv2.ORB_create() + +# # detect keypoints and descriptors +# kp_a, desc_a = orb.detectAndCompute(img1, None) +# kp_b, desc_b = orb.detectAndCompute(img2, None) + +# # define the bruteforce matcher object +# bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True) + +# #perform matches. +# matches = bf.match(desc_a, desc_b) +# #Look for similar regions with distance < 50. Goes from 0 to 100 so pick a number between. +# similar_regions = [i for i in matches if i.distance < 50] +# if len(matches) == 0: +# return 0 +# return len(similar_regions) / len(matches) + + + \ No newline at end of file diff --git a/tempCodeRunnerFile.py b/tempCodeRunnerFile.py new file mode 100644 index 0000000..c7f8bd2 --- /dev/null +++ b/tempCodeRunnerFile.py @@ -0,0 +1 @@ +print(tester.check_jee_allot('ALLOTMENT LETTER.pdf')) \ No newline at end of file diff --git a/test.jpeg b/test.jpeg new file mode 100644 index 0000000..be4aab0 Binary files /dev/null and b/test.jpeg differ diff --git a/test.py b/test.py new file mode 100644 index 0000000..9e8a3fc --- /dev/null +++ b/test.py @@ -0,0 +1,100 @@ +import logging +import sys +import numpy as np +import pandas as pd +import mlops.ml_verify as mas +for name in logging.Logger.manager.loggerDict.keys(): + logging.getLogger(name).setLevel(logging.CRITICAL) + +import os +os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' +from ocr import ankocr + +class tester: + def check_adhar(file): + image = ankocr.api_p2i(file) + bar=mas.check.check_similarity(image,'adhatest3.jpg') + t=ankocr.get_text(image) + ankocr.delete('save.png') + if(bar>0.40): + # print("similar") + + + # print(t) + if('GOVERNMENT OF INDIA' in t): + return True + else: + return False + else: + + # print(t) + if('GOVERNMENT OF INDIA' in t): + return True + else: + return False + + # test jee_admit card + def check_jee_allot(file): + image = ankocr.api_p2i(file) + bar=mas.check.check_similarity(image,'jee allot.jpg') + t=ankocr.get_text(image) + ankocr.delete('save.png') + if(bar>0.40): + # print("similar") + + # print(t) + if(('Provisional Admission Letter' in t) or ('Partial Admission Fee' in t)): + return True + else: + return False + else: + + # print(t) + if(('Provisional Admission Letter' in t) or ('Partial Admission Fee' in t) ): # error + return True + else: + return False + + + def check_pan(file): + image = ankocr.api_p2i(file) + bar=mas.check.check_similarity(image,'test.jpeg') + t=ankocr.get_text(image) + ankocr.delete('save.png') + if(bar>0.40): + # print("similar") + + # print(t) + if(('INCOME TAX DEPARTMENT' in t) or ('Permanent Account Number Card' in t)): + return True + else: + return False + else: + + # print(t) + if(('INCOME TAX DEPARTMENT' in t) or ('Permanent Account Number Card' in t)): + return True + else: + return False + + + # def pdf_to_image(pdf_file): + # from pdf2image import convert_from_path + # pages = convert_from_path(pdf_file, 500) + # for page in pages: + # page.save('out.jpg', 'JPEG') + + # return 'out.jpg' + + # def delete__image(image): + # os.remove(image) + # return True + + # def pdf_to_analysis(file): + # ifile= tester.pdf_to_image(file) + # pass + + # # PDF TO IMAGE WITHOUT PLOPPER + # def pdf_to_image_without_ploper(pdf_file): + # # pdf to image without ploper + # pass \ No newline at end of file diff --git a/variables/variables.data-00000-of-00001 b/variables/variables.data-00000-of-00001 new file mode 100644 index 0000000..37fd960 Binary files /dev/null and b/variables/variables.data-00000-of-00001 differ diff --git a/variables/variables.index b/variables/variables.index new file mode 100644 index 0000000..3dbd3db Binary files /dev/null and b/variables/variables.index differ