Spaces:
Sleeping
Sleeping
import streamlit as st | |
import requests | |
import pandas as pd | |
from PIL import Image | |
import io | |
st.title("🌳 Tree Disease Diagnosis System") | |
uploaded_file = st.file_uploader("Upload an image of a tree leaf", type=["jpg", "jpeg", "png"]) | |
if uploaded_file: | |
image = Image.open(uploaded_file) | |
st.image(image, caption="Uploaded Image", use_column_width=True) | |
with st.spinner("Diagnosing..."): | |
response = requests.post( | |
"http://localhost:8000/predict", | |
files={"file": uploaded_file.getvalue()} | |
) | |
result = response.json() | |
st.success(f"Prediction: **{result['prediction']}**") | |
st.write(f"Confidence: {result['confidence']:.2%}") | |
st.write(f"Suggested Treatment: {result['treatment']}") | |
st.write(f"Fertilizer Advice: {result['fertilizer']}") | |
st.write(f"AI Explanation: {result['explanation']}") | |
if result["alert"]: | |
st.error("⚠️ High-Risk Disease Detected!") | |