Spaces:
Sleeping
Sleeping
Add FastAPI backend and integrate with Gradio frontend for workout plan generation
Browse files
app.py
CHANGED
|
@@ -1,7 +1,29 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
def
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import requests
|
| 3 |
|
| 4 |
+
def get_workout_plan(weight, height, age, body_type, goals, preferences):
|
| 5 |
+
response = requests.post("http://127.0.0.1:8000/generate_plan", json={
|
| 6 |
+
"weight": weight,
|
| 7 |
+
"height": height,
|
| 8 |
+
"age": age,
|
| 9 |
+
"body_type": body_type,
|
| 10 |
+
"goals": goals,
|
| 11 |
+
"preferences": preferences
|
| 12 |
+
})
|
| 13 |
+
return response.json()
|
| 14 |
|
| 15 |
+
with gr.Blocks() as demo:
|
| 16 |
+
with gr.Row():
|
| 17 |
+
weight = gr.Number(label="Weight (kg)")
|
| 18 |
+
height = gr.Number(label="Height (cm)")
|
| 19 |
+
age = gr.Number(label="Age")
|
| 20 |
+
body_type = gr.Dropdown(choices=["Active", "Sedentary"], label="Body Type")
|
| 21 |
+
goals = gr.Textbox(label="Goals")
|
| 22 |
+
preferences = gr.Textbox(label="Preferences")
|
| 23 |
+
|
| 24 |
+
workout_plan = gr.Textbox(label="Generated Workout Plan")
|
| 25 |
+
|
| 26 |
+
generate_button = gr.Button("Generate Plan")
|
| 27 |
+
generate_button.click(get_workout_plan, [weight, height, age, body_type, goals, preferences], workout_plan)
|
| 28 |
+
|
| 29 |
+
demo.launch()
|