bright1 commited on
Commit
636b9ec
1 Parent(s): fefa05b

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +96 -0
  2. images/image.jpg +0 -0
  3. requirements.txt +1 -0
app.py ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+ from PIL import Image
4
+
5
+ image_path = '\images\image.jpg'
6
+ image = Image.open(image_path)
7
+
8
+
9
+
10
+
11
+
12
+ # Set API Endpoint
13
+ URL = 'https://radiant-lowlands-86946.herokuapp.com/predict'
14
+
15
+
16
+ # Create a function to make prediction
17
+ def make_prediction(pg: float, bwr1: float, bp : float, bwr2: float, bwr3: float, bmi: float, bwr4: float, age: int, insurance: bool):
18
+
19
+ parameters={
20
+ 'plasma_glucose':pg,
21
+ 'blood_work_result_1':bwr1,
22
+ 'blood_pressure':bp,
23
+ 'blood_work_result_2':bwr2,
24
+ 'blood_work_result_3':bwr3,
25
+ 'body_mass_index':bmi,
26
+ 'blood_work_result_4':bwr4,
27
+ 'age':int(age),
28
+ 'insurance':bool(insurance)}
29
+ response = requests.post(URL, params=parameters)
30
+ response_text = response.json()
31
+ sepsis_status = response_text['results'][0]['0']['output']['Predicted Label']
32
+ return sepsis_status
33
+
34
+
35
+ # set page configuration
36
+ st.set_page_config(
37
+ page_title='Sepsis Prediction',
38
+ page_icon="🤖",
39
+ initial_sidebar_state="expanded",
40
+ menu_items={
41
+ 'About': "# This is a Health App. Call it the Covid Vaccine Sepsis Analyzer!"
42
+ }
43
+ )
44
+
45
+
46
+ # create a sidebar and contents
47
+ st.sidebar.markdown("""
48
+ ## Demo App
49
+
50
+ This app return sepsis status base on the input parameters
51
+ """)
52
+
53
+ st.markdown('''
54
+ <h1 style="color: green; text-align:center">The Sepsis Prediction App</h1>
55
+ ''', unsafe_allow_html=True)
56
+
57
+ # insert an image
58
+ st.image(image, caption=None, width=None, use_column_width=None, clamp=False, channels="RGB", output_format="auto")
59
+
60
+
61
+ # Create app interface
62
+ container = st.container()
63
+ container.write("Inputs to predict Sepsis")
64
+ with container:
65
+ col1, col2, col3 = st.columns(3)
66
+
67
+ age = col1.number_input(label='Age')
68
+ pg = col2.number_input(label='Blood Glucose')
69
+ bp = col3.number_input(label='Blood Pressure')
70
+ with st.expander(label='Blood Parameter', expanded=True, ):
71
+ bwr1 = col1.number_input(label='Blood Work Result-1')
72
+ bwr2 = col2.number_input(label='Blood Work Result-2')
73
+ bwr3 = col1.number_input(label='Blood Work Result-3')
74
+ bwr4 = col2.number_input(label='Blood Work Result-4')
75
+ ins = col3.selectbox(label='Insurance', options=[True, False])
76
+ bmi = col3.number_input(label='Body Mass Index')
77
+ button = st.button(label='Predict', type='primary', use_container_width=True)
78
+
79
+
80
+ if button:
81
+ response = make_prediction(pg, bwr1, bp, bwr2, bwr3, bmi, bwr4, age, ins)
82
+ st.write(f'The {response}')
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
images/image.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ streamlit==1.23.1