FranciscoLozDataScience
commited on
Commit
·
4afc0a1
1
Parent(s):
b15d31f
testing interface instead of block
Browse files
app.py
CHANGED
@@ -39,8 +39,8 @@ def load_interface():
|
|
39 |
Configure Gradio interface
|
40 |
'''
|
41 |
|
42 |
-
#
|
43 |
-
ex=
|
44 |
[20,85,135,190,30,125,53,126,0.1,9.9,0.1,9.9,1,2,1,2,79,240,40,140,55,505,72,371,16,405,4,618,1,1660,4.9,20.9,1,6,0.1,10.3,6,1311,1,2062,1,999,0,1],
|
45 |
[40,170,65,75.1,1.0,0.9,1,1,120,70,102,225,260,41,132,15.7,1,0.8,24,26,32,0,45,170,75,89.0,0.7,1.2,1,1,100,67,96,258,345,49,140,15.7,1,1.1,26,28,138,0,30],
|
46 |
[180,90,94.0,1.0,0.8,1,1,115,72,88,177,103,53,103,13.5,1,1.0,19,29,30,0,60,170,65,78.0,1.5,1.0,1,1,110,70,87,190,210,45,103,14.7,1,0.8,21,21,19,0,55],
|
@@ -50,9 +50,9 @@ def load_interface():
|
|
50 |
|
51 |
#set blocks
|
52 |
info_page = gr.Blocks()
|
53 |
-
model_page = gr.Blocks() #TODO: get examples working
|
54 |
|
55 |
-
with info_page:
|
56 |
# set title and description
|
57 |
gr.Markdown(
|
58 |
"""
|
@@ -98,59 +98,92 @@ def load_interface():
|
|
98 |
"""
|
99 |
)
|
100 |
|
101 |
-
with model_page:
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
|
155 |
iface = gr.TabbedInterface(
|
156 |
[info_page, model_page],
|
|
|
39 |
Configure Gradio interface
|
40 |
'''
|
41 |
|
42 |
+
#example inputs
|
43 |
+
ex=[
|
44 |
[20,85,135,190,30,125,53,126,0.1,9.9,0.1,9.9,1,2,1,2,79,240,40,140,55,505,72,371,16,405,4,618,1,1660,4.9,20.9,1,6,0.1,10.3,6,1311,1,2062,1,999,0,1],
|
45 |
[40,170,65,75.1,1.0,0.9,1,1,120,70,102,225,260,41,132,15.7,1,0.8,24,26,32,0,45,170,75,89.0,0.7,1.2,1,1,100,67,96,258,345,49,140,15.7,1,1.1,26,28,138,0,30],
|
46 |
[180,90,94.0,1.0,0.8,1,1,115,72,88,177,103,53,103,13.5,1,1.0,19,29,30,0,60,170,65,78.0,1.5,1.0,1,1,110,70,87,190,210,45,103,14.7,1,0.8,21,21,19,0,55],
|
|
|
50 |
|
51 |
#set blocks
|
52 |
info_page = gr.Blocks()
|
53 |
+
# model_page = gr.Blocks() #TODO: get examples working
|
54 |
|
55 |
+
with info_page:
|
56 |
# set title and description
|
57 |
gr.Markdown(
|
58 |
"""
|
|
|
98 |
"""
|
99 |
)
|
100 |
|
101 |
+
# with model_page:
|
102 |
+
# # set title and description
|
103 |
+
# gr.Markdown(
|
104 |
+
# """
|
105 |
+
# # Interact with the Ensemble Classifier Model
|
106 |
+
# Enter sample bio data to predict smoking status.\n
|
107 |
+
# **Medical Disclaimer**: The predictions provided by this model are for educational purposes only and should not be considered a substitute for professional medical advice.
|
108 |
+
# """)
|
109 |
+
|
110 |
+
# #set inputs in rows of 3
|
111 |
+
# with gr.Row():
|
112 |
+
# age = gr.Number(label="Age", precision=0, minimum=0)
|
113 |
+
# height = gr.Number(label="Height(cm)", precision=0, minimum=0)
|
114 |
+
# weight = gr.Number(label="Weight(kg)", precision=0, minimum=0)
|
115 |
+
# with gr.Row():
|
116 |
+
# waist = gr.Number(label="Waist(cm)", minimum=0, info="Waist circumference length")
|
117 |
+
# eye_L = gr.Number(label="Visual acuity of the left eye, measured in diopters (D)", minimum=0)
|
118 |
+
# eye_R = gr.Number(label="Visual acuity of the right eye, measured in diopters (D)", minimum=0)
|
119 |
+
# with gr.Row():
|
120 |
+
# hear_L = gr.Radio(label="Is there any hearing ability in the left ear?",choices=[("Yes",1),("No",2)])
|
121 |
+
# hear_R = gr.Radio(label="Is there any hearing ability in the right ear?",choices=[("Yes",1),("No",2)])
|
122 |
+
# systolic = gr.Number(label="Systolic(mmHg)", precision=0, minimum=0, info="Blood Pressure")
|
123 |
+
# with gr.Row():
|
124 |
+
# relaxation = gr.Number(label="Relaxation(mmHg)", precision=0, minimum=0, info="Blood Pressure")
|
125 |
+
# fasting_blood_sugar = gr.Number(label="Fasting Blood Sugar(mg/dL)", precision=0, minimum=0, info="the concentration of glucose (sugar) in the bloodstream after an extended period of fasting")
|
126 |
+
# cholesterol = gr.Number(label="Total Cholesterol(mg/dL)", precision=0, minimum=0, info="Total amount of cholesterol present in the blood")
|
127 |
+
# with gr.Row():
|
128 |
+
# triglyceride = gr.Number(label="Triglyceride(mg/dL)", precision=0, minimum=0, info="A type of fat (lipid) found in blood")
|
129 |
+
# HDL = gr.Number(label="High-Density Lipoprotein(mg/dL) ", precision=0, minimum=0, info="It is commonly referred to as 'good cholesterol'")
|
130 |
+
# LDL = gr.Number(label="Low-Density Lipoprotein(mg/dL) ", precision=0, minimum=0, info="It is commonly referred to as 'bad cholesterol'")
|
131 |
+
# with gr.Row():
|
132 |
+
# hemoglobin = gr.Number(label="Hemoglobin(g/dL)", minimum=0, info="a protein found in red blood cells that is responsible for carrying oxygen from the lungs to the tissues and organs of the body")
|
133 |
+
# urine_protein = gr.Radio(label="Does urine contain excessive traces of protein?",choices=[("Yes",2),("No",1)], info="when excessive protein is detected in the urine, it may indicate a problem with kidney function or other underlying health conditions.")
|
134 |
+
# serum_creatinine = gr.Number(label="Serum creatinine(mg/dL)", minimum=0, info="Serum creatinine levels are commonly measured through a blood test and are used to assess kidney function")
|
135 |
+
# with gr.Row():
|
136 |
+
# AST = gr.Number(label="Aspartate Aminotransferase(IU/L)", precision=0, minimum=0, info="glutamic oxaloacetic transaminase type; AST is released into the bloodstream when cells are damaged or destroyed, such as during injury or disease affecting organs rich in AST.")
|
137 |
+
# ALT = gr.Number(label="Alanine Aminotransferase(IU/L)", precision=0, minimum=0, info="glutamic oxaloacetic transaminase type; ALT is primarily found in the liver cells, and increased levels of ALT in the blood can indicate liver damage or disease")
|
138 |
+
# Gtp = gr.Number(label="Gamma-glutamyl Transferase(IU/L)", precision=0, minimum=0, info="Elevated levels of GGT in the blood can indicate liver disease or bile duct obstruction. GGT levels are often measured alongside other liver function tests to assess liver health and function.")
|
139 |
+
# dental_caries = gr.Radio(label="Are there any signs of dental cavities?",choices=[("Yes",1),("No",0)])
|
140 |
+
|
141 |
+
# #set button row
|
142 |
+
# with gr.Row():
|
143 |
+
# pred_btn = gr.Button("Predict")
|
144 |
+
# clear_btn = gr.Button("Clear")
|
145 |
+
|
146 |
+
# #set label txt box
|
147 |
+
# smoker_label = gr.Label(label="Predicted Label")
|
148 |
+
|
149 |
+
# #set event listeners
|
150 |
+
# inputs = [age, height, weight, waist, eye_L, eye_R, hear_L, hear_R, systolic, relaxation, fasting_blood_sugar, cholesterol, triglyceride, HDL, LDL, hemoglobin, urine_protein, serum_creatinine, AST, ALT, Gtp, dental_caries]
|
151 |
+
# pred_btn.click(fn=predict, inputs=inputs, outputs=smoker_label)
|
152 |
+
# clear_btn.click(lambda: [None]*22, outputs=inputs)
|
153 |
+
|
154 |
+
age = gr.Number(label="Age", precision=0, minimum=0)
|
155 |
+
height = gr.Number(label="Height(cm)", precision=0, minimum=0)
|
156 |
+
weight = gr.Number(label="Weight(kg)", precision=0, minimum=0)
|
157 |
+
waist = gr.Number(label="Waist(cm)", minimum=0, info="Waist circumference length")
|
158 |
+
eye_L = gr.Number(label="Visual acuity of the left eye, measured in diopters (D)", minimum=0)
|
159 |
+
eye_R = gr.Number(label="Visual acuity of the right eye, measured in diopters (D)", minimum=0)
|
160 |
+
hear_L = gr.Radio(label="Is there any hearing ability in the left ear?",choices=[("Yes",1),("No",2)])
|
161 |
+
hear_R = gr.Radio(label="Is there any hearing ability in the right ear?",choices=[("Yes",1),("No",2)])
|
162 |
+
systolic = gr.Number(label="Systolic(mmHg)", precision=0, minimum=0, info="Blood Pressure")
|
163 |
+
relaxation = gr.Number(label="Relaxation(mmHg)", precision=0, minimum=0, info="Blood Pressure")
|
164 |
+
fasting_blood_sugar = gr.Number(label="Fasting Blood Sugar(mg/dL)", precision=0, minimum=0, info="the concentration of glucose (sugar) in the bloodstream after an extended period of fasting")
|
165 |
+
cholesterol = gr.Number(label="Total Cholesterol(mg/dL)", precision=0, minimum=0, info="Total amount of cholesterol present in the blood")
|
166 |
+
triglyceride = gr.Number(label="Triglyceride(mg/dL)", precision=0, minimum=0, info="A type of fat (lipid) found in blood")
|
167 |
+
HDL = gr.Number(label="High-Density Lipoprotein(mg/dL) ", precision=0, minimum=0, info="It is commonly referred to as 'good cholesterol'")
|
168 |
+
LDL = gr.Number(label="Low-Density Lipoprotein(mg/dL) ", precision=0, minimum=0, info="It is commonly referred to as 'bad cholesterol'")
|
169 |
+
hemoglobin = gr.Number(label="Hemoglobin(g/dL)", minimum=0, info="a protein found in red blood cells that is responsible for carrying oxygen from the lungs to the tissues and organs of the body")
|
170 |
+
urine_protein = gr.Radio(label="Does urine contain excessive traces of protein?",choices=[("Yes",2),("No",1)], info="when excessive protein is detected in the urine, it may indicate a problem with kidney function or other underlying health conditions.")
|
171 |
+
serum_creatinine = gr.Number(label="Serum creatinine(mg/dL)", minimum=0, info="Serum creatinine levels are commonly measured through a blood test and are used to assess kidney function")
|
172 |
+
AST = gr.Number(label="Aspartate Aminotransferase(IU/L)", precision=0, minimum=0, info="glutamic oxaloacetic transaminase type; AST is released into the bloodstream when cells are damaged or destroyed, such as during injury or disease affecting organs rich in AST.")
|
173 |
+
ALT = gr.Number(label="Alanine Aminotransferase(IU/L)", precision=0, minimum=0, info="glutamic oxaloacetic transaminase type; ALT is primarily found in the liver cells, and increased levels of ALT in the blood can indicate liver damage or disease")
|
174 |
+
Gtp = gr.Number(label="Gamma-glutamyl Transferase(IU/L)", precision=0, minimum=0, info="Elevated levels of GGT in the blood can indicate liver disease or bile duct obstruction. GGT levels are often measured alongside other liver function tests to assess liver health and function.")
|
175 |
+
dental_caries = gr.Radio(label="Are there any signs of dental cavities?",choices=[("Yes",1),("No",0)])
|
176 |
+
inputs = [age, height, weight, waist, eye_L, eye_R, hear_L, hear_R, systolic, relaxation, fasting_blood_sugar, cholesterol, triglyceride, HDL, LDL, hemoglobin, urine_protein, serum_creatinine, AST, ALT, Gtp, dental_caries]
|
177 |
+
smoker_label = gr.Label(label="Predicted Label")
|
178 |
+
|
179 |
+
model_page = gr.Interface(
|
180 |
+
predict,
|
181 |
+
inputs=inputs,
|
182 |
+
outputs=smoker_label,
|
183 |
+
examples=ex,
|
184 |
+
title="Interact with the Ensemble Classifier Model",
|
185 |
+
description="Enter sample bio data to predict smoking status.\n**Medical Disclaimer**: The predictions provided by this model are for educational purposes only and should not be considered a substitute for professional medical advice."
|
186 |
+
)
|
187 |
|
188 |
iface = gr.TabbedInterface(
|
189 |
[info_page, model_page],
|