Sanjayraju30 commited on
Commit
325b9a0
·
verified ·
1 Parent(s): a3a81c9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -27,12 +27,12 @@ def process_image(image):
27
  ist = pytz.timezone('Asia/Kolkata')
28
  timestamp = datetime.now(ist).strftime("%Y-%m-%d %H:%M:%S IST")
29
 
30
- if not weight or ("No valid" in weight and "OCR:" in weight):
31
- return f"❌ OCR Failed: {weight}", "", image, gr.update(visible=True)
32
 
33
  numeric_match = re.search(r'\d{1,5}(\.\d{1,3})?', weight)
34
  if not numeric_match:
35
- return "❌ Could not extract number", "", image, gr.update(visible=True)
36
 
37
  numeric_value = float(numeric_match.group())
38
  unit = "kg" if "kg" in weight.lower() else "g"
 
27
  ist = pytz.timezone('Asia/Kolkata')
28
  timestamp = datetime.now(ist).strftime("%Y-%m-%d %H:%M:%S IST")
29
 
30
+ if not weight or weight.startswith("Error"):
31
+ return f"❌ OCR Error: {weight}", "", image, gr.update(visible=True)
32
 
33
  numeric_match = re.search(r'\d{1,5}(\.\d{1,3})?', weight)
34
  if not numeric_match:
35
+ return f"❌ Could not extract number | OCR: {weight}", "", image, gr.update(visible=True)
36
 
37
  numeric_value = float(numeric_match.group())
38
  unit = "kg" if "kg" in weight.lower() else "g"