Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,13 +3,14 @@ from datetime import datetime
|
|
3 |
import pytz
|
4 |
from ocr_engine import extract_weight_from_image
|
5 |
|
|
|
6 |
def process_image(img):
|
7 |
if img is None:
|
8 |
-
return "No image uploaded", None, None
|
9 |
|
10 |
ist_time = datetime.now(pytz.timezone("Asia/Kolkata")).strftime("%d-%m-%Y %I:%M:%S %p")
|
11 |
-
weight, confidence = extract_weight_from_image(img)
|
12 |
-
return f"{weight} kg (Confidence: {confidence}%)", ist_time, img
|
13 |
|
14 |
with gr.Blocks(title="βοΈ Auto Weight Logger") as demo:
|
15 |
gr.Markdown("## βοΈ Auto Weight Logger")
|
@@ -23,7 +24,9 @@ with gr.Blocks(title="βοΈ Auto Weight Logger") as demo:
|
|
23 |
timestamp = gr.Textbox(label="π Captured At (IST)")
|
24 |
snapshot = gr.Image(label="πΈ Snapshot Image")
|
25 |
|
|
|
|
|
26 |
submit = gr.Button("π Detect Weight")
|
27 |
-
submit.click(process_image, inputs=image_input, outputs=[output_weight, timestamp, snapshot])
|
28 |
|
29 |
demo.launch()
|
|
|
3 |
import pytz
|
4 |
from ocr_engine import extract_weight_from_image
|
5 |
|
6 |
+
# NEW: Add debug list to see OCR text
|
7 |
def process_image(img):
|
8 |
if img is None:
|
9 |
+
return "No image uploaded", None, None, "No OCR output"
|
10 |
|
11 |
ist_time = datetime.now(pytz.timezone("Asia/Kolkata")).strftime("%d-%m-%Y %I:%M:%S %p")
|
12 |
+
weight, confidence, raw_text = extract_weight_from_image(img)
|
13 |
+
return f"{weight} kg (Confidence: {confidence}%)", ist_time, img, raw_text
|
14 |
|
15 |
with gr.Blocks(title="βοΈ Auto Weight Logger") as demo:
|
16 |
gr.Markdown("## βοΈ Auto Weight Logger")
|
|
|
24 |
timestamp = gr.Textbox(label="π Captured At (IST)")
|
25 |
snapshot = gr.Image(label="πΈ Snapshot Image")
|
26 |
|
27 |
+
debug_output = gr.Textbox(label="πͺ΅ Raw OCR Output")
|
28 |
+
|
29 |
submit = gr.Button("π Detect Weight")
|
30 |
+
submit.click(process_image, inputs=image_input, outputs=[output_weight, timestamp, snapshot, debug_output])
|
31 |
|
32 |
demo.launch()
|