Spaces:
Sleeping
Sleeping
import gradio as gr | |
import cv2 | |
import numpy as np | |
from gradio import components | |
from skimage.metrics import structural_similarity as ssim | |
def checkSimilarity(real_signature, testing_signature): | |
real_signature = cv2.resize(real_signature, (300, 300)) | |
testing_signature = cv2.resize(testing_signature, (300, 300)) | |
# result = match(path1=path1, path2=path2) | |
real_signature = cv2.cvtColor(real_signature, cv2.COLOR_BGR2GRAY) | |
testing_signature = cv2.cvtColor(testing_signature, cv2.COLOR_BGR2GRAY) | |
similarity_value = "{:.2f}".format(ssim(real_signature, testing_signature)*100) | |
# Mach Threshold | |
THRESHOLD = 75 | |
#def print_result(real_signature, testing_signature): | |
if(float(similarity_value) >= THRESHOLD): | |
label = "Signatures Match" | |
else: | |
label = "Signatures Do Not Match" | |
return (similarity_value, label ) | |
def print_result(real_signature, testing_signature): | |
if(float(similarity_value) <= THRESHOLD): | |
return "Signatures Match" | |
else: | |
return "Signatures Do Not Match" | |
inputs = [ | |
gr.Image(label="Real Signature"), | |
gr.Image(label="Testing Signature") | |
] | |
output = [ | |
gr.Textbox(label="Verification Result"), | |
gr.Textbox(label="Similarity Value") | |
] | |
gr.Interface(fn = checkSimilarity , inputs=inputs, outputs=output,allow_flagging="never", title="SIGNATURE VERIFICATION SYSTEM",description="Upload the real signature and the testing signature to check their similarity.").launch(debug=True, share=True) | |