Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -8,6 +8,8 @@ labels = learn.dls.vocab
|
|
8 |
|
9 |
def predict(img):
|
10 |
img = PILImage.create(img)
|
|
|
|
|
11 |
_pred, _pred_w_idx, probs = learn.predict(img)
|
12 |
# gradio doesn't support tensors, so converting to float
|
13 |
labels_probs = {labels[i]: float(probs[i]) for i, _ in enumerate(labels)}
|
@@ -28,7 +30,7 @@ interface_options = {
|
|
28 |
demo = gr.Interface(
|
29 |
fn=predict,
|
30 |
inputs=gr.inputs.Image(shape=(480, 480)),
|
31 |
-
outputs=gr.outputs.Label(num_top_classes=
|
32 |
**interface_options,
|
33 |
)
|
34 |
|
|
|
8 |
|
9 |
def predict(img):
|
10 |
img = PILImage.create(img)
|
11 |
+
size = (224, 224)
|
12 |
+
img = img.thumbnail(size, Image.ANTIALIAS)
|
13 |
_pred, _pred_w_idx, probs = learn.predict(img)
|
14 |
# gradio doesn't support tensors, so converting to float
|
15 |
labels_probs = {labels[i]: float(probs[i]) for i, _ in enumerate(labels)}
|
|
|
30 |
demo = gr.Interface(
|
31 |
fn=predict,
|
32 |
inputs=gr.inputs.Image(shape=(480, 480)),
|
33 |
+
outputs=gr.outputs.Label(num_top_classes=2),
|
34 |
**interface_options,
|
35 |
)
|
36 |
|