Spaces:
Runtime error
Runtime error
Download app.py from djaydenvanhattem3/Training-AI: direct link, hf CLI and curl.
- Browser
- Download file 914 Bytes
-
https://huggingface.co/spaces/djaydenvanhattem3/Training-AI/resolve/main/app.py
- Command line
-
hf download hf://spaces/djaydenvanhattem3/Training-AI/app.py
-
curl -L -o app.py https://huggingface.co/spaces/djaydenvanhattem3/Training-AI/resolve/main/app.py
914 Bytes
| from fastapi import FastAPI | |
| from pydantic import BaseModel | |
| from transformers import pipeline | |
| app = FastAPI() | |
| # Laad model (eerste keer duurt even) | |
| generator = pipeline("text-generation", model="distilgpt2") | |
| class UserInput(BaseModel): | |
| goal: str | |
| frequency: int | |
| level: str | |
| def home(): | |
| return {"message": "AI Fitness Coach is running"} | |
| def generate_workout(user_input: UserInput): | |
| prompt = f""" | |
| Je bent een professionele fitness coach. | |
| Maak een trainingsschema. | |
| Doel: {user_input.goal} | |
| Trainingsfrequentie: {user_input.frequency} keer per week | |
| Niveau: {user_input.level} | |
| Geef een duidelijk schema met oefeningen, sets en reps. | |
| """ | |
| result = generator( | |
| prompt, | |
| max_length=300, | |
| do_sample=True, | |
| temperature=0.7 | |
| ) | |
| return { | |
| "workout": result[0]["generated_text"] | |
| } |