Download app.py from Harry2406/Module_2: direct link, hf CLI and curl.
- Browser
- Download file 1.36 kB
-
https://huggingface.co/spaces/Harry2406/Module_2/resolve/main/app.py
- Command line
-
hf download hf://spaces/Harry2406/Module_2/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Harry2406/Module_2/resolve/main/app.py
1.36 kB
| import os | |
| import request | |
| import | |
| from transformers import pipeline | |
| st.set_page{ | |
| def load_model(): | |
| return pipeline( | |
| "text-generation", | |
| model="google/flan-t5-base" | |
| ) | |
| generator = load_model() | |
| if not name: | |
| st.error("Please enter your name.") | |
| elif not equipment: | |
| st.error("Please select at least one equipment option.") | |
| elif bmi is None: | |
| st.error("Please enter valid height and weight.") | |
| else: | |
| st.success("✅ Profile Submitted Successfully!") | |
| bmi_status = bmi_category(bmi) | |
| equipment_list = ", ".join(equipment) | |
| prompt = f""" | |
| Generate a 5-day structured workout plan. | |
| User Details: | |
| Name: {name} | |
| Gender: {gender} | |
| BMI: {bmi:.2f} ({bmi_status}) | |
| Goal: {goal} | |
| Fitness Level: {fitness_level} | |
| Available Equipment: {equipment_list} | |
| Requirements: | |
| - Include warmup | |
| - Include exercises with sets and reps | |
| - Include rest time | |
| - Adjust intensity based on BMI and fitness level | |
| - Keep it structured day-wise | |
| """ | |
| with st.spinner("Generating your AI workout plan..."): | |
| result = generator(prompt, max_new_tokens=400)[0]["generated_text"] | |
| st.subheader("🏋️ Your Personalized Workout Plan") | |
| st.write(result) |