|
|
|
import gradio as gr |
|
import joblib |
|
import dill |
|
|
|
import imblearn |
|
import sklearn |
|
import xgboost |
|
file_name = 'TSPI_model_joblib.sav' |
|
model = joblib.load(file_name) |
|
|
|
|
|
def STPI(TS4,TS2,TS1, |
|
|
|
DTS4,DTS2,DTS1): |
|
print('------------------') |
|
|
|
X = [TS4,TS2,TS1, |
|
|
|
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(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]) |
|
|
|
|
|
|
|
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"], |
|
outputs="text") |
|
iface.launch( |
|
|
|
) |
|
|
|
|