hellocute / app.py
Rashi-jan's picture
Create app.py
bc311ed verified
import gradio as gr
# ----------------- FITNESS LOGIC ----------------- #
def fitness_advice(goal, duration, equipment):
"""
Provides personalized fitness suggestions based on user input.
"""
advice = "πŸ‹οΈβ€β™‚οΈ Personalized Fitness Plan:\n\n"
# Duration check
if duration < 15:
advice += "πŸ”Ή Try short, high-intensity exercises like HIIT.\n"
elif duration <= 45:
advice += "πŸ”Ή Moderate workout combining cardio and strength training.\n"
else:
advice += "πŸ”Ή Long sessions: focus on endurance, strength, and flexibility.\n"
# Goal-specific advice
if goal.lower() == "weight loss":
advice += "πŸ”Ή Focus on cardio, HIIT, and full-body workouts.\n"
elif goal.lower() == "muscle gain":
advice += "πŸ”Ή Focus on strength training, compound exercises, progressive overload.\n"
elif goal.lower() == "flexibility":
advice += "πŸ”Ή Yoga, Pilates, and dynamic stretching are recommended.\n"
else:
advice += "πŸ”Ή Mix cardio, strength, and flexibility for general fitness.\n"
# Equipment
if equipment.lower() in ["none", "bodyweight"]:
advice += "πŸ”Ή Use bodyweight exercises like push-ups, squats, planks.\n"
else:
advice += f"πŸ”Ή Incorporate your {equipment} into your workouts.\n"
advice += "\nπŸ’‘ Remember: consistency + proper diet = results!"
return advice
# ----------------- GRADIO UI ----------------- #
with gr.Blocks(title="Physical Fitness Assistant") as demo:
gr.Markdown("## πŸ‹οΈ Physical Fitness Assistant")
gr.Markdown("Enter your fitness goals and preferences to get a personalized plan.")
with gr.Row():
goal = gr.Dropdown(choices=["Weight Loss", "Muscle Gain", "Flexibility", "General Fitness"], label="Fitness Goal")
duration = gr.Slider(minimum=10, maximum=120, step=5, label="Workout Duration (minutes)")
equipment = gr.Textbox(label="Available Equipment (type 'None' for bodyweight)")
output = gr.Textbox(label="Your Fitness Plan", lines=10)
gr.Button("Get Fitness Plan").click(
fn=fitness_advice,
inputs=[goal, duration, equipment],
outputs=output
)
demo.launch()