Spaces:
Runtime error
Runtime error
Malay Shah
commited on
Commit
•
457c8da
1
Parent(s):
b78aa09
Add app to huggingfaces spaces
Browse files- app.py +19 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
import skimage
|
4 |
+
|
5 |
+
gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=2)).launch(share=True)
|
6 |
+
|
7 |
+
learn = load_learning('export.pkl')
|
8 |
+
|
9 |
+
labels = learn.dls.vocab
|
10 |
+
|
11 |
+
def predict(img):
|
12 |
+
img = PILImage.create(img)
|
13 |
+
pred, pred_idx, probs = learn.predict(img)
|
14 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
15 |
+
|
16 |
+
|
17 |
+
|
18 |
+
|
19 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
fastai
|
2 |
+
scikit-image
|