Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -5,11 +5,11 @@ 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
|
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,10 +23,7 @@ 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 |
-
with gr.Row():
|
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
|
31 |
|
32 |
demo.launch()
|
|
|
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 |
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()
|