remove unused vars, set return val for fn
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
__all__ = ["is_cat" , "learn", "classify_image", "
|
| 2 |
|
| 3 |
from fastai.vision.all import *
|
| 4 |
import gradio as gr
|
|
@@ -8,11 +8,11 @@ def is_cat(x): return x[0].isupper()
|
|
| 8 |
|
| 9 |
learn = load_learner("model.pkl")
|
| 10 |
labels = learn.dls.vocab
|
| 11 |
-
categories = ("Dog", "Cat")
|
| 12 |
|
| 13 |
def classify_image(img):
|
|
|
|
| 14 |
pred,idx,probs = learn.predict(img)
|
| 15 |
-
return
|
| 16 |
|
| 17 |
image = gr.inputs.Image(shape=(192, 192))
|
| 18 |
outputs = gr.outputs.Label(num_top_classes=3)
|
|
|
|
| 1 |
+
__all__ = ["is_cat" , "learn", "classify_image", "image", "outputs", "labels", "examples", "intf"]
|
| 2 |
|
| 3 |
from fastai.vision.all import *
|
| 4 |
import gradio as gr
|
|
|
|
| 8 |
|
| 9 |
learn = load_learner("model.pkl")
|
| 10 |
labels = learn.dls.vocab
|
|
|
|
| 11 |
|
| 12 |
def classify_image(img):
|
| 13 |
+
img = PILImage.create(img)
|
| 14 |
pred,idx,probs = learn.predict(img)
|
| 15 |
+
return { labels[i]: float(probs[i]) for i in range(len(labels)) }
|
| 16 |
|
| 17 |
image = gr.inputs.Image(shape=(192, 192))
|
| 18 |
outputs = gr.outputs.Label(num_top_classes=3)
|