Internship_task / Home.py
yashpat85's picture
Upload 2 files
c80d070 verified
import joblib
import streamlit as st
from prediction import predict_single_image
knn_model = joblib.load('models/knn_model.joblib')
svm_model = joblib.load('models/svm_model.joblib')
random_forest_model = joblib.load('models/random_forest_model.joblib')
def show_error_popup(message):
st.error(message, icon="🚨")
st.set_page_config(layout="wide")
st.title('CASIA PALMPRINT DATASET')
st.markdown('By Yash Patel')
st.header('Add Palmprint Image')
uploaded_file = st.file_uploader("Choose an image", type=["jpg", "png", "jpeg"])
st.header("Available Models")
option = st.selectbox(
"Available Models",
("SVM", "KNN","Random Forest"),
)
predicted_label =""
col1, col2= st.columns(2)
if uploaded_file is not None:
with col1:
image_data = uploaded_file.read()
st.image(image_data, caption="Uploaded Image")
with col2:
if option=="SVM":
predicted_label = predict_single_image(svm_model,image_data)
elif option=="KNN":
predicted_label = predict_single_image(knn_model, image_data)
elif option=="Random Forest":
predicted_label = predict_single_image(random_forest_model, image_data)
else:
p = "Other Models are still under training due to overfitting"
print(predicted_label)
st.markdown("""
<style>
.big-font {
display: flex;
align-items:center;
justify-content: center;
font-size:50px !important;
color:green;
height: 50vh;
}
</style>
""", unsafe_allow_html=True)
st.markdown(f'<div class="big-font">{predicted_label}</div>', unsafe_allow_html=True)
else:
show_error_popup("Please Upload Image...")