Spaces:
Build error
Build error
MarkusEssl
commited on
Commit
Β·
c37f4c0
1
Parent(s):
172e9ef
- Welcome.py +1 -1
- pages/{2_GAN_cleaning.py β 2_Cleaning.py} +0 -0
- pages/{3_Signify.py β 3_Verify.py} +3 -3
- pages/4_Siamese.py +0 -84
- results/media/documents/1.png +0 -0
- results/media/documents/2.png +0 -0
- results/media/documents/Sample1.png +0 -0
- results/media/documents/Sample2.png +0 -0
- results/media/documents/acr64d00.png +0 -0
- results/media/documents/ajy01c00.png +0 -0
Welcome.py
CHANGED
|
@@ -13,9 +13,9 @@ st.markdown(
|
|
| 13 |
"""
|
| 14 |
Signfiy is an open-source project addressing core problems in signature verification with the help of deep learning.
|
| 15 |
### 3 Tasks
|
| 16 |
-
- Signature Verification (Siamese Model)
|
| 17 |
- Signature Detection (Object detection with YOLO)
|
| 18 |
- Signature Cleaning (Cycle-GAN)
|
|
|
|
| 19 |
|
| 20 |
**π Select a demo from the sidebar**
|
| 21 |
### Want to learn more?
|
|
|
|
| 13 |
"""
|
| 14 |
Signfiy is an open-source project addressing core problems in signature verification with the help of deep learning.
|
| 15 |
### 3 Tasks
|
|
|
|
| 16 |
- Signature Detection (Object detection with YOLO)
|
| 17 |
- Signature Cleaning (Cycle-GAN)
|
| 18 |
+
- Signature Verification (Siamese Model)
|
| 19 |
|
| 20 |
**π Select a demo from the sidebar**
|
| 21 |
### Want to learn more?
|
pages/{2_GAN_cleaning.py β 2_Cleaning.py}
RENAMED
|
File without changes
|
pages/{3_Signify.py β 3_Verify.py}
RENAMED
|
@@ -18,7 +18,7 @@ YOLO_RESULT = 'results/yolov5/'
|
|
| 18 |
YOLO_OP = 'crops/DLSignature/'
|
| 19 |
|
| 20 |
|
| 21 |
-
st.set_page_config(page_title="Signature
|
| 22 |
|
| 23 |
st.markdown("# Detect Signatures")
|
| 24 |
st.sidebar.header("Plotting Demo")
|
|
@@ -66,7 +66,7 @@ transform_valid = transforms.Compose([
|
|
| 66 |
transforms.Resize((124, 124)),
|
| 67 |
])
|
| 68 |
|
| 69 |
-
st.session_state.predict = st.button('
|
| 70 |
if st.session_state.predict:
|
| 71 |
device = torch.device('cpu')
|
| 72 |
backbone = models.efficientnet_v2_s(pretrained=True)
|
|
@@ -75,6 +75,6 @@ if st.session_state.predict:
|
|
| 75 |
model.load_state_dict(weights)
|
| 76 |
img1, img2 = transform_valid(img1).unsqueeze(0), transform_valid(img2).unsqueeze(0)
|
| 77 |
prediction = model(img1,img2)
|
| 78 |
-
st.write(f"
|
| 79 |
|
| 80 |
|
|
|
|
| 18 |
YOLO_OP = 'crops/DLSignature/'
|
| 19 |
|
| 20 |
|
| 21 |
+
st.set_page_config(page_title="Signature Verificaton", page_icon="π")
|
| 22 |
|
| 23 |
st.markdown("# Detect Signatures")
|
| 24 |
st.sidebar.header("Plotting Demo")
|
|
|
|
| 66 |
transforms.Resize((124, 124)),
|
| 67 |
])
|
| 68 |
|
| 69 |
+
st.session_state.predict = st.button('Verify Signatures')
|
| 70 |
if st.session_state.predict:
|
| 71 |
device = torch.device('cpu')
|
| 72 |
backbone = models.efficientnet_v2_s(pretrained=True)
|
|
|
|
| 75 |
model.load_state_dict(weights)
|
| 76 |
img1, img2 = transform_valid(img1).unsqueeze(0), transform_valid(img2).unsqueeze(0)
|
| 77 |
prediction = model(img1,img2)
|
| 78 |
+
st.write(f"The signatures match with a probability of {str(round(float(prediction), 2))}%")
|
| 79 |
|
| 80 |
|
pages/4_Siamese.py
DELETED
|
@@ -1,84 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
|
| 3 |
-
import glob
|
| 4 |
-
import os
|
| 5 |
-
import time
|
| 6 |
-
|
| 7 |
-
import numpy as np
|
| 8 |
-
import streamlit as st
|
| 9 |
-
|
| 10 |
-
MEDIA_ROOT = 'results/media/signatures/'
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
st.set_page_config(page_title="Signature Detection", page_icon="π")
|
| 14 |
-
|
| 15 |
-
st.markdown("# Detect Signatures")
|
| 16 |
-
st.sidebar.header("Plotting Demo")
|
| 17 |
-
st.write(
|
| 18 |
-
"Detect signatures of the given image!"
|
| 19 |
-
)
|
| 20 |
-
|
| 21 |
-
if "predict" not in st.session_state:
|
| 22 |
-
# Initialize session state.
|
| 23 |
-
st.session_state.update({
|
| 24 |
-
# Default page.
|
| 25 |
-
"predict": False,
|
| 26 |
-
})
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
def select_document():
|
| 30 |
-
'''
|
| 31 |
-
Selects the document from the dropdown menu and displays the image.
|
| 32 |
-
Returns an integer represeting the id of the document selected.
|
| 33 |
-
'''
|
| 34 |
-
left, right = st.columns(2) # Create two columns
|
| 35 |
-
# dropdown box in left column
|
| 36 |
-
selection_left = str(left.selectbox('Select document to run inference 1', [1, 2]))
|
| 37 |
-
selection_right = str(right.selectbox('Select document to run inference 2', [1, 2]))
|
| 38 |
-
# select corresponding document image from media/documents
|
| 39 |
-
selection_image_left = MEDIA_ROOT+selection_left+'.png'
|
| 40 |
-
left.image(selection_image_left, use_column_width='always')
|
| 41 |
-
|
| 42 |
-
selection_image_right = MEDIA_ROOT+selection_right+'.png'
|
| 43 |
-
right.image(selection_image_right, use_column_width='always')
|
| 44 |
-
return selection_image_left, selection_image_right
|
| 45 |
-
|
| 46 |
-
def upload_document():
|
| 47 |
-
img1 = st.file_uploader("left_img")
|
| 48 |
-
img2 = st.file_uploader("right_img")
|
| 49 |
-
|
| 50 |
-
def compare(img1, img2):
|
| 51 |
-
print("images are very similar .. yuhu (hard coded func not implemented yet)")
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
selection = select_document()
|
| 55 |
-
# call YOLOv5 detection fn on all images in the document folder.
|
| 56 |
-
#detect.detect(MEDIA_ROOT)
|
| 57 |
-
|
| 58 |
-
st.session_state.predict = st.button('Compare signatures')
|
| 59 |
-
if st.session_state.predict:
|
| 60 |
-
|
| 61 |
-
if not st.session_state.img1 or not st.session_state.img2:
|
| 62 |
-
|
| 63 |
-
with st.empty():
|
| 64 |
-
|
| 65 |
-
st.write("Upload both images first!!")
|
| 66 |
-
time.sleep(2)
|
| 67 |
-
st.session_state.predict = False
|
| 68 |
-
|
| 69 |
-
compare(img1, img2)
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
# get the path where last detected results are stored.
|
| 75 |
-
latest_detection = max(glob.glob(os.path.join(YOLO_RESULT, '*/')), key=os.path.getmtime)
|
| 76 |
-
# resize and add top and bottom padding to detected sigantures.
|
| 77 |
-
# gan model expects ips in that particular format.
|
| 78 |
-
|
| 79 |
-
# selects and display the detections of the document which the user selected.
|
| 80 |
-
#selection_detection =latest_detection + YOLO_OP + selection + '.jpg'
|
| 81 |
-
#st.image(selection_detection)
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
results/media/documents/1.png
DELETED
|
Binary file (96.6 kB)
|
|
|
results/media/documents/2.png
DELETED
|
Binary file (165 kB)
|
|
|
results/media/documents/Sample1.png
ADDED
|
results/media/documents/Sample2.png
ADDED
|
results/media/documents/acr64d00.png
ADDED
|
results/media/documents/ajy01c00.png
ADDED
|