Spaces:
Running
Running
feat: add error handling for multiple image search and visual display
Browse files- web/interface.py +19 -1
web/interface.py
CHANGED
|
@@ -74,7 +74,13 @@ class WebInterface:
|
|
| 74 |
|
| 75 |
def multiple_image_search(self, img, threshold, results):
|
| 76 |
"""Wrapper for the multiple image search function"""
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
def format_results_for_visual_display(self, json_results):
|
| 80 |
"""
|
|
@@ -89,6 +95,18 @@ class WebInterface:
|
|
| 89 |
if not json_results:
|
| 90 |
return [], "<p>No faces detected or no matches found.</p>"
|
| 91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
gallery_images = []
|
| 93 |
html_parts = []
|
| 94 |
|
|
|
|
| 74 |
|
| 75 |
def multiple_image_search(self, img, threshold, results):
|
| 76 |
"""Wrapper for the multiple image search function"""
|
| 77 |
+
try:
|
| 78 |
+
return image_search_performers(img, self.data_manager, threshold, results)
|
| 79 |
+
except ValueError as e:
|
| 80 |
+
if "No faces found" in str(e):
|
| 81 |
+
return {"error": "No faces detected in the uploaded image. Please try uploading an image with visible faces."}
|
| 82 |
+
else:
|
| 83 |
+
raise e
|
| 84 |
|
| 85 |
def format_results_for_visual_display(self, json_results):
|
| 86 |
"""
|
|
|
|
| 95 |
if not json_results:
|
| 96 |
return [], "<p>No faces detected or no matches found.</p>"
|
| 97 |
|
| 98 |
+
# Handle error case
|
| 99 |
+
if isinstance(json_results, dict) and "error" in json_results:
|
| 100 |
+
error_html = f"""
|
| 101 |
+
<div class="performer-card">
|
| 102 |
+
<div class="face-info">
|
| 103 |
+
<h3 style="color: #ff6b6b;">Error</h3>
|
| 104 |
+
<p>{json_results['error']}</p>
|
| 105 |
+
</div>
|
| 106 |
+
</div>
|
| 107 |
+
"""
|
| 108 |
+
return [], error_html
|
| 109 |
+
|
| 110 |
gallery_images = []
|
| 111 |
html_parts = []
|
| 112 |
|