ved_T
commited on
Commit
·
ec2d4b8
1
Parent(s):
4fed069
doen
Browse files
app.py
CHANGED
@@ -1,14 +1,21 @@
|
|
1 |
-
|
2 |
from fastai.vision.all import *
|
3 |
import gradio as gr
|
4 |
-
|
5 |
-
def is_cat(x):
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
7 |
def classify_image(img):
|
8 |
-
|
9 |
-
|
|
|
10 |
image = gr.components.Image(label="Image Input")
|
11 |
-
label= gr.components.Label(label="Image
|
12 |
-
examples = ['dog.jpg','cat.jpg','0002a367-38b4-41c3-a47c-b11e104b394b.jpg']
|
13 |
-
|
14 |
-
intf.
|
|
|
|
1 |
+
|
2 |
from fastai.vision.all import *
|
3 |
import gradio as gr
|
4 |
+
|
5 |
+
def is_cat(x):
|
6 |
+
return x[0].isupper()
|
7 |
+
|
8 |
+
learn = load_learner('model.pkl')
|
9 |
+
|
10 |
+
categories = ('Dog', 'Cat')
|
11 |
+
|
12 |
def classify_image(img):
|
13 |
+
pred, idx, probs = learn.predict(img)
|
14 |
+
return dict(zip(categories, map(float, probs)))
|
15 |
+
|
16 |
image = gr.components.Image(label="Image Input")
|
17 |
+
label = gr.components.Label(label="Image Output")
|
18 |
+
examples = ['dog.jpg', 'cat.jpg', '0002a367-38b4-41c3-a47c-b11e104b394b.jpg']
|
19 |
+
|
20 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
21 |
+
intf.launch(inline=False)
|