Spaces:
Build error
Build error
mulkong commited on
Commit ·
4d65424
1
Parent(s): 860bc2d
add model file
Browse files- app.py +30 -4
- model.pkl +3 -0
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -1,7 +1,33 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
|
| 4 |
-
return "Hello " + name + "!!"
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastai.vision.all import *
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
learn_inf = load_learner('model.pkl')
|
|
|
|
| 5 |
|
| 6 |
+
labels = learn.dls.vocab
|
| 7 |
+
|
| 8 |
+
def predict(img):
|
| 9 |
+
img = PILImage.create(img)
|
| 10 |
+
pred, pred_idx, probs = learn.predict(img)
|
| 11 |
+
return {
|
| 12 |
+
labels[i]: float(probs[i]) for i in range(len(labels))
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
gr.Interface(
|
| 16 |
+
title="Late Night Host Classifier",
|
| 17 |
+
description="Upload a photo of Jimmy Kimmel, Jimmy Fallon or Conan O'Brien",
|
| 18 |
+
fn=predict,
|
| 19 |
+
inputs=gr.Image(),
|
| 20 |
+
outputs=gr.Label(num_top_classes=3),
|
| 21 |
+
# examples=[],
|
| 22 |
+
# enable_queue=True,
|
| 23 |
+
).launch(
|
| 24 |
+
# share=True,
|
| 25 |
+
# debug=True
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
# def greet(name):
|
| 30 |
+
# return "Hello " + name + "!!"
|
| 31 |
+
|
| 32 |
+
# iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 33 |
+
# iface.launch()
|
model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b041cfbd52c5a85a6241abb335630d48f5a3daf89aec8f4066b08227d23ec1e7
|
| 3 |
+
size 46974506
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
fastai
|