| import gradio as gr |
|
|
| |
| def fitness_advice(goal, duration, equipment): |
| """ |
| Provides personalized fitness suggestions based on user input. |
| """ |
| advice = "ποΈββοΈ Personalized Fitness Plan:\n\n" |
|
|
| |
| 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" |
|
|
| |
| 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" |
|
|
| |
| 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 |
|
|
|
|
| |
| 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() |
|
|