Spaces:
Sleeping

School_Project / app.py
IndujaMuthu's picture
Upload app.py
4b23564 verified
Raw History Blame Contribute Delete
2.8 kB
#!/usr/bin/env python
# coding: utf-8
# In[12]:
import gradio as gr
def recommend(name, age, grade, study_hours, sleep_hours, junk_food_score, activity_level, interests):
# Convert inputs
age = int(age)
study_hours = float(study_hours)
sleep_hours = float(sleep_hours)
junk_food_score = int(junk_food_score)
interests = interests.lower()
# 🎭 Extracurricular Recommendation
if "music" in interests:
extracurricular = "Join a music club or take online classes."
elif "drawing" in interests:
extracurricular = "Participate in art competitions or clubs."
elif "sports" in interests:
extracurricular = "Join a sports academy or team."
else:
extracurricular = "Explore clubs based on your interests."
# πŸŽ“ Academic Feedback
if study_hours >= 5 and sleep_hours >= 7:
academic_feedback = "Excellent academic balance!"
elif study_hours >= 3:
academic_feedback = "Good efforts, just a little more focus needed."
else:
academic_feedback = "Try improving study and sleep habits."
# 🍽 Food Lifestyle
if junk_food_score > 7:
food_advice = "Reduce junk foods and hydrate better!"
elif junk_food_score > 4:
food_advice = "Moderate junk food consumption. Focus on healthier meals."
else:
food_advice = "Very good eating habits! Keep going."
# 😴 Attitude Suggestion
if sleep_hours >= 8:
attitude = "Great attitude! Rest and energy are balanced."
elif sleep_hours >= 6:
attitude = "Stable, but better rest can boost energy."
else:
attitude = "Improve your sleeping pattern for better focus."
# πŸ“‹ Final Output using Markdown for Bold
return (
f"**πŸ‘‹ Hello {name}!**\n\n"
f"**🎭 Recommended Extracurricular Activity:** {extracurricular}\n\n"
f"**πŸŽ“ Academic Performance Feedback:** {academic_feedback}\n\n"
f"**🍽 Food Lifestyle Advice:** {food_advice}\n\n"
f"**😴 Attitude Suggestion:** {attitude}"
)
# Gradio UI
demo = gr.Interface(
fn=recommend,
inputs=[
gr.Textbox(label="Name"),
gr.Number(label="Age"),
gr.Textbox(label="Grade"),
gr.Textbox(label="Study Hours (e.g. 3.5)"),
gr.Textbox(label="Sleep Hours (e.g. 6.5)"),
gr.Textbox(label="Junk Food Score (1-10)"),
gr.Dropdown(["Low", "Medium", "High"], label="Activity Level"),
gr.Textbox(label="Interests (comma separated, e.g. music, drawing)")
],
outputs=gr.Markdown(), # βœ… correct now
title="πŸŽ“ Student Recommendation System",
description="Enter student details to get dynamic recommendations on extracurriculars, academics, food lifestyle, and attitude."
)
demo.launch()
# In[ ]: