Update app.py
Browse files
app.py
CHANGED
|
@@ -7,21 +7,21 @@ import pandas as pd
|
|
| 7 |
plt = platform.system()
|
| 8 |
if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath
|
| 9 |
|
| 10 |
-
learn = load_learner('export.pkl')
|
| 11 |
|
| 12 |
-
labels = learn.dls.vocab
|
| 13 |
-
def predict(img):
|
| 14 |
-
img = PILImage.create(img)
|
| 15 |
-
pred,pred_idx,probs = learn.predict(img)
|
| 16 |
-
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 17 |
|
| 18 |
-
title = "
|
| 19 |
-
description = "
|
| 20 |
examples = [['harmonal_acne.jpg'],['forehead_wrinkles.jpg'],['oily_skin.jpg']]
|
| 21 |
enable_queue=True
|
| 22 |
|
| 23 |
-
gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),outputs=gr.outputs.Label(num_top_classes=3),title=title,
|
| 24 |
-
description=description,examples=examples,enable_queue=enable_queue).launch()
|
| 25 |
with gr.Blocks(title=title,description=description,examples=examples,enable_queue=enable_queue) as demo:
|
| 26 |
learn = load_learner('export.pkl')
|
| 27 |
labels = learn.dls.vocab
|
|
@@ -29,17 +29,17 @@ with gr.Blocks(title=title,description=description,examples=examples,enable_queu
|
|
| 29 |
img = PILImage.create(img)
|
| 30 |
pred,pred_idx,probs = learn.predict(img)
|
| 31 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 32 |
-
gr.Markdown("#
|
| 33 |
-
gr.Markdown("
|
| 34 |
with gr.Row():
|
| 35 |
inputs = gr.inputs.Image(shape=(512, 512))
|
| 36 |
outputs = gr.outputs.Label(num_top_classes=3)
|
| 37 |
-
btn = gr.Button("
|
| 38 |
btn.click(fn=predict, inputs=inputs, outputs=outputs)
|
| 39 |
|
| 40 |
df=pd.read_excel("recommendation.xlsx")
|
| 41 |
classes = df['class'].unique()
|
| 42 |
-
with gr.Accordion("
|
| 43 |
for c in classes:
|
| 44 |
with gr.Accordion(c,open=False):
|
| 45 |
df_temp = df[df['class']==c]
|
|
|
|
| 7 |
plt = platform.system()
|
| 8 |
if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath
|
| 9 |
|
| 10 |
+
# learn = load_learner('export.pkl')
|
| 11 |
|
| 12 |
+
# labels = learn.dls.vocab
|
| 13 |
+
# def predict(img):
|
| 14 |
+
# img = PILImage.create(img)
|
| 15 |
+
# pred,pred_idx,probs = learn.predict(img)
|
| 16 |
+
# return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 17 |
|
| 18 |
+
title = "Face condition Analyzer"
|
| 19 |
+
description = "A face condition detector trained on the custom dataset with fastai. Created using Gradio and HuggingFace Spaces."
|
| 20 |
examples = [['harmonal_acne.jpg'],['forehead_wrinkles.jpg'],['oily_skin.jpg']]
|
| 21 |
enable_queue=True
|
| 22 |
|
| 23 |
+
# gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),outputs=gr.outputs.Label(num_top_classes=3),title=title,
|
| 24 |
+
# description=description,examples=examples,enable_queue=enable_queue).launch()
|
| 25 |
with gr.Blocks(title=title,description=description,examples=examples,enable_queue=enable_queue) as demo:
|
| 26 |
learn = load_learner('export.pkl')
|
| 27 |
labels = learn.dls.vocab
|
|
|
|
| 29 |
img = PILImage.create(img)
|
| 30 |
pred,pred_idx,probs = learn.predict(img)
|
| 31 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 32 |
+
gr.Markdown("# Face Skin Analyzer")
|
| 33 |
+
gr.Markdown("A face condition detector trained on the custom dataset with fastai. Created using Gradio and HuggingFace Spaces. Kindly upload a photo of your face.")
|
| 34 |
with gr.Row():
|
| 35 |
inputs = gr.inputs.Image(shape=(512, 512))
|
| 36 |
outputs = gr.outputs.Label(num_top_classes=3)
|
| 37 |
+
btn = gr.Button("Predict")
|
| 38 |
btn.click(fn=predict, inputs=inputs, outputs=outputs)
|
| 39 |
|
| 40 |
df=pd.read_excel("recommendation.xlsx")
|
| 41 |
classes = df['class'].unique()
|
| 42 |
+
with gr.Accordion("Find your skin condition using above analyzer and see the Recommended solutions",open=False):
|
| 43 |
for c in classes:
|
| 44 |
with gr.Accordion(c,open=False):
|
| 45 |
df_temp = df[df['class']==c]
|