teganmosi commited on
Commit
1f6b20c
Β·
verified Β·
1 Parent(s): b5194d6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -6,7 +6,10 @@ from sklearn.model_selection import train_test_split, GridSearchCV
6
  import gradio as gr
7
  import os
8
  import warnings
 
 
9
  warnings.filterwarnings('ignore')
 
10
 
11
  # Dataset generation
12
  np.random.seed(42)
@@ -268,9 +271,13 @@ with gr.Blocks(css="""
268
  text, snack = predict_snack(mood, time_of_day, hunger_level, sentiment, snack_type)
269
  image_path = f"assets/{snack.replace(' ', '_')}.jpeg"
270
  if not os.path.exists(image_path):
 
271
  image_path = f"assets/{snack.replace(' ', '_')}.png" # Check for .png as fallback
272
  if not os.path.exists(image_path):
 
273
  image_path = "assets/placeholder.jpeg" # Final fallback
 
 
274
  return text, image_path
275
 
276
  predict_btn.click(
@@ -281,7 +288,7 @@ with gr.Blocks(css="""
281
 
282
  gr.HTML("""
283
  <div class='footer'>
284
- <p>Built with ❀️ by [Your Twitter Handle] | Powered by <a href='https://x.ai' style='color: #FF4500;'>xAI</a> πŸš€</p>
285
  <p>Follow my #WeeklyMLProjects for more! 🍟</p>
286
  </div>
287
  """)
 
6
  import gradio as gr
7
  import os
8
  import warnings
9
+ import logging
10
+
11
  warnings.filterwarnings('ignore')
12
+ logging.basicConfig(level=logging.INFO)
13
 
14
  # Dataset generation
15
  np.random.seed(42)
 
271
  text, snack = predict_snack(mood, time_of_day, hunger_level, sentiment, snack_type)
272
  image_path = f"assets/{snack.replace(' ', '_')}.jpeg"
273
  if not os.path.exists(image_path):
274
+ logging.info(f"Image not found: {image_path}")
275
  image_path = f"assets/{snack.replace(' ', '_')}.png" # Check for .png as fallback
276
  if not os.path.exists(image_path):
277
+ logging.info(f"PNG fallback not found: {image_path}, using placeholder")
278
  image_path = "assets/placeholder.jpeg" # Final fallback
279
+ if not os.path.exists(image_path):
280
+ logging.error(f"Placeholder not found: {image_path}")
281
  return text, image_path
282
 
283
  predict_btn.click(
 
288
 
289
  gr.HTML("""
290
  <div class='footer'>
291
+ <p>Built with ❀️ by @teganmosi πŸš€</p>
292
  <p>Follow my #WeeklyMLProjects for more! 🍟</p>
293
  </div>
294
  """)