File size: 1,914 Bytes
5a6f531
 
efb2a5c
 
203a444
be6ab4a
96fb78a
 
efb2a5c
 
5a6f531
 
e746e73
5a6f531
e746e73
5a6f531
 
e746e73
5a6f531
e746e73
5a6f531
203a444
5a6f531
e746e73
5a6f531
e746e73
5a6f531
e746e73
5a6f531
 
 
e746e73
5a6f531
e746e73
5a6f531
e746e73
5a6f531
 
 
 
 
203a444
5a6f531
 
 
 
 
 
 
50cddb6
5a6f531
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# %%
import gradio as gr
import joblib
import dill
# import pickle
import imblearn
import sklearn
import xgboost
file_name = 'TSPI_model_joblib.sav'
model = joblib.load(file_name)


def STPI(TS4,TS2,TS1,
# Acc_0_5__1_0_MaxValue,
DTS4,DTS2,DTS1):
    print('------------------')
    
    X = [TS4,TS2,TS1,
    # Acc_0_5__1_0_MaxValue,
    DTS4,DTS2,DTS1]
    print(X)
    outcome_decoded = ['Normal','','Suspect','Keratoconic']
    file_object = open('stpi_data.txt', 'a')
    file_object.write(str(TS4))
    file_object.write(';')
    file_object.write(str(TS2))
    file_object.write(';')
    file_object.write(str(TS1))
    file_object.write(';')
    # file_object.write(str(Acc_0_5__1_0_MaxValue))
    # file_object.write(';')
    file_object.write(str(DTS4))
    file_object.write(';')
    file_object.write(str(DTS2))
    file_object.write(';')
    file_object.write(str(DTS1))
    file_object.write(';')
    file_object.write('\n')
    file_object.close()

    result_3way = model.predict([X])
    # print('The patient is ', outcome_decoded[int(result_3way)], 'through the 3way method')
    # result = 'The 3-way classification resulted in a ', outcome_decoded[int(result_3way)] + ' patient.'
    # further_analysis = 'Futher analysis using the 2-way classification resulted in a ' + outcome_decoded[int(result_2way)] + ' label.'
    return 'The patient is ' + outcome_decoded[int(result_3way)] + '.'

iface = gr.Interface(
    fn=STPI, 
    title='TSPI Calculator',
    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 3-way classification.',
    inputs=["number", "number","number", 
    # "number",
    "number", "number","number"],
    outputs="text")
iface.launch(
    # share=True
    )
# %%