Spaces:
Runtime error
Runtime error
Commit
·
32408db
1
Parent(s):
d2e3930
Fast Predict
Browse files- .vscode/settings.json +6 -0
- app.py +15 -4
- chai.jpg +0 -0
- coffee.jpg +0 -0
- model.pkl +3 -0
.vscode/settings.json
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"[python]": {
|
3 |
+
"editor.defaultFormatter": "ms-python.autopep8"
|
4 |
+
},
|
5 |
+
"python.formatting.provider": "none"
|
6 |
+
}
|
app.py
CHANGED
@@ -1,7 +1,18 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
return "Hello " + name + "!!"
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
|
4 |
+
learn = load_learner('model.pkl')
|
|
|
5 |
|
6 |
+
|
7 |
+
def classify_image(img):
|
8 |
+
pred, idx, probs = learn.predict(img)
|
9 |
+
return dict(zip(("Chai", "Coffee"), map(float, probs)))
|
10 |
+
|
11 |
+
|
12 |
+
image = gr.inputs.Image(shape=(192, 192))
|
13 |
+
label = gr.outputs.Label()
|
14 |
+
examples = ["chai.jpg", ""]
|
15 |
+
|
16 |
+
intf = gr.Interface(fn=classify_image, inputs=image,
|
17 |
+
outputs=label, examples=examples)
|
18 |
+
intf.launch(inline=False)
|
chai.jpg
ADDED
![]() |
coffee.jpg
ADDED
![]() |
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8f36c5b4c0fc05eff35c4ac054f70c22bb4000669ba14a00997c50f501ca8008
|
3 |
+
size 87456793
|