Kayeaelne commited on
Commit
7c6ca1b
·
verified ·
1 Parent(s): 145c873

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -18,6 +18,8 @@ def predict_glucose(current_glucose, meal_type, meal_time, galvus_dose, galvus_t
18
  glucose_after_meal = current_glucose + 20 # Small glucose increase due to protein
19
  elif meal_type == 'Low-carb':
20
  glucose_after_meal = current_glucose - 10 # Small reduction due to low-carb meal
 
 
21
  else:
22
  glucose_after_meal = current_glucose # Normal meal with moderate carbs
23
 
@@ -28,8 +30,7 @@ def predict_glucose(current_glucose, meal_type, meal_time, galvus_dose, galvus_t
28
  # Adjust the effects of Galvus based on its administration time (medication effect starts at galvus_time + 1-2 hours)
29
  time_since_galvus = meal_time - galvus_time
30
  if time_since_galvus >= 1: # After 1 hour, the effects of Galvus start kicking in
31
- # Limit the glucose reduction from Galvus to a more gradual effect (10-30 mg/dL reduction)
32
- glucose_3hr -= 15 # Average of 10-30 mg/dL range in the realistic effect
33
 
34
  # Exercise effect on glucose (hypothetical value, may vary based on intensity)
35
  glucose_3hr -= exercise_duration * 2 # Exercise reduces glucose by 2 mg/dL per minute
@@ -62,13 +63,12 @@ def build_interface():
62
  # Inputs for current glucose, meal info, medication dose, exercise, fast carbs, and Galvus time
63
  with gr.Row():
64
  current_glucose = gr.Number(label="Current Blood Glucose (mg/dL)", value=150)
65
- meal_type = gr.Radio(choices=["Normal", "High-carb", "Protein-heavy", "Low-carb"], label="Meal Type", value="Normal")
66
- meal_time_hours = gr.Number(label="Last Meal Time (hours)", value=6) # Meal time in hours
67
- meal_time_minutes = gr.Number(label="Last Meal Time (minutes)", value=0) # Meal time in minutes
68
  galvus_dose = gr.Number(label="Galvus Dose (mg)", value=50)
69
  galvus_time = gr.Number(label="Galvus Time of Administration (hours)", value=0) # Input for when Galvus was taken
70
  exercise_duration = gr.Number(label="Exercise Duration (min)", value=0)
71
- fast_carbs_ml = gr.Number(label="Fast Carbs (mL)", value=0) # Fast carbs input (e.g., milk or juice)
72
 
73
  # Output predictions and graph
74
  glucose_1hr_output = gr.Textbox(label="Predicted Glucose Level in 1 Hour (mg/dL)")
@@ -81,7 +81,7 @@ def build_interface():
81
  # Set button action
82
  predict_button.click(
83
  predict_glucose,
84
- inputs=[current_glucose, meal_type, meal_time_hours, meal_time_minutes, galvus_dose, galvus_time, exercise_duration, fast_carbs_ml],
85
  outputs=[glucose_1hr_output, glucose_3hr_output, glucose_graph]
86
  )
87
 
 
18
  glucose_after_meal = current_glucose + 20 # Small glucose increase due to protein
19
  elif meal_type == 'Low-carb':
20
  glucose_after_meal = current_glucose - 10 # Small reduction due to low-carb meal
21
+ elif meal_type == 'Fast-carb':
22
+ glucose_after_meal = current_glucose + carb_effect # For fast carbs like juice or milk
23
  else:
24
  glucose_after_meal = current_glucose # Normal meal with moderate carbs
25
 
 
30
  # Adjust the effects of Galvus based on its administration time (medication effect starts at galvus_time + 1-2 hours)
31
  time_since_galvus = meal_time - galvus_time
32
  if time_since_galvus >= 1: # After 1 hour, the effects of Galvus start kicking in
33
+ glucose_3hr -= 15 # Average of 10-30 mg/dL range in the realistic effect (gradual effect)
 
34
 
35
  # Exercise effect on glucose (hypothetical value, may vary based on intensity)
36
  glucose_3hr -= exercise_duration * 2 # Exercise reduces glucose by 2 mg/dL per minute
 
63
  # Inputs for current glucose, meal info, medication dose, exercise, fast carbs, and Galvus time
64
  with gr.Row():
65
  current_glucose = gr.Number(label="Current Blood Glucose (mg/dL)", value=150)
66
+ meal_type = gr.Radio(choices=["Normal", "High-carb", "Protein-heavy", "Low-carb", "Fast-carb"], label="Meal Type", value="Normal")
67
+ meal_time = gr.Number(label="Last Meal Time (in hours)", value=2)
 
68
  galvus_dose = gr.Number(label="Galvus Dose (mg)", value=50)
69
  galvus_time = gr.Number(label="Galvus Time of Administration (hours)", value=0) # Input for when Galvus was taken
70
  exercise_duration = gr.Number(label="Exercise Duration (min)", value=0)
71
+ fast_carbs_ml = gr.Number(label="Fast Carbs (mL)", value=0)
72
 
73
  # Output predictions and graph
74
  glucose_1hr_output = gr.Textbox(label="Predicted Glucose Level in 1 Hour (mg/dL)")
 
81
  # Set button action
82
  predict_button.click(
83
  predict_glucose,
84
+ inputs=[current_glucose, meal_type, meal_time, galvus_dose, galvus_time, exercise_duration, fast_carbs_ml],
85
  outputs=[glucose_1hr_output, glucose_3hr_output, glucose_graph]
86
  )
87