JadAssaf commited on
Commit
dc45fa4
1 Parent(s): c4381f3
.DS_Store ADDED
Binary file (8.2 kB). View file
 
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ MISC/
STPI_2WAY_RandomForest.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:84ae3aec58b4bf3cfe625ac2138d6ac245f741787070ea7ae2538f404029fc5a
3
+ size 86585
STPI_3WAY_RandomForest.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2404d314d346836902a186594bbeb9371f822b07aabe863d07c3777ddca05875
3
+ size 95873
app.py ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # %%
2
+ import gradio as gr
3
+ import joblib
4
+ loaded_rf_2way = joblib.load("STPI_2WAY_RandomForest.joblib")
5
+ loaded_rf_3way = joblib.load("STPI_3WAY_RandomForest.joblib")
6
+
7
+
8
+ def STPI(t_0_5_MaxValue,t_1_0_MaxValue,t_2_0_MaxValue,
9
+ # Acc_0_5__1_0_MaxValue,
10
+ Abs_Diff_t_0_5_MaxValue,Abs_Diff_t_1_0_MaxValue,Abs_Diff_t_2_0_MaxValue,Optional_Custom_Message='No_Message'):
11
+ print('------------------')
12
+ print(Optional_Custom_Message)
13
+
14
+ X = [t_0_5_MaxValue,t_1_0_MaxValue,t_2_0_MaxValue,
15
+ # Acc_0_5__1_0_MaxValue,
16
+ Abs_Diff_t_0_5_MaxValue,Abs_Diff_t_1_0_MaxValue,Abs_Diff_t_2_0_MaxValue]
17
+ print(X)
18
+ outcome_decoded = ['Normal','Keratoconic','Suspect']
19
+ file_object = open('stpi_data.txt', 'a')
20
+ file_object.write(str(t_0_5_MaxValue))
21
+ file_object.write(';')
22
+ file_object.write(str(t_1_0_MaxValue))
23
+ file_object.write(';')
24
+ file_object.write(str(t_2_0_MaxValue))
25
+ file_object.write(';')
26
+ # file_object.write(str(Acc_0_5__1_0_MaxValue))
27
+ # file_object.write(';')
28
+ file_object.write(str(Abs_Diff_t_0_5_MaxValue))
29
+ file_object.write(';')
30
+ file_object.write(str(Abs_Diff_t_1_0_MaxValue))
31
+ file_object.write(';')
32
+ file_object.write(str(Abs_Diff_t_2_0_MaxValue))
33
+ file_object.write(';')
34
+ file_object.write(Optional_Custom_Message)
35
+ file_object.write('\n')
36
+ file_object.close()
37
+
38
+ result_2way = loaded_rf_2way.predict([X])
39
+ print('The patient is ', outcome_decoded[int(result_2way)], ' through the 2way method')
40
+
41
+ result_3way = loaded_rf_3way.predict([X])
42
+ if result_2way == 0:
43
+ print('The patient is ', outcome_decoded[int(result_3way)], 'through the 3way method')
44
+ # result = 'The 3-way classification resulted in a ', outcome_decoded[int(result_3way)] + ' patient.'
45
+ # further_analysis = 'Futher analysis using the 2-way classification resulted in a ' + outcome_decoded[int(result_2way)] + ' label.'
46
+ return 'The 3-way classification resulted in a ' + outcome_decoded[int(result_3way)] + ' patient. Futher analysis using the 2-way classification resulted in a ' + outcome_decoded[int(result_2way)] + ' label.'
47
+
48
+ # result = 'The 2-way classification resulted in a ', outcome_decoded[int(result_2way)] + ' patient.'
49
+ # further_analysis = 'Futher analysis using the 3-way classification resulted in a ' + outcome_decoded[int(result_3way)] + ' label.'
50
+
51
+ return 'The 2-way classification resulted in a ' + outcome_decoded[int(result_2way)] + ' patient. Futher analysis using the 3-way classification resulted in a ' + outcome_decoded[int(result_3way)] + ' label.'
52
+
53
+ iface = gr.Interface(
54
+ fn=STPI,
55
+ title='STPI Calculator',
56
+ description='Calculates the STPI through summarized tomographic parameters. Beta version by Prof. Shady Awwad, Jad Assaf MD and Jawad Kaisania.',
57
+ inputs=["number", "number","number",
58
+ # "number",
59
+ "number", "number","number","text"],
60
+ outputs="text")
61
+ iface.launch(share=True)
62
+ # %%
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