from fastai.vision.all import * import gradio as gr def get_bmi(): return _ def get_age(): return _ def combine_loss(): return _ def age_loss(): return _ def bmi_loss(): return _ learn = load_learner("export.pkl") def classify_image(img): tst_dl = learn.dls.test_dl(img) preds,_ = learn.get_preds(dl=tst_dl) result_text = "This is a picture of a " + round(preds[0], 0) + " person with a BMI of" + round(preds[0], 1) + " kg/m^2" return result_text image = gr.inputs.Image(shape=(192,192)) label = gr.outputs.Label() examples = ['A00147.png','A00360.png','angela lansbury.jpg'] title = 'Predict Age and Body Mass Index from a Picture' description = 'This app predicts the age and BMI of a person just from their face.' article = "Author: Archie Tram. " intf = gr.Interface(fn=classify_image, inputs=image, outputs="text", examples=examples, title=title, description=description, article=article) intf.launch(inline=False)