Spaces:
Runtime error
Runtime error
archeltaneka
commited on
Commit
•
7bb9ddb
1
Parent(s):
b4092d2
Upload app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,18 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
import gradio as gr
|
3 |
|
4 |
+
# model
|
5 |
+
learn = load_learner("face_mask_detection_model.pkl")
|
6 |
+
labels = {"Wearing Mask", "No Mask"}
|
7 |
|
8 |
+
def classify_image(img):
|
9 |
+
pred, idx, probs = learn.predict(img)
|
10 |
+
return dict(zip(labels, map(float, probs)))
|
11 |
+
|
12 |
+
# gradio interface
|
13 |
+
image = gr.inputs.Image(shape=(224,224))
|
14 |
+
label = gr.outputs.Label()
|
15 |
+
examples = ["example.jpg"]
|
16 |
+
|
17 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
18 |
+
intf.launch(inline=False)
|