Sanjayraju30 commited on
Commit
b6c69fc
Β·
verified Β·
1 Parent(s): 52e7bf6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -12,7 +12,7 @@ def process_image(image):
12
  ist = pytz.timezone('Asia/Kolkata')
13
  timestamp = datetime.now(ist).strftime("%Y-%m-%d %H:%M:%S IST")
14
 
15
- if not weight:
16
  return "❌ Unable to detect. Try again with clearer image.", "", image, gr.update(visible=True)
17
 
18
  return weight, timestamp, image, gr.update(visible=False)
@@ -32,7 +32,7 @@ with gr.Blocks(css=".gr-button {background-color: #2e7d32 !important; color: whi
32
  detect_btn = gr.Button("πŸš€ Detect Weight")
33
 
34
  with gr.Row():
35
- weight_out = gr.Textbox(label="πŸ“¦ Detected Weight", placeholder="e.g., 72.4 kg", show_copy_button=True)
36
  time_out = gr.Textbox(label="πŸ•’ Captured At (IST)", placeholder="e.g., 2025-06-30 14:32:10")
37
 
38
  snapshot = gr.Image(label="πŸ“Έ Snapshot Preview")
@@ -43,7 +43,7 @@ with gr.Blocks(css=".gr-button {background-color: #2e7d32 !important; color: whi
43
  inputs=[], outputs=[weight_out, time_out, snapshot, retake_btn])
44
 
45
  gr.Markdown("""
46
- <p style='text-align: center; color: gray;'>Tip: Ensure image is glare-free and focused.<br>Developed by Shalu β€’ Hugging Face OCR ⚑</p>
47
  """)
48
 
49
  demo.launch()
 
12
  ist = pytz.timezone('Asia/Kolkata')
13
  timestamp = datetime.now(ist).strftime("%Y-%m-%d %H:%M:%S IST")
14
 
15
+ if not weight or "No valid" in weight:
16
  return "❌ Unable to detect. Try again with clearer image.", "", image, gr.update(visible=True)
17
 
18
  return weight, timestamp, image, gr.update(visible=False)
 
32
  detect_btn = gr.Button("πŸš€ Detect Weight")
33
 
34
  with gr.Row():
35
+ weight_out = gr.Textbox(label="πŸ“¦ Detected Weight", placeholder="e.g., 97.9 kg", show_copy_button=True)
36
  time_out = gr.Textbox(label="πŸ•’ Captured At (IST)", placeholder="e.g., 2025-06-30 14:32:10")
37
 
38
  snapshot = gr.Image(label="πŸ“Έ Snapshot Preview")
 
43
  inputs=[], outputs=[weight_out, time_out, snapshot, retake_btn])
44
 
45
  gr.Markdown("""
46
+ <p style='text-align: center; color: gray;'>Tip: Ensure image is clear and flat.<br>Developed by Shalu β€’ Hugging Face OCR ⚑</p>
47
  """)
48
 
49
  demo.launch()