Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +4 -13
src/streamlit_app.py
CHANGED
@@ -4,8 +4,6 @@ import cv2
|
|
4 |
from paddleocr import PaddleOCR
|
5 |
from PIL import Image
|
6 |
import re
|
7 |
-
from datetime import datetime
|
8 |
-
import pytz
|
9 |
|
10 |
ocr = PaddleOCR(use_angle_cls=True, lang='en')
|
11 |
|
@@ -24,10 +22,7 @@ def extract_weight_text(image):
|
|
24 |
return match.group()
|
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 |
|
@@ -35,16 +30,12 @@ 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 |
-
|
|
|
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.
|
|
|
4 |
from paddleocr import PaddleOCR
|
5 |
from PIL import Image
|
6 |
import re
|
|
|
|
|
7 |
|
8 |
ocr = PaddleOCR(use_angle_cls=True, lang='en')
|
9 |
|
|
|
22 |
return match.group()
|
23 |
return None
|
24 |
|
|
|
25 |
st.title("π¦ Auto Weight Logger")
|
|
|
|
|
26 |
uploaded_file = st.file_uploader("Upload Image", type=["jpg", "jpeg", "png"])
|
27 |
camera_image = st.camera_input("Or Capture Image")
|
28 |
|
|
|
30 |
|
31 |
if input_image:
|
32 |
image = Image.open(input_image)
|
33 |
+
st.image(image, caption="Original Image", use_column_width=True)
|
|
|
|
|
|
|
34 |
|
35 |
+
processed_image = preprocess_image(image)
|
36 |
+
weight = extract_weight_text(processed_image)
|
37 |
|
38 |
if weight:
|
|
|
39 |
st.success(f"β
Weight Detected: {weight} kg")
|
|
|
40 |
else:
|
41 |
+
st.error("β Weight not detected.")
|