File size: 1,443 Bytes
4a22b0c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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)