raghav commited on
Commit ·
1d4ebe5
1
Parent(s): 4b3c68c
Add error visibility and debug logging
Browse files
app.py
CHANGED
|
@@ -22,15 +22,22 @@ def classify_material(image):
|
|
| 22 |
return "Please upload an image", "", ""
|
| 23 |
|
| 24 |
try:
|
|
|
|
|
|
|
| 25 |
# Call protected space API
|
| 26 |
result = backend.predict(image=image, api_name="/classify_material")
|
| 27 |
|
|
|
|
|
|
|
| 28 |
# result is tuple: (classification, confidence, reasoning)
|
| 29 |
return result[0], result[1], result[2]
|
| 30 |
|
| 31 |
except Exception as e:
|
|
|
|
| 32 |
error_msg = str(e)
|
| 33 |
-
|
|
|
|
|
|
|
| 34 |
|
| 35 |
|
| 36 |
# Custom CSS (same as original)
|
|
@@ -170,4 +177,4 @@ with gr.Blocks(css=custom_css, title="Netra AI - Material Classifier") as demo:
|
|
| 170 |
|
| 171 |
# Launch
|
| 172 |
if __name__ == "__main__":
|
| 173 |
-
demo.launch()
|
|
|
|
| 22 |
return "Please upload an image", "", ""
|
| 23 |
|
| 24 |
try:
|
| 25 |
+
print(f"📤 Calling backend API with image type: {type(image)}")
|
| 26 |
+
|
| 27 |
# Call protected space API
|
| 28 |
result = backend.predict(image=image, api_name="/classify_material")
|
| 29 |
|
| 30 |
+
print(f"📥 Backend response: {result}")
|
| 31 |
+
|
| 32 |
# result is tuple: (classification, confidence, reasoning)
|
| 33 |
return result[0], result[1], result[2]
|
| 34 |
|
| 35 |
except Exception as e:
|
| 36 |
+
import traceback
|
| 37 |
error_msg = str(e)
|
| 38 |
+
full_error = traceback.format_exc()
|
| 39 |
+
print(f"❌ Error: {full_error}")
|
| 40 |
+
return f"❌ Classification Error", "", f"Error: {error_msg}"
|
| 41 |
|
| 42 |
|
| 43 |
# Custom CSS (same as original)
|
|
|
|
| 177 |
|
| 178 |
# Launch
|
| 179 |
if __name__ == "__main__":
|
| 180 |
+
demo.launch(show_error=True)
|