Siri23 commited on
Commit
ca60849
·
verified ·
1 Parent(s): aa1da0f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -4
app.py CHANGED
@@ -1,8 +1,32 @@
 
1
  from transformers import pipeline
2
 
3
- # Load the model
4
  gpt_model = pipeline('text-generation', model='distilgpt2')
5
 
6
- # Generate a workout plan
7
- prompt = "Generate a 1-day workout plan for weight loss."
8
- workout_plan = gpt_model(prompt, max_length=150, num_return_sequences=1)[0]['generated_text']
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # Load the GPT model
5
  gpt_model = pipeline('text-generation', model='distilgpt2')
6
 
7
+ # Function to generate workout plan
8
+ def generate_workout_plan(goal, days):
9
+ prompt = f"Generate a {days}-day workout plan for {goal}."
10
+ generated_text = gpt_model(prompt, max_length=150, num_return_sequences=1)[0]['generated_text']
11
+ return generated_text.strip()
12
+
13
+ # Gradio Interface
14
+ def workout_interface(goal, days):
15
+ workout_plan = generate_workout_plan(goal, days)
16
+ return workout_plan
17
+
18
+ # Create the Gradio interface
19
+ interface = gr.Interface(
20
+ fn=workout_interface,
21
+ inputs=[
22
+ gr.inputs.Textbox(label="Goal (e.g., weight loss, muscle gain)", placeholder="Enter your goal"),
23
+ gr.inputs.Slider(minimum=1, maximum=30, default=1, label="Number of days")
24
+ ],
25
+ outputs="text",
26
+ title="AI-Generated Workout Plan",
27
+ description="Enter your fitness goal and number of days to generate a personalized workout plan."
28
+ )
29
+
30
+ # Launch the app
31
+ if __name__ == "__main__":
32
+ interface.launch()