JadAssaf commited on
Commit
1110093
1 Parent(s): 7f56996
Files changed (6) hide show
  1. .DS_Store +0 -0
  2. TSPI_model_joblib.sav +0 -0
  3. app.py +58 -0
  4. load_model.py +4 -0
  5. requirements.txt +7 -0
  6. stpi_data.txt +1 -0
.DS_Store ADDED
Binary file (6.15 kB). View file
 
TSPI_model_joblib.sav ADDED
Binary file (88.6 kB). View file
 
app.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # %%
2
+ import gradio as gr
3
+ import joblib
4
+ import dill
5
+ # import pickle
6
+ import imblearn
7
+ import sklearn
8
+ import xgboost
9
+ file_name = 'TSPI_model_joblib.sav'
10
+ model = joblib.load(file_name)
11
+
12
+
13
+ def STPI(TS4,TS2,TS1,
14
+ # Acc_0_5__1_0_MaxValue,
15
+ DTS4,DTS2,DTS1):
16
+ print('------------------')
17
+
18
+ X = [TS4,TS2,TS1,
19
+ # Acc_0_5__1_0_MaxValue,
20
+ DTS4,DTS2,DTS1]
21
+ print(X)
22
+ outcome_decoded = ['Normal','Borderline','Suspicious','Keratoconic']
23
+ file_object = open('stpi_data.txt', 'a')
24
+ file_object.write(str(TS4))
25
+ file_object.write(';')
26
+ file_object.write(str(TS2))
27
+ file_object.write(';')
28
+ file_object.write(str(TS1))
29
+ file_object.write(';')
30
+ # file_object.write(str(Acc_0_5__1_0_MaxValue))
31
+ # file_object.write(';')
32
+ file_object.write(str(DTS4))
33
+ file_object.write(';')
34
+ file_object.write(str(DTS2))
35
+ file_object.write(';')
36
+ file_object.write(str(DTS1))
37
+ file_object.write(';')
38
+ file_object.write('\n')
39
+ file_object.close()
40
+
41
+ result_3way = model.predict([X])
42
+ # print('The patient is ', outcome_decoded[int(result_3way)], 'through the 3way method')
43
+ # result = 'The 3-way classification resulted in a ', outcome_decoded[int(result_3way)] + ' patient.'
44
+ # further_analysis = 'Futher analysis using the 2-way classification resulted in a ' + outcome_decoded[int(result_2way)] + ' label.'
45
+ return 'The patient is ' + outcome_decoded[int(result_3way)] + '.'
46
+
47
+ iface = gr.Interface(
48
+ fn=STPI,
49
+ title='TSPI Calculator',
50
+ 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. This is the 4-way classification.',
51
+ inputs=["number", "number","number",
52
+ # "number",
53
+ "number", "number","number"],
54
+ outputs="text")
55
+ iface.launch(
56
+ # share=True
57
+ )
58
+ # %%
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,7 @@
 
 
 
 
 
 
 
 
1
+ gradio==3.15.0
2
+ imbalanced_learn==0.9.1
3
+ imblearn==0.0
4
+ sklearn==0.0
5
+ xgboost==0.90
6
+ joblib==1.2.0
7
+ dill==0.3.6
stpi_data.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ 11.0;22.0;33.0;44.0;55.0;66.0;77.0