Spaces:
Sleeping
Sleeping
kpkishankrishna commited on
Commit ·
5f5346a
1
Parent(s): 990c29e
main3
Browse files
app.py
CHANGED
|
@@ -1,8 +1,25 @@
|
|
|
|
|
| 1 |
from fastai.vision.all import *
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
-
def
|
| 5 |
-
return "Hello " + name + "!!"
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastbook import *
|
| 2 |
from fastai.vision.all import *
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
+
def is_cat(x): return x[0].isupper()
|
|
|
|
| 6 |
|
| 7 |
+
img = PILImage.create(image_cat())
|
| 8 |
+
img.to_thumb(192)
|
| 9 |
+
|
| 10 |
+
learn = load_learner('/Users/krushn/Downloads/model.pkl')
|
| 11 |
+
|
| 12 |
+
learn.predict(img)
|
| 13 |
+
|
| 14 |
+
catagories = ('Dog','Cat')
|
| 15 |
+
def classify_image(img):
|
| 16 |
+
pred, idx, probs = learn.predict(img)
|
| 17 |
+
return dict(zip(catagories, map(float, probs)))
|
| 18 |
+
|
| 19 |
+
image = gr.inputs.Image(shape=(192,192))
|
| 20 |
+
label = gr.outputs.Label()
|
| 21 |
+
examples = ['Ragdoll_235.jpg', 'saint_bernard_28.jpg', 'Ragdoll_254.jpg', 'samoyed_4.jpg','Ragdoll_202.jpg', 'saint_bernard_23.jpg']
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
intf = gr.Interface(fn = classify_image, inputs = image, outputs = label, examples = examples)
|
| 25 |
+
intf.launch(inline =False)
|