# %% import gradio as gr from joblib import load file_name = 'Zernike_pipeline.pkl' model = load(file_name) def Zernike(z1,z2,z3,z4,z5,z6,z7): print('------------------') X = [z1,z2,z3,z4,z5,z6,z7] print(X) outcome_decoded = ['Normal','Borderline','Suspicious','Keratoconic'] file_object = open('stpi_data.txt', 'a') file_object.write(str(z1)) file_object.write(';') file_object.write(str(z2)) file_object.write(';') file_object.write(str(z3)) file_object.write(';') file_object.write(str(z4)) file_object.write(';') file_object.write(str(z5)) file_object.write(';') file_object.write(str(z6)) file_object.write(';') file_object.write('\n') file_object.close() result_3way = model.predict([X]) return 'The patient is ' + outcome_decoded[int(result_3way)] + '.' 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 2mm cornea centered on the thinnest point the selected polynomials are z(0,0) z(1,-1) z(2,0) z(3,-1) z(4,0) z(6,0) z(7,-1) from highest ROC curves', # inputs=["number", "number","number", "number", "number","number"], inputs=[ gr.inputs.Number(label="z(0,0)"), gr.inputs.Number(label="z(1,-1)"), gr.inputs.Number(label="z(2,0)"), gr.inputs.Number(label="z(3,-1)"), gr.inputs.Number(label="z(4,0)"), gr.inputs.Number(label="z(6,0)"), gr.inputs.Number(label="z(7,-1)") ], outputs="text") iface.launch( # share=True ) # %%