Update app.py
Browse files
app.py
CHANGED
|
@@ -88,48 +88,17 @@ def predict_menu_inclusion(food_name, review_text, cook_time, prep_time, total_t
|
|
| 88 |
# Streamlit app with enhanced UI
|
| 89 |
st.set_page_config(page_title="Recipe Rating & Menu Optimization", layout="wide")
|
| 90 |
|
|
|
|
| 91 |
st.markdown(
|
| 92 |
"""
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
color: #3c3c7b;
|
| 100 |
-
}
|
| 101 |
-
.sidebar .sidebar-content {
|
| 102 |
-
background-color: #eef2f3;
|
| 103 |
-
}
|
| 104 |
-
.stButton>button {
|
| 105 |
-
background-color: #3c3c7b;
|
| 106 |
-
color: white;
|
| 107 |
-
border-radius: 5px;
|
| 108 |
-
font-size: 16px;
|
| 109 |
-
}
|
| 110 |
-
.stButton>button:hover {
|
| 111 |
-
background-color: #2c2c5a;
|
| 112 |
-
}
|
| 113 |
-
.prediction-box {
|
| 114 |
-
background-color: #eaf6f6;
|
| 115 |
-
padding: 20px;
|
| 116 |
-
border-radius: 10px;
|
| 117 |
-
box-shadow: 2px 2px 10px #ccc;
|
| 118 |
-
}
|
| 119 |
-
.success {
|
| 120 |
-
color: green;
|
| 121 |
-
font-weight: bold;
|
| 122 |
-
}
|
| 123 |
-
.error {
|
| 124 |
-
color: red;
|
| 125 |
-
font-weight: bold;
|
| 126 |
-
}
|
| 127 |
-
</style>
|
| 128 |
-
""",
|
| 129 |
-
unsafe_allow_html=True,
|
| 130 |
)
|
| 131 |
|
| 132 |
-
st.title("๐ Recipe Rating & Menu Optimization")
|
| 133 |
|
| 134 |
st.sidebar.header("๐ Enter Recipe Details")
|
| 135 |
food_name = st.sidebar.text_input("๐ด Food Name", value="Paneer Butter Masala")
|
|
@@ -143,14 +112,56 @@ fat = st.sidebar.number_input("๐ Fat (grams)", min_value=0.0, step=1.0, value
|
|
| 143 |
|
| 144 |
if st.sidebar.button("๐ฎ Predict"):
|
| 145 |
result = predict_menu_inclusion(food_name, review_text, cook_time, prep_time, total_time, protein, carbs, fat)
|
| 146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
st.subheader("Prediction Results")
|
| 148 |
-
st.
|
| 149 |
-
st.
|
| 150 |
-
|
|
|
|
| 151 |
f"**๐ฝ๏ธ Include on Menu:** "
|
| 152 |
-
f"<span
|
| 153 |
-
f"{'Yes' if
|
| 154 |
unsafe_allow_html=True,
|
| 155 |
)
|
| 156 |
-
|
|
|
|
|
|
| 88 |
# Streamlit app with enhanced UI
|
| 89 |
st.set_page_config(page_title="Recipe Rating & Menu Optimization", layout="wide")
|
| 90 |
|
| 91 |
+
st.title("๐ฒ๐ Recipe Rating & Menu Optimization ๐")
|
| 92 |
st.markdown(
|
| 93 |
"""
|
| 94 |
+
Welcome to the **Recipe Rating & Menu Optimization** app! ๐
|
| 95 |
+
This tool uses cutting-edge **AI and machine learning** ๐ง to help chefs, restaurateurs, and food enthusiasts ๐ฝ๏ธ predict recipe ratings and decide if a dish deserves a place on the menu. ๐
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
Let's get started and create culinary magic! โจ
|
| 99 |
+
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
)
|
| 101 |
|
|
|
|
| 102 |
|
| 103 |
st.sidebar.header("๐ Enter Recipe Details")
|
| 104 |
food_name = st.sidebar.text_input("๐ด Food Name", value="Paneer Butter Masala")
|
|
|
|
| 112 |
|
| 113 |
if st.sidebar.button("๐ฎ Predict"):
|
| 114 |
result = predict_menu_inclusion(food_name, review_text, cook_time, prep_time, total_time, protein, carbs, fat)
|
| 115 |
+
predicted_rating = result["PredictedRating"]
|
| 116 |
+
include_on_menu = result["IncludeOnMenu"]
|
| 117 |
+
|
| 118 |
+
# Custom progress bar with color based on inclusion
|
| 119 |
+
bar_color = "green" if include_on_menu else "red"
|
| 120 |
+
progress_percentage = int(predicted_rating * 20) # Convert rating (0-5) to percentage (0-100)
|
| 121 |
+
|
| 122 |
+
# Display animated progress bar
|
| 123 |
+
st.markdown(
|
| 124 |
+
f"""
|
| 125 |
+
<div style="
|
| 126 |
+
width: 100%;
|
| 127 |
+
background-color: #ddd;
|
| 128 |
+
border-radius: 10px;
|
| 129 |
+
margin-bottom: 15px;
|
| 130 |
+
">
|
| 131 |
+
<div style="
|
| 132 |
+
width: {progress_percentage}%;
|
| 133 |
+
height: 25px;
|
| 134 |
+
background-color: {bar_color};
|
| 135 |
+
border-radius: 10px;
|
| 136 |
+
text-align: center;
|
| 137 |
+
color: white;
|
| 138 |
+
line-height: 25px;
|
| 139 |
+
font-weight: bold;
|
| 140 |
+
animation: growBar 2s;
|
| 141 |
+
">
|
| 142 |
+
{progress_percentage}%
|
| 143 |
+
</div>
|
| 144 |
+
</div>
|
| 145 |
+
<style>
|
| 146 |
+
@keyframes growBar {{
|
| 147 |
+
from {{ width: 0%; }}
|
| 148 |
+
to {{ width: {progress_percentage}%; }}
|
| 149 |
+
}}
|
| 150 |
+
</style>
|
| 151 |
+
""",
|
| 152 |
+
unsafe_allow_html=True,
|
| 153 |
+
)
|
| 154 |
+
|
| 155 |
+
# Display prediction results
|
| 156 |
st.subheader("Prediction Results")
|
| 157 |
+
st.markdown(f"**๐ด Food Name:** {result['FoodName']}")
|
| 158 |
+
st.markdown(f"**โญ Predicted Rating:** {result['PredictedRating']:.1f}")
|
| 159 |
+
|
| 160 |
+
st.markdown(
|
| 161 |
f"**๐ฝ๏ธ Include on Menu:** "
|
| 162 |
+
f"<span style='color: {'green' if include_on_menu else 'red'}; font-weight: bold;'>"
|
| 163 |
+
f"{'Yes' if include_on_menu else 'No'}</span>",
|
| 164 |
unsafe_allow_html=True,
|
| 165 |
)
|
| 166 |
+
|
| 167 |
+
|