forked from mathurlagsalot/SignatureSherlock
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
45 lines (35 loc) · 1.15 KB
/
app.py
File metadata and controls
45 lines (35 loc) · 1.15 KB
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
44
45
import streamlit as st
import tensorflow as tf
import numpy as np
from PIL import Image
import cv2
def load_model():
model = tf.keras.models.load_model('image.hdf5')
return model
def predict_class(image, model):
image = Image.open(image)
resized_image = image.resize((224, 224))
grayscale_image = resized_image.convert('L')
img_array = np.array(grayscale_image)
img = img_array.reshape(-1, 224, 224, 1) / 255.0
prediction = model.predict(img)
return prediction[0][0]
model = load_model()
st.title('Signature Sherlock : Handwritten Signature Classifier')
file = st.file_uploader("Upload an image of a signature", type=["jpg", "png"])
if file is None:
st.text('Waiting for upload....')
else:
slot = st.empty()
slot.text('Running inference....')
test_image = Image.open(file)
st.image(test_image, caption="Input Image", width=400)
pred = predict_class(file, model)
st.text(f'Prediction Probability: {pred}')
if pred < 0.4998:
result = "real"
else:
result = "forged"
output = 'The signature is ' + result
slot.text('Done')
st.success(output)