Prototype / app.py
WatermelonPapaya's picture
Update app.py
d88725b verified
from helper.model import fetch_model, preprocess_image, classify_image
from PIL import Image
import streamlit as st
import io
st.set_page_config(
page_title="VGNet Prototype",
page_icon="🤖",
)
st.title("Using Deep Learning Techniques on Philippine Corn Leaf Disease Classification")
st.write("This is the prototype of VGNet model trained using different optimizers")
st.write("Thesis Project by Group BDK of Mapua University")
st.image(
"resources/corn-field.png",
caption='A corn field',
width=700
)
st.header("How to use?")
st.markdown("""
1. Select a model.
2. Select an image (Leaf Blight, Gray Leaf Spot, Common Rust).
3. Upload the selected image here.
4. The model will output the classification result if the image is (Leaf Blight, Gray Leaf Spot, Common Rust).
""")
uploaded_image = st.file_uploader(
"Choose an image...",
type=["bmp", "png", "jpg", "jpeg"]
)
model_labels = [
"VGNet + Adam",
"VGNet + Adan",
"VGNet + AdamW",
"VGNet + RMSprop",
"VGNet + AdaBound"
]
model_option = st.selectbox(
"Select a Model:",
list(range(len(model_labels))),
format_func=lambda ind: model_labels[ind]
)
# Check if an image was uploaded
if uploaded_image is not None:
# Preprocess the image
image = preprocess_image(
Image.open(
uploaded_image
)
)
# Fetch the model
model_optimizer_name = ["adam", "adan", "adamw", "rmsprop", "adabound"]
model = fetch_model(model_optimizer_name[model_option])
# Perform classification
predicted_label = classify_image(model, image)
# Display Prediction Result
st.image(image, clamp = True)
st.write(f"Prediction Result: {predicted_label}")