updated app file
Browse files
app.py
CHANGED
@@ -1,7 +1,25 @@
|
|
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
-
def greet(name):
|
4 |
-
|
5 |
|
6 |
-
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
7 |
-
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
import gradio as gr
|
3 |
+
from fastbook import *
|
4 |
+
from fastdownload import download_url
|
5 |
|
6 |
+
# def greet(name):
|
7 |
+
# return "Hello " + name + "!!"
|
8 |
|
9 |
+
# iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
10 |
+
# iface.launch()
|
11 |
+
|
12 |
+
def is_cat(x): return x[0].isupper()
|
13 |
+
learn = load_learner("model.pkl")
|
14 |
+
|
15 |
+
categories = ('Dog', 'Cat')
|
16 |
+
def classify_image(img):
|
17 |
+
pred, idx, probs = learn.predict(img)
|
18 |
+
return dict(zip(categories, map(float,probs)))
|
19 |
+
|
20 |
+
image = gr.inputs.Image(shape=(192,192))
|
21 |
+
label = gr.outputs.Label()
|
22 |
+
example = ['cat.jpg', 'dog.jpg']
|
23 |
+
|
24 |
+
intr = gr.Interface(fn = classify_image, inputs=image, outputs=label, examples=example)
|
25 |
+
intr.launch(inline=False)
|