Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,17 +7,22 @@ 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 |
-
|
|
|
|
|
|
|
| 13 |
|
| 14 |
with gr.Blocks(title="βοΈ Auto Weight Logger") as demo:
|
| 15 |
-
gr.Markdown("
|
| 16 |
-
gr.Markdown("Upload or capture an image of a
|
| 17 |
|
| 18 |
with gr.Row():
|
| 19 |
-
image_input = gr.Image(type="pil", label="
|
| 20 |
-
output_weight = gr.Textbox(label="βοΈ Detected Weight")
|
| 21 |
|
| 22 |
with gr.Row():
|
| 23 |
timestamp = gr.Textbox(label="π Captured At (IST)")
|
|
|
|
| 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 |
+
# Extract weight and confidence
|
| 14 |
weight, confidence = extract_weight_from_image(img)
|
| 15 |
+
|
| 16 |
+
# Format output in kg
|
| 17 |
+
return f"{weight} kg (Confidence: {confidence}%)", ist_time, img
|
| 18 |
|
| 19 |
with gr.Blocks(title="βοΈ Auto Weight Logger") as demo:
|
| 20 |
+
gr.Markdown("## βοΈ Auto Weight Logger")
|
| 21 |
+
gr.Markdown("π· **Upload or capture an image of a digital weight scale.** The app will auto-detect the weight in kilograms using OCR.")
|
| 22 |
|
| 23 |
with gr.Row():
|
| 24 |
+
image_input = gr.Image(type="pil", label="Upload / Capture Image")
|
| 25 |
+
output_weight = gr.Textbox(label="βοΈ Detected Weight (in kg)")
|
| 26 |
|
| 27 |
with gr.Row():
|
| 28 |
timestamp = gr.Textbox(label="π Captured At (IST)")
|