TSPIv3 / app.py
JadAssaf
Model Update
50cddb6
raw
history blame
1.91 kB
# %%
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
)
# %%