Spaces:
Sleeping
Sleeping
azaher1215
commited on
Commit
·
7b4a6cb
1
Parent(s):
4bef0fb
adding cache to the model loading
Browse files
model/search_script.py
CHANGED
@@ -8,6 +8,7 @@ import os
|
|
8 |
import sys
|
9 |
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..'))
|
10 |
from config import GOOGLE_DRIVE_FILES
|
|
|
11 |
|
12 |
|
13 |
class RecipeSearchSystem:
|
@@ -215,7 +216,7 @@ class RecipeSearchSystem:
|
|
215 |
|
216 |
return final_results
|
217 |
|
218 |
-
|
219 |
def search_for_recipes():
|
220 |
return RecipeSearchSystem()
|
221 |
|
@@ -224,10 +225,10 @@ if __name__ == "__main__":
|
|
224 |
|
225 |
search_system = RecipeSearchSystem()
|
226 |
test_queries = [
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
"beef steak",
|
232 |
"beef pasta",
|
233 |
"beef"
|
|
|
8 |
import sys
|
9 |
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..'))
|
10 |
from config import GOOGLE_DRIVE_FILES
|
11 |
+
import streamlit as st
|
12 |
|
13 |
|
14 |
class RecipeSearchSystem:
|
|
|
216 |
|
217 |
return final_results
|
218 |
|
219 |
+
@st.cache_resource
|
220 |
def search_for_recipes():
|
221 |
return RecipeSearchSystem()
|
222 |
|
|
|
225 |
|
226 |
search_system = RecipeSearchSystem()
|
227 |
test_queries = [
|
228 |
+
"chicken pasta italian quick dinner",
|
229 |
+
"chocolate cake dessert brownie baked healthy",
|
230 |
+
"healthy vegetarian salad tomato basil",
|
231 |
+
"quick easy dinner",
|
232 |
"beef steak",
|
233 |
"beef pasta",
|
234 |
"beef"
|
pages/3_Recipe_Recommendation.py
CHANGED
@@ -44,13 +44,15 @@ def recipe_search_page():
|
|
44 |
if results:
|
45 |
st.markdown(f"### Top {len(results)} recipe recommendations for: *'{query}'*")
|
46 |
st.markdown("<hr>", unsafe_allow_html=True)
|
47 |
-
|
|
|
|
|
48 |
for i, recipe in enumerate(results, 1):
|
49 |
steps_html = "".join([f"<li>{step.strip().capitalize()}</li>" for step in recipe.get("steps", [])])
|
50 |
description = recipe.get("description", "").strip().capitalize()
|
51 |
|
52 |
html_code = f"""
|
53 |
-
<div style=\"margin: 8px 0 8px 0; padding: 8px; border-radius: 12px; background-color: #fdfdfd; box-shadow: 0 2px 8px rgba(0,0,0,0.06); font-family: Arial, sans-serif; border: 1px solid #e0e0e0;\">
|
54 |
<div style=\"font-size: 18px; font-weight: bold; color: #333; margin-bottom: 8px;\"> {i}. {recipe['name']}</div>
|
55 |
|
56 |
<div style=\"margin: 4px 0 12px 0; font-size: 14px; color: #555;\">
|
@@ -81,7 +83,8 @@ def recipe_search_page():
|
|
81 |
{"<div style='margin-top: 10px; font-size: 13px;'><b>Steps:</b><ol style='margin: 6px 0 0 18px; padding: 0;'>" + steps_html + "</ol></div>" if steps_html else ""}
|
82 |
</div>
|
83 |
"""
|
84 |
-
|
|
|
85 |
|
86 |
else:
|
87 |
st.warning(f"No recipes found for '{query}' with a minimum rating of {min_rating}/5.0.")
|
|
|
44 |
if results:
|
45 |
st.markdown(f"### Top {len(results)} recipe recommendations for: *'{query}'*")
|
46 |
st.markdown("<hr>", unsafe_allow_html=True)
|
47 |
+
col1, col2 = st.columns(2)
|
48 |
+
columns = [col1, col2]
|
49 |
+
|
50 |
for i, recipe in enumerate(results, 1):
|
51 |
steps_html = "".join([f"<li>{step.strip().capitalize()}</li>" for step in recipe.get("steps", [])])
|
52 |
description = recipe.get("description", "").strip().capitalize()
|
53 |
|
54 |
html_code = f"""
|
55 |
+
<div style=\"width: auto; margin: 8px 0 8px 0; padding: 8px; border-radius: 12px; background-color: #fdfdfd; box-shadow: 0 2px 8px rgba(0,0,0,0.06); font-family: Arial, sans-serif; border: 1px solid #e0e0e0;\">
|
56 |
<div style=\"font-size: 18px; font-weight: bold; color: #333; margin-bottom: 8px;\"> {i}. {recipe['name']}</div>
|
57 |
|
58 |
<div style=\"margin: 4px 0 12px 0; font-size: 14px; color: #555;\">
|
|
|
83 |
{"<div style='margin-top: 10px; font-size: 13px;'><b>Steps:</b><ol style='margin: 6px 0 0 18px; padding: 0;'>" + steps_html + "</ol></div>" if steps_html else ""}
|
84 |
</div>
|
85 |
"""
|
86 |
+
with columns[(i-1) % 2]:
|
87 |
+
components.html(html_code, height=340, scrolling=True)
|
88 |
|
89 |
else:
|
90 |
st.warning(f"No recipes found for '{query}' with a minimum rating of {min_rating}/5.0.")
|