Spaces:
Runtime error
Runtime error
Rename app to app.py
Browse files- app → app.py +6 -13
app → app.py
RENAMED
|
@@ -1,21 +1,14 @@
|
|
| 1 |
-
import
|
|
|
|
| 2 |
from fastai.vision.all import *
|
| 3 |
-
|
| 4 |
learn = load_learner('export.pkl')
|
|
|
|
| 5 |
labels = learn.dls.vocab
|
| 6 |
def predict(img):
|
| 7 |
img = PILImage.create(img)
|
| 8 |
pred,pred_idx,probs = learn.predict(img)
|
| 9 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
inputs=gr.Image(),
|
| 14 |
-
outputs=gr.Label(num_top_classes=3)
|
| 15 |
-
)
|
| 16 |
-
|
| 17 |
-
# Enable the queue to handle POST requests
|
| 18 |
-
interface.queue(api_open=True)
|
| 19 |
-
|
| 20 |
-
# Launch the interface
|
| 21 |
-
interface.launch()
|
|
|
|
| 1 |
+
import timm
|
| 2 |
+
from fastbook import *
|
| 3 |
from fastai.vision.all import *
|
| 4 |
+
|
| 5 |
learn = load_learner('export.pkl')
|
| 6 |
+
|
| 7 |
labels = learn.dls.vocab
|
| 8 |
def predict(img):
|
| 9 |
img = PILImage.create(img)
|
| 10 |
pred,pred_idx,probs = learn.predict(img)
|
| 11 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 12 |
|
| 13 |
+
import gradio as gr
|
| 14 |
+
gr.Interface(fn=predict, inputs=gr.Image(), outputs=gr.Label(num_top_classes=3)).launch(share=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|