Spaces:
Runtime error
Runtime error
tkelley353
commited on
Commit
•
66d9faa
1
Parent(s):
43cdfba
added app and requirements files
Browse files- app.py +23 -0
- c172-test.jpeg +0 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
import skimage
|
4 |
+
|
5 |
+
learn = load_learner('export.pkl')
|
6 |
+
|
7 |
+
labels = learn.dls.vocab
|
8 |
+
|
9 |
+
|
10 |
+
def predict(img):
|
11 |
+
img = PILImage.create(img)
|
12 |
+
pred, pred_idx, probs = learn.predict(img)
|
13 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
14 |
+
|
15 |
+
|
16 |
+
title = "Aircraft Classifier"
|
17 |
+
description = "An aircraft classifier trained on internet photos with fastai. Created as a demo for Gradio and HuggingFace Spaces."
|
18 |
+
examples = ['c172-test.jpeg']
|
19 |
+
interpretation = 'default'
|
20 |
+
enable_queue = True
|
21 |
+
|
22 |
+
gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3), title=title,
|
23 |
+
description=description, examples=examples, interpretation=interpretation, enable_queue=enable_queue).launch()
|
c172-test.jpeg
ADDED
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
fastai
|
2 |
+
scikit-image
|