Sanjayraju30 commited on
Commit
6a56695
Β·
verified Β·
1 Parent(s): 6b64a33

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
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
- return f"{weight} g (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.")
17
 
18
  with gr.Row():
19
- image_input = gr.Image(type="pil", label="πŸ“· Upload or Capture Image")
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)")