ArpitChb commited on
Commit
7372787
·
verified ·
1 Parent(s): ea739a6

Upload app.py

Browse files
Files changed (1) hide show
  1. src/app.py +31 -0
src/app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+ from PIL import Image
4
+ import io
5
+
6
+ # Streamlit app title
7
+ st.title("🥔 Potato Leaf Disease Classifier")
8
+
9
+ # Upload image
10
+ uploaded_file = st.file_uploader("Upload a potato leaf image", type=["jpg", "jpeg", "png"])
11
+
12
+ if uploaded_file is not None:
13
+ # Show preview
14
+ image = Image.open(uploaded_file)
15
+ st.image(image, caption="Uploaded Image", use_column_width=True)
16
+
17
+ # Button to trigger prediction
18
+ if st.button("Predict"):
19
+ with st.spinner("Classifying..."):
20
+ # Send image to FastAPI backend
21
+ response = requests.post(
22
+ "http://localhost:8000/predict",
23
+ files={"file": uploaded_file.getvalue()}
24
+ )
25
+
26
+ if response.status_code == 200:
27
+ result = response.json()
28
+ st.success(f"🌿 Predicted Class: **{result['class']}**")
29
+ st.info(f"📈 Confidence: **{result['confidence'] * 100:.2f}%**")
30
+ else:
31
+ st.error("Prediction failed. Please try again.")