Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,16 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
iface = gr.Interface(fn=
|
7 |
-
iface.launch()
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
import gradio as gr
|
3 |
|
4 |
+
path = Path()
|
5 |
+
learn_inf = load_learner(path/'export.pkl')
|
6 |
+
def classify_image(img):
|
7 |
+
pred,pred_idx,probs = learn_inf.predict(img)
|
8 |
+
return f'Prediction: {pred}; Probability: float({probs[pred_idx]:.04f})'
|
9 |
+
|
10 |
+
image = gr.inputs.Image(shape=(224, 224))
|
11 |
+
label = gr.outputs.Label()
|
12 |
+
examples = ['1.jpg', '2.jpg', '3.jpg']
|
13 |
+
|
14 |
|
15 |
+
iface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
16 |
+
iface.launch(inline=False)
|