File size: 2,223 Bytes
bc311ed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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()