import streamlit as st
import cv2
import base64
from detection import *
background_image = """
"""
st.markdown(background_image, unsafe_allow_html=True)
st.html("
Face Detection Web App
")
vis = True
db_mode = st.checkbox("Add to data base")
if db_mode:
vis = False
if not vis:
st.html("Storing Image to Database
")
input_method = st.checkbox("Camera Mode")
cam_inp , file_inp = None , None
if input_method:
cam_inp = st.camera_input(label="Say Cheese!")
else:
file_inp = st.file_uploader("Upload a Photo!")
if cam_inp != None:
file = cam_inp
else:
file = file_inp
if file and vis:
min_conf = st.number_input("Enter the desired confidence value:" , min_value=0.0 , max_value=1.0, step=0.10, disabled= not vis , value=0.65)
if min_conf:
img , labels = detect_and_fetch(file , min_confidence= min_conf)
st.image(img , caption='Detections' , use_column_width=True)
st.header('Detected:')
labels = set(labels)
for i in labels:
if i is not "Unknown":
st.text(i)
else:
name = st.text_input("Write the Name of Person" , disabled= vis)
if name:
process = write_and_upsert(file , name)
if process:
st.text("Uploaded Sucessfully!")