Spaces:
Runtime error
Runtime error
Commit
·
fb2233b
1
Parent(s):
d1c293f
add app demo
Browse files
app.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from fastai.vision.all import *
|
| 3 |
+
|
| 4 |
+
learner = load_learner("models/batch_size_64_device_cuda_lr_0.01_n_epoch_30_seed_42_valid_pct_0.2.pkl", cpu=False)
|
| 5 |
+
|
| 6 |
+
labels = learner.dls.vocab
|
| 7 |
+
|
| 8 |
+
def classify(img):
|
| 9 |
+
pred, pred_idx, probs = learner.predict(img)
|
| 10 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 11 |
+
|
| 12 |
+
interface = gr.Interface(fn=classify, inputs="sketchpad", outputs=gr.outputs.Label(num_top_classes=5), live=True)
|
| 13 |
+
interface.launch(debug=True, share=True)
|