Spaces:
Build error
Build error
archietram
commited on
Commit
•
9eba1bb
1
Parent(s):
c155234
updated app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
def get_bmi(): return _
|
5 |
+
def get_age(): return _
|
6 |
+
def combine_loss(): return _
|
7 |
+
def age_loss(): return _
|
8 |
+
def bmi_loss(): return _
|
9 |
+
|
10 |
+
learn = load_learner("export.pkl")
|
11 |
+
|
12 |
+
|
13 |
+
def classify_image(img):
|
14 |
+
tst_dl = learn.dls.test_dl(img)
|
15 |
+
preds,_ = learn.get_preds(dl=tst_dl)
|
16 |
+
result_text = "This is a picture of a " + round(preds[0], 0) + " person with a BMI of" + round(preds[0], 1) + " kg/m^2"
|
17 |
+
return result_text
|
18 |
+
|
19 |
+
image = gr.inputs.Image(shape=(192,192))
|
20 |
+
label = gr.outputs.Label()
|
21 |
+
examples = ['A00147.png','A00360.png','angela lansbury.jpg']
|
22 |
+
title = 'Predict Age and Body Mass Index from a Picture'
|
23 |
+
description = 'This app predicts the age and BMI of a person just from their face.'
|
24 |
+
article = "Author: <a href=\"https://huggingface.co/archietram\">Archie Tram</a>. "
|
25 |
+
|
26 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs="text", examples=examples, title=title, description=description, article=article)
|
27 |
+
intf.launch(inline=False)
|