Spaces:
Runtime error
Runtime error
Added full model
Browse files
app.py
CHANGED
|
@@ -1,23 +1,16 @@
|
|
| 1 |
from fastai.vision.all import *
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
probs=[9.9996e-01, 1.1584e-08, 1.8556e-07, 1.6986e-06, 3.5755e-08,
|
| 7 |
-
1.3057e-06, 2.7230e-08, 5.8373e-08, 1.3209e-08, 1.8147e-10,
|
| 8 |
-
2.8197e-08, 9.4939e-09, 8.8776e-09, 7.7736e-08, 3.0117e-08,
|
| 9 |
-
2.8444e-09, 9.8802e-09, 5.9252e-08, 1.9288e-08, 1.2375e-07,
|
| 10 |
-
8.2446e-08, 1.6437e-06, 2.4753e-08, 1.1622e-05, 6.6616e-09,
|
| 11 |
-
1.8746e-08, 1.6764e-05, 9.2635e-07, 2.6931e-09, 1.1366e-08,
|
| 12 |
-
1.7266e-09, 1.7419e-08, 3.6652e-08, 2.4264e-07, 8.6940e-08,
|
| 13 |
-
1.0518e-07]
|
| 14 |
|
|
|
|
| 15 |
def sample_predict(img):
|
| 16 |
img = PILImage.create(img)
|
|
|
|
| 17 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 18 |
|
| 19 |
intf=gr.Interface(fn=sample_predict,
|
| 20 |
-
inputs=gr.
|
| 21 |
-
outputs=gr.
|
| 22 |
|
| 23 |
intf.launch()
|
|
|
|
| 1 |
from fastai.vision.all import *
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
learn=load_learner("model.pkl")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
+
labels=learn.dls.vocab
|
| 7 |
def sample_predict(img):
|
| 8 |
img = PILImage.create(img)
|
| 9 |
+
pred,pred_idx,probs=learn.predict(img)
|
| 10 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 11 |
|
| 12 |
intf=gr.Interface(fn=sample_predict,
|
| 13 |
+
inputs=gr.components.Image(shape=(256, 256)),
|
| 14 |
+
outputs=gr.components.Label(num_top_classes=3))
|
| 15 |
|
| 16 |
intf.launch()
|