Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
from PIL import Image
|
3 |
from datetime import datetime
|
|
|
4 |
from ocr_engine import extract_weight
|
5 |
|
6 |
def process_image(image):
|
@@ -9,18 +10,22 @@ def process_image(image):
|
|
9 |
|
10 |
try:
|
11 |
weight = extract_weight(image)
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
14 |
except Exception as e:
|
15 |
return f"Error: {str(e)}", "", None
|
16 |
|
17 |
with gr.Blocks() as demo:
|
18 |
gr.Markdown("## π· Auto Weight Logger β Hugging Face OCR Edition")
|
19 |
-
gr.Markdown("Upload a
|
20 |
|
21 |
image_input = gr.Image(type="pil", label="π Upload or Capture Image")
|
22 |
-
|
23 |
detect_btn = gr.Button("π Detect Weight")
|
|
|
24 |
weight_out = gr.Textbox(label="Detected Weight")
|
25 |
time_out = gr.Textbox(label="Captured At (IST)")
|
26 |
snapshot = gr.Image(label="Snapshot")
|
|
|
1 |
import gradio as gr
|
2 |
from PIL import Image
|
3 |
from datetime import datetime
|
4 |
+
import pytz
|
5 |
from ocr_engine import extract_weight
|
6 |
|
7 |
def process_image(image):
|
|
|
10 |
|
11 |
try:
|
12 |
weight = extract_weight(image)
|
13 |
+
|
14 |
+
# Get IST time
|
15 |
+
ist = pytz.timezone('Asia/Kolkata')
|
16 |
+
now_ist = datetime.now(ist).strftime("%Y-%m-%d %H:%M:%S IST")
|
17 |
+
|
18 |
+
return weight, now_ist, image
|
19 |
except Exception as e:
|
20 |
return f"Error: {str(e)}", "", None
|
21 |
|
22 |
with gr.Blocks() as demo:
|
23 |
gr.Markdown("## π· Auto Weight Logger β Hugging Face OCR Edition")
|
24 |
+
gr.Markdown("Upload a digital weight image. Auto-detects value & unit (kg or grams).")
|
25 |
|
26 |
image_input = gr.Image(type="pil", label="π Upload or Capture Image")
|
|
|
27 |
detect_btn = gr.Button("π Detect Weight")
|
28 |
+
|
29 |
weight_out = gr.Textbox(label="Detected Weight")
|
30 |
time_out = gr.Textbox(label="Captured At (IST)")
|
31 |
snapshot = gr.Image(label="Snapshot")
|