ArpitChb's picture
Upload streamlit_app.py
4c7e10f verified
import streamlit as st
import requests
from PIL import Image
import io
# Streamlit app title
st.title("πŸ₯” Potato Leaf Disease Classifier")
# Upload image
uploaded_file = st.file_uploader("Upload a potato leaf image", type=["jpg", "jpeg", "png"])
if uploaded_file is not None:
# Show preview
image = Image.open(uploaded_file)
st.image(image, caption="Uploaded Image", use_column_width=True)
# Button to trigger prediction
if st.button("Predict"):
with st.spinner("Classifying..."):
# Send image to FastAPI backend
response = requests.post(
"https://potato-disease-classification-ltgh.onrender.com/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.")