Spaces:
Running
Running
Update app.py
Browse files
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 ("
|
31 |
-
return f"❌ OCR
|
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"
|