Spaces:
Sleeping
Sleeping
Leo Hu
commited on
Commit
•
3a3fcf3
1
Parent(s):
3a3ee4b
initial commit for huggingface
Browse files- app.py +21 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
import skimage
|
4 |
+
|
5 |
+
learn = load_learner('model.pkl')
|
6 |
+
|
7 |
+
labels = learn.dls.vocab
|
8 |
+
|
9 |
+
def predict(img):
|
10 |
+
img = PILImage.create(img)
|
11 |
+
pred,pred_idx,probs = learn.predict(img)
|
12 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
13 |
+
|
14 |
+
interface=gr.Interface(
|
15 |
+
fn=predict,
|
16 |
+
inputs=gr.Image(shape=(512, 512)),
|
17 |
+
outputs=gr.Label(num_top_classes=3),
|
18 |
+
interpretation='default'
|
19 |
+
)
|
20 |
+
interface.queue()
|
21 |
+
interface.launch(share=True)
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
fastai
|
2 |
+
scikit-image
|