|
|
import streamlit as st |
|
|
import requests |
|
|
from PIL import Image |
|
|
import io |
|
|
|
|
|
|
|
|
st.title("π₯ Potato Leaf Disease Classifier") |
|
|
|
|
|
|
|
|
uploaded_file = st.file_uploader("Upload a potato leaf image", type=["jpg", "jpeg", "png"]) |
|
|
|
|
|
if uploaded_file is not None: |
|
|
|
|
|
image = Image.open(uploaded_file) |
|
|
st.image(image, caption="Uploaded Image", use_column_width=True) |
|
|
|
|
|
|
|
|
if st.button("Predict"): |
|
|
with st.spinner("Classifying..."): |
|
|
|
|
|
response = requests.post( |
|
|
"http://localhost:8000/predict", |
|
|
files={"file": uploaded_file.getvalue()} |
|
|
) |
|
|
|
|
|
if response.status_code == 200: |
|
|
result = response.json() |
|
|
st.success(f"πΏ Predicted Class: **{result['class']}**") |
|
|
st.info(f"π Confidence: **{result['confidence'] * 100:.2f}%**") |
|
|
else: |
|
|
st.error("Prediction failed. Please try again.") |
|
|
|