Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -109,26 +109,27 @@ exercise_input = gr.Number(label="Exercise in Last 2 Hours (minutes)", value=0)
|
|
| 109 |
def update_fast_carb_visibility(last_meal):
|
| 110 |
return gr.update(visible=(last_meal == "Fast Carb (Juice, Glucose Tablet, etc.)"))
|
| 111 |
|
| 112 |
-
# Define Gradio Interface
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
|
|
|
|
|
| 109 |
def update_fast_carb_visibility(last_meal):
|
| 110 |
return gr.update(visible=(last_meal == "Fast Carb (Juice, Glucose Tablet, etc.)"))
|
| 111 |
|
| 112 |
+
# Define Gradio Interface in a Blocks context
|
| 113 |
+
with gr.Blocks() as iface:
|
| 114 |
+
current_glucose_input = gr.Number(label="Current Blood Glucose (mg/dL)", value=100)
|
| 115 |
+
meal_input = gr.Dropdown(["Fast Carb (Juice, Glucose Tablet, etc.)", "High Carb", "Balanced", "Protein/Fat", "Skipped"], label="Last Meal Type")
|
| 116 |
+
meal_time_input = gr.Textbox(label="Time of Last Meal (HH:MM)", placeholder="e.g. 13:30")
|
| 117 |
+
med_input = gr.Dropdown(["None", "Metformin", "Insulin", "Sulfonylurea"], label="Last Medication Taken")
|
| 118 |
+
med_time_input = gr.Textbox(label="Time of Last Medication (HH:MM)", placeholder="e.g. 08:00")
|
| 119 |
+
exercise_input = gr.Number(label="Exercise in Last 2 Hours (minutes)", value=0)
|
| 120 |
+
fast_carb_amount_input = gr.Number(label="Amount of Fast Carbs (grams)", value=0)
|
| 121 |
+
|
| 122 |
+
# Event to show/hide the fast carb input field
|
| 123 |
+
meal_input.change(fn=update_fast_carb_visibility, inputs=meal_input, outputs=fast_carb_amount_input)
|
| 124 |
+
|
| 125 |
+
output = gr.Textbox()
|
| 126 |
+
|
| 127 |
+
# Call the prediction function on form submission
|
| 128 |
+
gr.Button("Predict").click(
|
| 129 |
+
fn=predict_glucose,
|
| 130 |
+
inputs=[current_glucose_input, meal_input, meal_time_input, med_input, med_time_input, exercise_input, fast_carb_amount_input],
|
| 131 |
+
outputs=output
|
| 132 |
+
)
|
| 133 |
+
|
| 134 |
+
# Launch the interface
|
| 135 |
+
iface.launch()
|