vashu2425 commited on
Commit
b413c92
ยท
verified ยท
1 Parent(s): 1fc0058

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +56 -45
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
- <style>
94
- .main {
95
- background-color: #f5f5f5;
96
- font-family: Arial, sans-serif;
97
- }
98
- h1 {
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
- st.markdown("<div class='prediction-box'>", unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
  st.subheader("Prediction Results")
148
- st.write(f"**๐Ÿด Food Name:** {result['FoodName']}")
149
- st.write(f"**โญ Predicted Rating:** {result['PredictedRating']}")
150
- st.write(
 
151
  f"**๐Ÿฝ๏ธ Include on Menu:** "
152
- f"<span class='{'success' if result['IncludeOnMenu'] else 'error'}'>"
153
- f"{'Yes' if result['IncludeOnMenu'] else 'No'}</span>",
154
  unsafe_allow_html=True,
155
  )
156
- st.markdown("</div>", unsafe_allow_html=True)
 
 
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
+