CoolFace
Apppublic

Siri23/workoutplan

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
app.py34 linesDownload Raw Back to root
1import gradio as gr2from transformers import pipeline3 4# Load the GPT model5gpt_model = pipeline('text-generation', model='distilgpt2')6 7# Function to generate workout plan8def 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 Interface14def workout_interface(goal, days):15    workout_plan = generate_workout_plan(goal, days)16    return workout_plan17 18# Create the Gradio interface19interface = gr.Interface(20    fn=workout_interface,21    inputs=[22        gr.Textbox(label="Goal (e.g., weight loss, muscle gain)", placeholder="Enter your goal"),23        gr.Slider(minimum=1, maximum=30, value=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 app31if __name__ == "__main__":32    interface.launch()33 34