Spaces:
Sleeping
Sleeping
Image classifier for Ship and Aeroplane
Browse files- app.py +13 -4
- model.pkl +3 -0
- requirements.txt +1 -0
app.py
CHANGED
@@ -1,7 +1,16 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
|
4 |
+
learn = load_learner('model.pkl')
|
5 |
+
labels = learn.dls.vocab
|
6 |
|
7 |
+
def 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 |
+
gr.Interface(
|
13 |
+
fn=predict,
|
14 |
+
inputs=gr.inputs.Image(shape=(512, 512)),
|
15 |
+
outputs=gr.outputs.Label(num_top_classes=2)
|
16 |
+
).launch()
|
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c1175767d40f27e72750b54cc950df8405d615a9b43eae7e7d9e259c29656640
|
3 |
+
size 46963389
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
fastai
|