Spaces:
Runtime error
Runtime error
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +15 -15
src/streamlit_app.py
CHANGED
@@ -25,26 +25,26 @@ def extract_weight_text(image):
|
|
25 |
return None
|
26 |
|
27 |
st.set_page_config(page_title="Auto Weight Logger", layout="centered")
|
28 |
-
st.title("π¦ Auto Weight Logger
|
29 |
-
st.write("Upload or
|
30 |
|
31 |
-
|
32 |
-
|
33 |
|
34 |
-
|
35 |
|
36 |
-
if
|
37 |
-
image = Image.open(
|
38 |
-
st.image(image, caption="Original
|
39 |
|
40 |
-
|
41 |
-
st.image(
|
42 |
|
43 |
-
weight = extract_weight_text(
|
44 |
|
45 |
if weight:
|
46 |
-
|
47 |
-
st.success(f"β
Weight Detected:
|
48 |
-
st.info(f"
|
49 |
else:
|
50 |
-
st.error("β
|
|
|
25 |
return None
|
26 |
|
27 |
st.set_page_config(page_title="Auto Weight Logger", layout="centered")
|
28 |
+
st.title("π¦ Auto Weight Logger")
|
29 |
+
st.write("Upload or click image of weight display. App will read the weight.")
|
30 |
|
31 |
+
uploaded_file = st.file_uploader("Upload Image", type=["jpg", "jpeg", "png"])
|
32 |
+
camera_image = st.camera_input("Or Capture Image")
|
33 |
|
34 |
+
input_image = uploaded_file or camera_image
|
35 |
|
36 |
+
if input_image:
|
37 |
+
image = Image.open(input_image)
|
38 |
+
st.image(image, caption="Original", use_column_width=True)
|
39 |
|
40 |
+
processed = preprocess_image(image)
|
41 |
+
st.image(processed, caption="Processed", use_column_width=True)
|
42 |
|
43 |
+
weight = extract_weight_text(processed)
|
44 |
|
45 |
if weight:
|
46 |
+
time_now = datetime.now(pytz.timezone('Asia/Kolkata')).strftime('%Y-%m-%d %H:%M:%S')
|
47 |
+
st.success(f"β
Weight Detected: {weight} kg")
|
48 |
+
st.info(f"β±οΈ Captured At: {time_now}")
|
49 |
else:
|
50 |
+
st.error("β Weight not detected. Try clearer image.")
|