Spaces:
Running
on
Zero
Running
on
Zero
Update breed_recommendation.py
Browse files- breed_recommendation.py +12 -1
breed_recommendation.py
CHANGED
@@ -64,6 +64,7 @@ def create_recommendation_tab(UserPreferences, get_breed_recommendations, format
|
|
64 |
|
65 |
with gr.Tab("Find by Description"):
|
66 |
description_input, description_search_btn, description_output = create_description_search_tab()
|
|
|
67 |
|
68 |
def on_find_match_click(*args):
|
69 |
try:
|
@@ -117,6 +118,9 @@ def create_recommendation_tab(UserPreferences, get_breed_recommendations, format
|
|
117 |
|
118 |
def on_description_search(description: str):
|
119 |
try:
|
|
|
|
|
|
|
120 |
matcher = SmartBreedMatcher(dog_data)
|
121 |
breed_recommendations = matcher.match_user_preference(description, top_n=10)
|
122 |
|
@@ -194,10 +198,16 @@ def create_recommendation_tab(UserPreferences, get_breed_recommendations, format
|
|
194 |
print(f"Warning: Ranking inconsistency detected!")
|
195 |
print(f"#{rec['rank']-1} score: {prev_score:.4f}")
|
196 |
print(f"#{rec['rank']} score: {rec['final_score']:.4f}")
|
|
|
|
|
|
|
197 |
|
198 |
return format_recommendation_html(final_recommendations)
|
199 |
|
200 |
except Exception as e:
|
|
|
|
|
|
|
201 |
import traceback
|
202 |
error_details = traceback.format_exc()
|
203 |
print(f"Detailed error:\n{error_details}")
|
@@ -234,5 +244,6 @@ def create_recommendation_tab(UserPreferences, get_breed_recommendations, format
|
|
234 |
'recommendation_output': recommendation_output,
|
235 |
'description_input': description_input,
|
236 |
'description_search_btn': description_search_btn,
|
237 |
-
'description_output': description_output
|
|
|
238 |
}
|
|
|
64 |
|
65 |
with gr.Tab("Find by Description"):
|
66 |
description_input, description_search_btn, description_output = create_description_search_tab()
|
67 |
+
|
68 |
|
69 |
def on_find_match_click(*args):
|
70 |
try:
|
|
|
118 |
|
119 |
def on_description_search(description: str):
|
120 |
try:
|
121 |
+
loading_info.update(visible=True)
|
122 |
+
description_output.update(visible=False)
|
123 |
+
|
124 |
matcher = SmartBreedMatcher(dog_data)
|
125 |
breed_recommendations = matcher.match_user_preference(description, top_n=10)
|
126 |
|
|
|
198 |
print(f"Warning: Ranking inconsistency detected!")
|
199 |
print(f"#{rec['rank']-1} score: {prev_score:.4f}")
|
200 |
print(f"#{rec['rank']} score: {rec['final_score']:.4f}")
|
201 |
+
|
202 |
+
loading_info.update(visible=False)
|
203 |
+
description_output.update(visible=True)
|
204 |
|
205 |
return format_recommendation_html(final_recommendations)
|
206 |
|
207 |
except Exception as e:
|
208 |
+
loading_info.update(visible=False)
|
209 |
+
description_output.update(visible=True)
|
210 |
+
|
211 |
import traceback
|
212 |
error_details = traceback.format_exc()
|
213 |
print(f"Detailed error:\n{error_details}")
|
|
|
244 |
'recommendation_output': recommendation_output,
|
245 |
'description_input': description_input,
|
246 |
'description_search_btn': description_search_btn,
|
247 |
+
'description_output': description_output,
|
248 |
+
'loading_info': loading_info
|
249 |
}
|