File size: 1,048 Bytes
ca60849
7d57e58
 
ca60849
7d57e58
 
ca60849
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a589019
 
ca60849
 
 
 
 
 
 
 
 
a589019
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
import gradio as gr
from transformers import pipeline

# Load the GPT model
gpt_model = pipeline('text-generation', model='distilgpt2')

# Function to generate workout plan
def generate_workout_plan(goal, days):
    prompt = f"Generate a {days}-day workout plan for {goal}."
    generated_text = gpt_model(prompt, max_length=150, num_return_sequences=1)[0]['generated_text']
    return generated_text.strip()

# Gradio Interface
def workout_interface(goal, days):
    workout_plan = generate_workout_plan(goal, days)
    return workout_plan

# Create the Gradio interface
interface = gr.Interface(
    fn=workout_interface,
    inputs=[
        gr.Textbox(label="Goal (e.g., weight loss, muscle gain)", placeholder="Enter your goal"),
        gr.Slider(minimum=1, maximum=30, value=1, label="Number of days")
    ],
    outputs="text",
    title="AI-Generated Workout Plan",
    description="Enter your fitness goal and number of days to generate a personalized workout plan."
)

# Launch the app
if __name__ == "__main__":
    interface.launch()