#Bismillahir Rahmaanir Raheem #Almadadh Ya Gause RadiAllahu Ta'alah Anh - Ameen import gradio as gr import pandas as pd from pycaret.classification import load_model, predict_model # load the trained model for predictions model = load_model('tuned_blend_specific_model_19112021') # define the function to call def predict(model, input_df): predictions_df = predict_model(estimator=model, data=input_df) predict_label = predictions_df["Label"][0] # either 1 (amputation yes) or 0 (amputation no) predict_score = predictions_df["Score"][0] # the prediction (accuracy) amputation_risk = "" if predict_label == 1: amputation_risk = "YES" amputation_risk_output = "Amputation Risk: " + amputation_risk score_output = "Score: "+str(predict_score) html = "
Copyright © DIARC. 2021. All Rights Reserved. Contact Us: Dr Sifisiso Mtshali or Dr Ozayr Mahomed
" iface = gr.Interface( fn=predict_amputation, title=title, description=description, article=article, inputs=[gr.inputs.Slider(minimum=0,maximum=100, step=1, default=0, label="Age"), gr.inputs.Dropdown(["Female", "Male"], default="Female", label="Gender"), gr.inputs.Dropdown(["Asian", "Black", "Coloured", "White", "Other"], default="Asian", label="Race"), gr.inputs.Dropdown(["1", "2"], default="1", label="Diabetes Type")], outputs="html", theme="grass", examples=[ [50, "Male", "Black", 2], [76, "Female", "Asian", 2], [12, "Female", "White", 1], [30, "Male", "Coloured", 1], [65, "Female", "Other", 2], ], ) iface.test_launch() if __name__ == "__main__": iface.launch()