Simp4me commited on
Commit
8e77fc9
·
verified ·
1 Parent(s): 1f9eb35

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +16 -6
src/streamlit_app.py CHANGED
@@ -1,11 +1,7 @@
1
-
2
-
3
  import streamlit as st
 
4
  from PIL import Image
5
 
6
-
7
-
8
-
9
  st.image("src/RezbinLogo.jpg", width=150)
10
  st.title("Rezbin AI 📷")
11
  st.write("Upload an image of your waste before throwing it.")
@@ -13,6 +9,20 @@ st.write("Upload an image of your waste before throwing it.")
13
  uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "png", "jpeg"])
14
 
15
  if uploaded_file is not None:
 
16
  img = Image.open(uploaded_file)
17
  st.image(img, caption="Uploaded Image", use_container_width=True)
18
- st.markdown('<div class="orange-background">This is a can. You earn 0.50</div>', unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
+ import requests
3
  from PIL import Image
4
 
 
 
 
5
  st.image("src/RezbinLogo.jpg", width=150)
6
  st.title("Rezbin AI 📷")
7
  st.write("Upload an image of your waste before throwing it.")
 
9
  uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "png", "jpeg"])
10
 
11
  if uploaded_file is not None:
12
+ # Show preview
13
  img = Image.open(uploaded_file)
14
  st.image(img, caption="Uploaded Image", use_container_width=True)
15
+
16
+ # Send to AI API
17
+ files = {"file": uploaded_file.getvalue()}
18
+ try:
19
+ response = requests.post("https://your-api-url.com/predict", files=files)
20
+ if response.status_code == 200:
21
+ result = response.json()
22
+ label = result.get("label", "Unknown item")
23
+ reward = result.get("reward", 0)
24
+ st.markdown(f'<div class="orange-background">This is a {label}. You earn {reward:.2f}</div>', unsafe_allow_html=True)
25
+ else:
26
+ st.error(f"Error: {response.status_code} - {response.text}")
27
+ except Exception as e:
28
+ st.error(f"Failed to connect to model: {e}")