Dharma20 commited on
Commit
c4527cf
·
verified ·
1 Parent(s): 4cd8d5c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -6
app.py CHANGED
@@ -3,7 +3,7 @@ from fastai.vision.all import *
3
  import gradio as gr
4
 
5
  # %% ../hugging-space-model-app.ipynb 7
6
- learn = load_learner('model1.pkl')
7
 
8
  # %% ../hugging-space-model-app.ipynb 9
9
  labels = learn.dls.vocab
@@ -13,9 +13,15 @@ def classify_image(img):
13
  return {labels[i]: float(probs[i]) for i in range(len(labels))}
14
 
15
  # %% ../hugging-space-model-app.ipynb 11
16
- image = gr.components.Image()
17
- label = gr.components.Label(show_label=True,num_top_classes=3)
18
- examples = ['afraid.jpg','anger.jpg','happyface.jpg','disgust.jpg','sadface.webp','neutral.webp']
 
19
 
20
- intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
21
- intf.launch(inline=False)
 
 
 
 
 
 
3
  import gradio as gr
4
 
5
  # %% ../hugging-space-model-app.ipynb 7
6
+ learn = load_learner('model.pkl')
7
 
8
  # %% ../hugging-space-model-app.ipynb 9
9
  labels = learn.dls.vocab
 
13
  return {labels[i]: float(probs[i]) for i in range(len(labels))}
14
 
15
  # %% ../hugging-space-model-app.ipynb 11
16
+ with gr.Blocks(theme=gr.themes.Soft())as demo:
17
+ gr.HTML("<center><h1>EmoPix - Facial Expressions Classifier! 😊😞</h1><center>")
18
+ gr.Markdown("""##### Classifies human facial expressions from an uploaded image.
19
+ <b>Upload images and have fun🤗. Classifies facial expressions with 75% accuracy</b>""")
20
 
21
+
22
+ gr.Interface(fn=classify_image,
23
+ inputs=gr.components.Image(),
24
+ outputs=gr.components.Label(show_label=True,num_top_classes=3))
25
+
26
+
27
+ demo.launch(inline=False)