Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -15,7 +15,7 @@ def process_image(img):
|
|
15 |
try:
|
16 |
# Convert Gradio image (PIL) to process
|
17 |
if img is None:
|
18 |
-
return "No image provided",
|
19 |
|
20 |
# Resize if > 5MB
|
21 |
img_bytes = img.tobytes()
|
@@ -33,8 +33,10 @@ def process_image(img):
|
|
33 |
# Extract weight
|
34 |
weight, confidence, unit = extract_weight_from_image(img)
|
35 |
|
36 |
-
# Return results
|
37 |
-
|
|
|
|
|
38 |
except Exception as e:
|
39 |
logging.error(f"Error in process_image: {str(e)}")
|
40 |
return f"Error: {str(e)}", "", None
|
|
|
15 |
try:
|
16 |
# Convert Gradio image (PIL) to process
|
17 |
if img is None:
|
18 |
+
return "No image provided", "", None
|
19 |
|
20 |
# Resize if > 5MB
|
21 |
img_bytes = img.tobytes()
|
|
|
33 |
# Extract weight
|
34 |
weight, confidence, unit = extract_weight_from_image(img)
|
35 |
|
36 |
+
# Return results with improved feedback
|
37 |
+
result = f"{weight} {unit} (Confidence: {confidence:.2f}%)" if confidence > 0 else "No weight detected"
|
38 |
+
timestamp = f"Processed at {datetime.now(pytz.timezone('Asia/Kolkata')).strftime('%d-%m-%Y %I:%M:%S %p IST')}"
|
39 |
+
return result, timestamp, img
|
40 |
except Exception as e:
|
41 |
logging.error(f"Error in process_image: {str(e)}")
|
42 |
return f"Error: {str(e)}", "", None
|