JadAssaf commited on
Commit
5a6f531
·
1 Parent(s): 3120adf
Files changed (6) hide show
  1. .DS_Store +0 -0
  2. TSPI_model.sav +0 -0
  3. app.py +53 -0
  4. load_model.py +4 -0
  5. requirements.txt +3 -0
  6. stpi_data.txt +1 -0
.DS_Store ADDED
Binary file (6.15 kB). View file
 
TSPI_model.sav ADDED
Binary file (159 kB). View file
 
app.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # %%
2
+ import gradio as gr
3
+ import pickle
4
+ file_name = 'TSPI_model.sav'
5
+ model = pickle.load(open(file_name,'rb'))
6
+
7
+
8
+ def STPI(t_1_MaxValue,t_2_MaxValue,t_2_0_MaxValue,
9
+ # Acc_0_5__1_0_MaxValue,
10
+ Abs_Diff_t_1_MaxValue,Abs_Diff_t_2_MaxValue,Abs_Diff_t_4_MaxValue):
11
+ print('------------------')
12
+
13
+ X = [t_1_MaxValue,t_2_MaxValue,t_2_0_MaxValue,
14
+ # Acc_0_5__1_0_MaxValue,
15
+ Abs_Diff_t_1_MaxValue,Abs_Diff_t_2_MaxValue,Abs_Diff_t_4_MaxValue]
16
+ print(X)
17
+ outcome_decoded = ['Normal','Suspect','Keratoconic']
18
+ file_object = open('stpi_data.txt', 'a')
19
+ file_object.write(str(t_1_MaxValue))
20
+ file_object.write(';')
21
+ file_object.write(str(t_2_MaxValue))
22
+ file_object.write(';')
23
+ file_object.write(str(t_2_0_MaxValue))
24
+ file_object.write(';')
25
+ # file_object.write(str(Acc_0_5__1_0_MaxValue))
26
+ # file_object.write(';')
27
+ file_object.write(str(Abs_Diff_t_1_MaxValue))
28
+ file_object.write(';')
29
+ file_object.write(str(Abs_Diff_t_2_MaxValue))
30
+ file_object.write(';')
31
+ file_object.write(str(Abs_Diff_t_4_MaxValue))
32
+ file_object.write(';')
33
+ file_object.write('\n')
34
+ file_object.close()
35
+
36
+ result_3way = model.predict([X])
37
+ print('The patient is ', outcome_decoded[int(result_3way)], 'through the 3way method')
38
+ # result = 'The 3-way classification resulted in a ', outcome_decoded[int(result_3way)] + ' patient.'
39
+ # further_analysis = 'Futher analysis using the 2-way classification resulted in a ' + outcome_decoded[int(result_2way)] + ' label.'
40
+ return 'The patient is ' + outcome_decoded[int(result_3way)] + '.'
41
+
42
+ iface = gr.Interface(
43
+ fn=STPI,
44
+ title='TSPI Calculator',
45
+ description='The Thickness Speed Progression Index (TSPI) detects keratoconus and keratoconus susceptible corneas through summarized pachymetric parameters. Beta version made for Zeimer by Prof. Shady Awwad, Jad Assaf, MD, and Bassel Hammoud, MD.',
46
+ inputs=["number", "number","number",
47
+ # "number",
48
+ "number", "number","number"],
49
+ outputs="text")
50
+ iface.launch(
51
+ # share=True
52
+ )
53
+ # %%
load_model.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ import pickle
2
+
3
+ file_name = 'TSPI_model.sav'
4
+ model = pickle.load(open(file_name,'rb'))
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio==2.4.6
2
+ joblib==1.0.0
3
+ scikit-learn==0.24.0
stpi_data.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ 11.0;22.0;33.0;44.0;55.0;66.0;77.0