Spaces:
Runtime error
Runtime error
Yousef Rafat
commited on
Commit
·
2ff8ae9
1
Parent(s):
360ae83
Classifier
Browse files
app.py
CHANGED
|
@@ -1,8 +1,26 @@
|
|
| 1 |
-
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
-
def
|
| 5 |
-
return "Hello " + name + "!!"
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastai.vision.all import *
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
def is_cat(x): return x[0].isupper()
|
|
|
|
| 5 |
|
| 6 |
+
learn = load_learner('model.pkl')
|
| 7 |
+
|
| 8 |
+
categories = ('Dog', 'Cat')
|
| 9 |
+
|
| 10 |
+
def classify_image(img):
|
| 11 |
+
pred, idx, probs = learn.predict(img)
|
| 12 |
+
|
| 13 |
+
return dict(zip(categories, map(float, probs)))
|
| 14 |
+
|
| 15 |
+
from gradio.components import Image, Label
|
| 16 |
+
|
| 17 |
+
label = Label()
|
| 18 |
+
image = Image() #shape = (192, 192)
|
| 19 |
+
examples=[
|
| 20 |
+
"/content/cat.jpg"]
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
intf = gr.Interface(fn = classify_image, inputs = image, outputs = label, examples = examples)
|
| 24 |
+
|
| 25 |
+
# Launch the web interface with the image and label components
|
| 26 |
+
intf.launch(inline = False)
|