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], num_workers = 0) preds,_ = learn.get_preds(dl=tst_dl) result_text = "This person is " + str(round(preds[0][0].item(), 0)) + " years old with a BMI of " + str(round(preds[0][1].item(), 1)) + " kg/m^2" return result_text image = gr.inputs.Image() examples = ['A00147.png','K86344.png','A00360.png', "R89614.png", 'A01681.png', 'R79591.png','R86556.png', "R43263.png", 'Y15554.png', "X78069.png"] 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)