JadAssaf commited on
Commit
6cf9c2b
1 Parent(s): cfcfdba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -11
app.py CHANGED
@@ -5,7 +5,10 @@ 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,Acc_0_5__1_0_MaxValue,Abs_Diff_t_0_5_MaxValue,Abs_Diff_t_1_0_MaxValue,Abs_Diff_t_2_0_MaxValue):
 
 
 
9
  X = [t_0_5_MaxValue,t_1_0_MaxValue,t_2_0_MaxValue,Acc_0_5__1_0_MaxValue,Abs_Diff_t_0_5_MaxValue,Abs_Diff_t_1_0_MaxValue,Abs_Diff_t_2_0_MaxValue]
10
  print(X)
11
  outcome_decoded = ['Normal','Keratoconic','Suspect']
@@ -23,24 +26,31 @@ def STPI(t_0_5_MaxValue,t_1_0_MaxValue,t_2_0_MaxValue,Acc_0_5__1_0_MaxValue,Abs_
23
  file_object.write(str(Abs_Diff_t_1_0_MaxValue))
24
  file_object.write(';')
25
  file_object.write(str(Abs_Diff_t_2_0_MaxValue))
 
 
26
  file_object.write('\n')
27
  file_object.close()
28
 
29
  result_2way = loaded_rf_2way.predict([X])
30
- print('The patient is ', outcome_decoded[int(result_2way)], 'through the 2way method')
31
 
 
32
  if result_2way == 0:
33
- result_3way = loaded_rf_3way.predict([X])
34
  print('The patient is ', outcome_decoded[int(result_3way)], 'through the 3way method')
35
- return "The patient is " + outcome_decoded[int(result_3way)] + " using the 3way method and is " + outcome_decoded[int(result_2way)] + "through the 2way method"
 
 
 
 
 
36
 
37
-
38
- return "The patient is " + outcome_decoded[int(result_2way)] + " using the 2way method"
39
 
40
- iface = gr.Interface(fn=STPI,
41
- title='STPI Calculator',
42
- description='Calculates the STPI through summarized tomographic parameters. Beta version by Prof. Shady Awwad, Jad Assaf MD and Jawad Kaisania.',
43
- inputs=["number", "number","number", "number","number", "number","number"],
44
- outputs="text")
 
45
  iface.launch(share=True)
46
  # %%
 
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,Acc_0_5__1_0_MaxValue,Abs_Diff_t_0_5_MaxValue,Abs_Diff_t_1_0_MaxValue,Abs_Diff_t_2_0_MaxValue,optional_custom_message='No_Message'):
9
+ print('------------------')
10
+ print(optional_custom_message)
11
+
12
  X = [t_0_5_MaxValue,t_1_0_MaxValue,t_2_0_MaxValue,Acc_0_5__1_0_MaxValue,Abs_Diff_t_0_5_MaxValue,Abs_Diff_t_1_0_MaxValue,Abs_Diff_t_2_0_MaxValue]
13
  print(X)
14
  outcome_decoded = ['Normal','Keratoconic','Suspect']
 
26
  file_object.write(str(Abs_Diff_t_1_0_MaxValue))
27
  file_object.write(';')
28
  file_object.write(str(Abs_Diff_t_2_0_MaxValue))
29
+ file_object.write(';')
30
+ file_object.write(optional_custom_message)
31
  file_object.write('\n')
32
  file_object.close()
33
 
34
  result_2way = loaded_rf_2way.predict([X])
35
+ print('The patient is ', outcome_decoded[int(result_2way)], ' through the 2way method')
36
 
37
+ result_3way = loaded_rf_3way.predict([X])
38
  if result_2way == 0:
 
39
  print('The patient is ', outcome_decoded[int(result_3way)], 'through the 3way method')
40
+ # result = 'The 3-way classification resulted in a ', outcome_decoded[int(result_3way)] + ' patient.'
41
+ # further_analysis = 'Futher analysis using the 2-way classification resulted in a ' + outcome_decoded[int(result_2way)] + ' label.'
42
+ 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.'
43
+
44
+ # result = 'The 2-way classification resulted in a ', outcome_decoded[int(result_2way)] + ' patient.'
45
+ # further_analysis = 'Futher analysis using the 3-way classification resulted in a ' + outcome_decoded[int(result_3way)] + ' label.'
46
 
47
+ 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.'
 
48
 
49
+ iface = gr.Interface(
50
+ fn=STPI,
51
+ title='STPI Calculator',
52
+ description='Calculates the STPI through summarized tomographic parameters. Beta version by Prof. Shady Awwad, Jad Assaf MD and Jawad Kaisania.',
53
+ inputs=["number", "number","number", "number","number", "number","number","text"],
54
+ outputs="text")
55
  iface.launch(share=True)
56
  # %%