# %% import gradio as gr import pickle import imblearn file_name = 'TSPI_model.sav' model = pickle.load(open(file_name,'rb')) def STPI(t_1_MaxValue,t_2_MaxValue,t_2_0_MaxValue, # Acc_0_5__1_0_MaxValue, Abs_Diff_t_1_MaxValue,Abs_Diff_t_2_MaxValue,Abs_Diff_t_4_MaxValue): print('------------------') X = [t_1_MaxValue,t_2_MaxValue,t_2_0_MaxValue, # Acc_0_5__1_0_MaxValue, Abs_Diff_t_1_MaxValue,Abs_Diff_t_2_MaxValue,Abs_Diff_t_4_MaxValue] print(X) outcome_decoded = ['Normal','Suspect','Keratoconic'] file_object = open('stpi_data.txt', 'a') file_object.write(str(t_1_MaxValue)) file_object.write(';') file_object.write(str(t_2_MaxValue)) file_object.write(';') file_object.write(str(t_2_0_MaxValue)) file_object.write(';') # file_object.write(str(Acc_0_5__1_0_MaxValue)) # file_object.write(';') file_object.write(str(Abs_Diff_t_1_MaxValue)) file_object.write(';') file_object.write(str(Abs_Diff_t_2_MaxValue)) file_object.write(';') file_object.write(str(Abs_Diff_t_4_MaxValue)) 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.', inputs=["number", "number","number", # "number", "number", "number","number"], outputs="text") iface.launch( # share=True ) # %%