Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +1 -9
src/streamlit_app.py
CHANGED
@@ -8,13 +8,9 @@ st.title("βοΈ Auto Weight Logger")
|
|
8 |
|
9 |
img_data = st.camera_input("π· Capture the weight display")
|
10 |
|
11 |
-
# β
Add a confirmation the photo was captured
|
12 |
-
st.write("πΈ Waiting for image capture...")
|
13 |
-
|
14 |
if img_data:
|
15 |
-
st.
|
16 |
|
17 |
-
# β
Check file size
|
18 |
if len(img_data.getvalue()) > 5 * 1024 * 1024:
|
19 |
st.error("β Image too large (>5MB). Please try again.")
|
20 |
st.stop()
|
@@ -25,20 +21,16 @@ if img_data:
|
|
25 |
with st.spinner("π Extracting weight..."):
|
26 |
weight, confidence = extract_weight_from_image(image)
|
27 |
|
28 |
-
# β
DEBUG display
|
29 |
st.write(f"π οΈ DEBUG: weight = {weight}, confidence = {confidence}")
|
30 |
|
31 |
-
# β
Retry logic
|
32 |
if not weight or confidence < 80:
|
33 |
st.error(f"β οΈ OCR confidence too low ({int(confidence)}%). Please retake the image.")
|
34 |
if st.button("π Try Again"):
|
35 |
st.experimental_rerun()
|
36 |
st.stop()
|
37 |
|
38 |
-
# β
Show result
|
39 |
st.success(f"β
Detected Weight: {weight} g (Confidence: {int(confidence)}%)")
|
40 |
|
41 |
-
# β
Salesforce integration
|
42 |
device_id = "BAL-001"
|
43 |
image_url = ""
|
44 |
|
|
|
8 |
|
9 |
img_data = st.camera_input("π· Capture the weight display")
|
10 |
|
|
|
|
|
|
|
11 |
if img_data:
|
12 |
+
st.success("β
Image captured successfully!")
|
13 |
|
|
|
14 |
if len(img_data.getvalue()) > 5 * 1024 * 1024:
|
15 |
st.error("β Image too large (>5MB). Please try again.")
|
16 |
st.stop()
|
|
|
21 |
with st.spinner("π Extracting weight..."):
|
22 |
weight, confidence = extract_weight_from_image(image)
|
23 |
|
|
|
24 |
st.write(f"π οΈ DEBUG: weight = {weight}, confidence = {confidence}")
|
25 |
|
|
|
26 |
if not weight or confidence < 80:
|
27 |
st.error(f"β οΈ OCR confidence too low ({int(confidence)}%). Please retake the image.")
|
28 |
if st.button("π Try Again"):
|
29 |
st.experimental_rerun()
|
30 |
st.stop()
|
31 |
|
|
|
32 |
st.success(f"β
Detected Weight: {weight} g (Confidence: {int(confidence)}%)")
|
33 |
|
|
|
34 |
device_id = "BAL-001"
|
35 |
image_url = ""
|
36 |
|