import glob import os import sys import time import numpy as np import streamlit as st from SOURCE.yolo_files import detect MEDIA_ROOT = 'results/media/documents/' YOLO_RESULT = 'results/yolov5/' YOLO_OP = 'crops/DLSignature/' st.set_page_config(page_title="Signature Detection", page_icon="📈") st.markdown("# Detect Signatures") st.write("""Detect the signature of the given document!""") st.session_state.predict = False if "predict" not in st.session_state else st.session_state.predict left, right = st.columns(2) selection = str(left.selectbox('Select document', os.listdir(MEDIA_ROOT))) selection_image_left = MEDIA_ROOT+selection left.image(selection_image_left, use_column_width='always') detect.detect(MEDIA_ROOT) st.session_state.selection = selection st.session_state.predict = st.button('Detect') if st.session_state.predict: latest_detection = max(glob.glob(os.path.join(YOLO_RESULT, '*/')), key=os.path.getmtime) selection_detection =latest_detection + YOLO_OP + selection[:-4] + '.jpg' st.image(selection_detection)