Files changed (1) hide show
  1. app.py +27 -27
app.py CHANGED
@@ -7,11 +7,11 @@ from typing import List
7
  # Define the COLUMN_MIN_MAX as provided
8
  COLUMN_MIN_MAX = {
9
  "Age": (18, 100),
10
- "Blood_Glucose_Level": (0, 3),
11
- "Blood_Pressure_Systolic": (0, 3),
12
- "Blood_Pressure_Diastolic": (0, 3),
13
- "BMI": (0, 3),
14
- "Condition_Severity": (0, 3),
15
  "Gender": (0, 2),
16
  "Ethnicity": (0, 5),
17
  "Geographic_Location": (0, 6),
@@ -33,7 +33,7 @@ additional_categories = {
33
  "Ethnicity": ["White", "Black or African American", "Asian", "American Indian or Alaska Native", "Native Hawaiian or Other Pacific Islander", "Other"],
34
  "Geographic_Location": ["North America", "South America", "Europe", "Asia", "Africa", "Australia", "Antarctica"],
35
  "Smoking_Status": ["Never", "Former", "Current"],
36
- "Diagnoses_ICD10": ["E11.9", "I10", "J45.909", "M54.5", "F32.9", "K21.9"],
37
  "Medications": ["Metformin", "Lisinopril", "Atorvastatin", "Amlodipine", "Omeprazole", "Simvastatin", "Levothyroxine", "None"],
38
  "Allergies": ["Penicillin", "Peanuts", "Shellfish", "Latex", "Bee stings", "None"],
39
  "Previous_Treatments": ["Chemotherapy", "Radiation Therapy", "Surgery", "Physical Therapy", "Immunotherapy", "None"],
@@ -48,39 +48,39 @@ additional_categories = {
48
  min_age_input = gr.Number(label="Minimum Age", value=18, minimum=COLUMN_MIN_MAX["Age"][0], maximum=COLUMN_MIN_MAX["Age"][1])
49
  max_age_input = gr.Number(label="Maximum Age", value=100, minimum=COLUMN_MIN_MAX["Age"][0], maximum=COLUMN_MIN_MAX["Age"][1])
50
 
51
- gender_input = gr.CheckboxGroup(choices=additional_categories["Gender"], label="Gender")
52
- ethnicity_input = gr.CheckboxGroup(choices=additional_categories["Ethnicity"], label="Ethnicity")
53
- geographic_location_input = gr.CheckboxGroup(choices=additional_categories["Geographic_Location"], label="Geographic Location")
54
- diagnoses_icd10_input = gr.CheckboxGroup(choices=additional_categories["Diagnoses_ICD10"], label="Diagnoses (ICD-10)")
55
- medications_input = gr.CheckboxGroup(choices=additional_categories["Medications"], label="Medications")
56
- allergies_input = gr.CheckboxGroup(choices=additional_categories["Allergies"], label="Allergies")
57
- previous_treatments_input = gr.CheckboxGroup(choices=additional_categories["Previous_Treatments"], label="Previous Treatments")
58
 
59
  min_blood_glucose_level_input = gr.Number(label="Minimum Blood Glucose Level", value=0, minimum=COLUMN_MIN_MAX["Blood_Glucose_Level"][0], maximum=COLUMN_MIN_MAX["Blood_Glucose_Level"][1])
60
  max_blood_glucose_level_input = gr.Number(label="Maximum Blood Glucose Level", value=3, minimum=COLUMN_MIN_MAX["Blood_Glucose_Level"][0], maximum=COLUMN_MIN_MAX["Blood_Glucose_Level"][1])
 
61
 
62
  min_blood_pressure_systolic_input = gr.Number(label="Minimum Blood Pressure (Systolic)", value=0, minimum=COLUMN_MIN_MAX["Blood_Pressure_Systolic"][0], maximum=COLUMN_MIN_MAX["Blood_Pressure_Systolic"][1])
63
  max_blood_pressure_systolic_input = gr.Number(label="Maximum Blood Pressure (Systolic)", value=3, minimum=COLUMN_MIN_MAX["Blood_Pressure_Systolic"][0], maximum=COLUMN_MIN_MAX["Blood_Pressure_Systolic"][1])
 
64
 
65
  min_blood_pressure_diastolic_input = gr.Number(label="Minimum Blood Pressure (Diastolic)", value=0, minimum=COLUMN_MIN_MAX["Blood_Pressure_Diastolic"][0], maximum=COLUMN_MIN_MAX["Blood_Pressure_Diastolic"][1])
66
  max_blood_pressure_diastolic_input = gr.Number(label="Maximum Blood Pressure (Diastolic)", value=3, minimum=COLUMN_MIN_MAX["Blood_Pressure_Diastolic"][0], maximum=COLUMN_MIN_MAX["Blood_Pressure_Diastolic"][1])
 
67
 
68
  min_bmi_input = gr.Number(label="Minimum BMI", value=0, minimum=COLUMN_MIN_MAX["BMI"][0], maximum=COLUMN_MIN_MAX["BMI"][1])
69
  max_bmi_input = gr.Number(label="Maximum BMI", value=3, minimum=COLUMN_MIN_MAX["BMI"][0], maximum=COLUMN_MIN_MAX["BMI"][1])
70
-
71
- smoking_status_input = gr.CheckboxGroup(choices=additional_categories["Smoking_Status"], label="Smoking Status")
72
- alcohol_consumption_input = gr.CheckboxGroup(choices=additional_categories["Alcohol_Consumption"], label="Alcohol Consumption")
73
- exercise_habits_input = gr.CheckboxGroup(choices=additional_categories["Exercise_Habits"], label="Exercise Habits")
74
- diet_input = gr.CheckboxGroup(choices=additional_categories["Diet"], label="Diet")
75
-
76
- min_condition_severity_input = gr.Number(label="Minimum Condition Severity", value=0, minimum=COLUMN_MIN_MAX["Condition_Severity"][0], maximum=COLUMN_MIN_MAX["Condition_Severity"][1])
77
- max_condition_severity_input = gr.Number(label="Maximum Condition Severity", value=3, minimum=COLUMN_MIN_MAX["Condition_Severity"][0], maximum=COLUMN_MIN_MAX["Condition_Severity"][1])
78
-
79
- functional_status_input = gr.CheckboxGroup(choices=additional_categories["Functional_Status"], label="Functional Status")
80
- previous_trial_participation_input = gr.CheckboxGroup(choices=additional_categories["Previous_Trial_Participation"], label="Previous Trial Participation")
81
-
82
  # Define the server's URL
83
- SERVER_URL = "http://127.0.0.1:7860/api/predict" # Ensure this is the correct endpoint
84
 
85
  def encode_categorical_data(data: List[str], category_name: str) -> List[int]:
86
  """Encodes a list of categorical values into their corresponding indices based on additional_categories."""
@@ -189,7 +189,7 @@ def process_researcher_data(
189
 
190
  # Construct the payload as a regular dictionary
191
  payload = {
192
- "model_name": "fhe_model_v1",
193
  "requirements": requirements
194
  }
195
 
 
7
  # Define the COLUMN_MIN_MAX as provided
8
  COLUMN_MIN_MAX = {
9
  "Age": (18, 100),
10
+ "Blood_Glucose_Level": (0, 300),
11
+ "Blood_Pressure_Systolic": (80, 200),
12
+ "Blood_Pressure_Diastolic": (40, 120),
13
+ "BMI": (10, 50),
14
+ "Condition_Severity": (1, 10),
15
  "Gender": (0, 2),
16
  "Ethnicity": (0, 5),
17
  "Geographic_Location": (0, 6),
 
33
  "Ethnicity": ["White", "Black or African American", "Asian", "American Indian or Alaska Native", "Native Hawaiian or Other Pacific Islander", "Other"],
34
  "Geographic_Location": ["North America", "South America", "Europe", "Asia", "Africa", "Australia", "Antarctica"],
35
  "Smoking_Status": ["Never", "Former", "Current"],
36
+ "Diagnoses_ICD10": ["Actinic keratosis", "Melanoma", "Dermatofibroma", "Vascular lesion","None"],
37
  "Medications": ["Metformin", "Lisinopril", "Atorvastatin", "Amlodipine", "Omeprazole", "Simvastatin", "Levothyroxine", "None"],
38
  "Allergies": ["Penicillin", "Peanuts", "Shellfish", "Latex", "Bee stings", "None"],
39
  "Previous_Treatments": ["Chemotherapy", "Radiation Therapy", "Surgery", "Physical Therapy", "Immunotherapy", "None"],
 
48
  min_age_input = gr.Number(label="Minimum Age", value=18, minimum=COLUMN_MIN_MAX["Age"][0], maximum=COLUMN_MIN_MAX["Age"][1])
49
  max_age_input = gr.Number(label="Maximum Age", value=100, minimum=COLUMN_MIN_MAX["Age"][0], maximum=COLUMN_MIN_MAX["Age"][1])
50
 
51
+ gender_input = gr.CheckboxGroup(choices=additional_categories["Gender"], label="Gender", value=["Male"])
52
+ ethnicity_input = gr.CheckboxGroup(choices=additional_categories["Ethnicity"], label="Ethnicity", value=["White"])
53
+ geographic_location_input = gr.CheckboxGroup(choices=additional_categories["Geographic_Location"], label="Geographic Location", value=["North America"])
54
+ diagnoses_icd10_input = gr.CheckboxGroup(choices=additional_categories["Diagnoses_ICD10"], label="Skin Diagnosis", value=["Actinic keratosis"])
55
+ medications_input = gr.CheckboxGroup(choices=additional_categories["Medications"], label="Medications", value=["Metformin"])
56
+ allergies_input = gr.CheckboxGroup(choices=additional_categories["Allergies"], label="Allergies", value=["Peanuts"])
57
+ previous_treatments_input = gr.CheckboxGroup(choices=additional_categories["Previous_Treatments"], label="Previous Treatments", value=["None"])
58
 
59
  min_blood_glucose_level_input = gr.Number(label="Minimum Blood Glucose Level", value=0, minimum=COLUMN_MIN_MAX["Blood_Glucose_Level"][0], maximum=COLUMN_MIN_MAX["Blood_Glucose_Level"][1])
60
  max_blood_glucose_level_input = gr.Number(label="Maximum Blood Glucose Level", value=3, minimum=COLUMN_MIN_MAX["Blood_Glucose_Level"][0], maximum=COLUMN_MIN_MAX["Blood_Glucose_Level"][1])
61
+ blood_glucose_level_input = gr.Number(label="Blood Glucose Level", value=100, minimum=COLUMN_MIN_MAX["Blood_Glucose_Level"][0], maximum=COLUMN_MIN_MAX["Blood_Glucose_Level"][1])
62
 
63
  min_blood_pressure_systolic_input = gr.Number(label="Minimum Blood Pressure (Systolic)", value=0, minimum=COLUMN_MIN_MAX["Blood_Pressure_Systolic"][0], maximum=COLUMN_MIN_MAX["Blood_Pressure_Systolic"][1])
64
  max_blood_pressure_systolic_input = gr.Number(label="Maximum Blood Pressure (Systolic)", value=3, minimum=COLUMN_MIN_MAX["Blood_Pressure_Systolic"][0], maximum=COLUMN_MIN_MAX["Blood_Pressure_Systolic"][1])
65
+ blood_pressure_systolic_input = gr.Number(label="Blood Pressure (Systolic)", value=120, minimum=COLUMN_MIN_MAX["Blood_Pressure_Systolic"][0], maximum=COLUMN_MIN_MAX["Blood_Pressure_Systolic"][1])
66
 
67
  min_blood_pressure_diastolic_input = gr.Number(label="Minimum Blood Pressure (Diastolic)", value=0, minimum=COLUMN_MIN_MAX["Blood_Pressure_Diastolic"][0], maximum=COLUMN_MIN_MAX["Blood_Pressure_Diastolic"][1])
68
  max_blood_pressure_diastolic_input = gr.Number(label="Maximum Blood Pressure (Diastolic)", value=3, minimum=COLUMN_MIN_MAX["Blood_Pressure_Diastolic"][0], maximum=COLUMN_MIN_MAX["Blood_Pressure_Diastolic"][1])
69
+ blood_pressure_diastolic_input = gr.Number(label="Blood Pressure (Diastolic)", value=80, minimum=COLUMN_MIN_MAX["Blood_Pressure_Diastolic"][0], maximum=COLUMN_MIN_MAX["Blood_Pressure_Diastolic"][1])
70
 
71
  min_bmi_input = gr.Number(label="Minimum BMI", value=0, minimum=COLUMN_MIN_MAX["BMI"][0], maximum=COLUMN_MIN_MAX["BMI"][1])
72
  max_bmi_input = gr.Number(label="Maximum BMI", value=3, minimum=COLUMN_MIN_MAX["BMI"][0], maximum=COLUMN_MIN_MAX["BMI"][1])
73
+ bmi_input = gr.Number(label="BMI", value=20, minimum=COLUMN_MIN_MAX["BMI"][0], maximum=COLUMN_MIN_MAX["BMI"][1])
74
+
75
+ smoking_status_input = gr.CheckboxGroup(choices=additional_categories["Smoking_Status"], label="Smoking Status", value=["Never"])
76
+ alcohol_consumption_input = gr.CheckboxGroup(choices=additional_categories["Alcohol_Consumption"], label="Alcohol Consumption", value=["None"])
77
+ exercise_habits_input = gr.CheckboxGroup(choices=additional_categories["Exercise_Habits"], label="Exercise Habits", value=["Sedentary"])
78
+ diet_input = gr.CheckboxGroup(choices=additional_categories["Diet"], label="Diet", value=["Omnivore"])
79
+ condition_severity_input = gr.Number(label="Condition Severity", value=5, minimum=0, maximum=10)
80
+ functional_status_input = gr.CheckboxGroup(choices=additional_categories["Functional_Status"], label="Functional Status", value=["Independent"])
81
+ previous_trial_participation_input = gr.CheckboxGroup(choices=additional_categories["Previous_Trial_Participation"], label="Previous Trial Participation", value=["No"])
 
 
 
82
  # Define the server's URL
83
+ SERVER_URL = "https://affordable-prot-bind-clarke.trycloudflare.com/requirements/create" # Ensure this is the correct endpoint
84
 
85
  def encode_categorical_data(data: List[str], category_name: str) -> List[int]:
86
  """Encodes a list of categorical values into their corresponding indices based on additional_categories."""
 
189
 
190
  # Construct the payload as a regular dictionary
191
  payload = {
192
+ "model_name": "second_model",
193
  "requirements": requirements
194
  }
195