File size: 991 Bytes
9eba1bb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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: <a href=\"https://huggingface.co/archietram\">Archie Tram</a>. "

intf = gr.Interface(fn=classify_image, inputs=image, outputs="text", examples=examples, title=title, description=description, article=article)
intf.launch(inline=False)