Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -7,24 +7,13 @@ def process_image(img):
|
|
7 |
if img is None:
|
8 |
return "No image uploaded", None, None
|
9 |
|
10 |
-
# Get IST time
|
11 |
ist_time = datetime.now(pytz.timezone("Asia/Kolkata")).strftime("%d-%m-%Y %I:%M:%S %p")
|
12 |
-
|
13 |
-
# Run OCR
|
14 |
weight, confidence = extract_weight_from_image(img)
|
|
|
15 |
|
16 |
-
# Format output with "kg"
|
17 |
-
if weight.replace('.', '', 1).isdigit():
|
18 |
-
formatted_weight = f"{weight} kg (Confidence: {confidence}%)"
|
19 |
-
else:
|
20 |
-
formatted_weight = f"{weight} (Confidence: {confidence}%)"
|
21 |
-
|
22 |
-
return formatted_weight, ist_time, img
|
23 |
-
|
24 |
-
# Gradio UI
|
25 |
with gr.Blocks(title="⚖️ Auto Weight Logger") as demo:
|
26 |
gr.Markdown("# ⚖️ Auto Weight Logger")
|
27 |
-
gr.Markdown("Upload or capture an image of a **digital scale display**. It will auto-detect the weight in
|
28 |
|
29 |
with gr.Row():
|
30 |
image_input = gr.Image(type="pil", label="📷 Upload or Capture Image")
|
|
|
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} (Confidence: {confidence}%)", ist_time, img
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
with gr.Blocks(title="⚖️ Auto Weight Logger") as demo:
|
15 |
gr.Markdown("# ⚖️ Auto Weight Logger")
|
16 |
+
gr.Markdown("Upload or capture an image of a **digital scale display**. It will auto-detect the weight in kilograms.")
|
17 |
|
18 |
with gr.Row():
|
19 |
image_input = gr.Image(type="pil", label="📷 Upload or Capture Image")
|