File size: 1,985 Bytes
e49cbdd
 
 
 
 
 
 
ae1ffe3
 
e49cbdd
ae1ffe3
 
 
 
 
 
 
 
 
 
 
 
e49cbdd
 
ae1ffe3
e49cbdd
 
 
bb1c225
 
e49cbdd
 
 
 
ae1ffe3
e49cbdd
954624d
 
 
 
 
 
 
 
e49cbdd
 
 
 
 
 
954624d
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
# %%
import gradio as gr
from joblib import load

file_name = 'Zernike_pipeline.pkl'
model = load(file_name)

# cols 6,7,10,13,18,20,23,30
indices = ['x', 'x', 'x', 'x', 'x', 'x', 'z(0,0)', 'z(1,-1)', 'z(1,+1)', 'z(2,-2)', 'z(2,0)', 'z(2,+2)', 'z(3,-3)', 'z(3,-1)', 'z(3,+1)', 'z(3,+3)', 'z(4,-4)', 'z(4,-2)', 'z(4,0)', 'z(4,+2)', 'z(4,+4)', 'z(5,-5)', 'z(5,-3)', 'z(5,-1)', 'z(5,+1)', 'z(5,+3)', 'z(5,+5)', 'z(6,-6)', 'z(6,-4)', 'z(6,-2)', 'z(6,0)', 'z(6,+2)', 'z(6,+4)', 'z(6,+6)', 'z(7,-7)', 'z(7,-5)', 'z(7,-3)', 'z(7,-1)', 'z(7,+1)', 'z(7,+3)', 'z(7,+5)', 'z(7,+7)']

# extract the columns
z1_label = indices[6]
z2_label = indices[7]
z3_label = indices[10]
z4_label = indices[13]
z5_label = indices[18]
z6_label = indices[20]
z7_label = indices[23]
z8_label = indices[30]


def Zernike(z1,z2,z3,z4,z5,z6,z7,z8):
    print('------------------')
    
    X = [z1,z2,z3,z4,z5,z6,z7,z8]
    print(X)
    outcome_decoded = ['Normal','Borderline','Suspicious','Keratoconic']

    result = model.predict([X])
    return 'The patient is ' + outcome_decoded[int(result)] + '.'

iface = gr.Interface(
    fn=Zernike, 
    title='Awwad-Versaci Keratoconus Index',
    description='The Awwad-Versaci Keratoconus Index (AVKI) detects keratoconus and keratoconus susceptible corneas through pachymetry maps centered on the thinnest point and fitted into Zernike polynomials. Beta version by Shady Awwad, Anthony Abou Mrad, MD, Jad Assaf, MD, and Francesco Versaci, PhD. This is the 4-way classification. The Zernke polynomials were taken from the 4mm cornea centered on the thinnest point and selected from highest ROC curves',
    inputs=[
        gr.Number(label=z1_label),
        gr.Number(label=z2_label),
        gr.Number(label=z3_label),
        gr.Number(label=z4_label),
        gr.Number(label=z5_label),
        gr.Number(label=z6_label),
        gr.Number(label=z7_label),
        gr.Number(label=z8_label)
    ],
    outputs="text")
iface.launch(
    # share=True
    )
# %%
# %%