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()