Spaces:
Runtime error
Runtime error
Updated app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,29 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
import gradio as gr
|
3 |
|
4 |
+
learn = load_learner("ndpaircraft.pkl")
|
5 |
+
labels = learn.dls.vocab
|
6 |
+
def predict(img):
|
7 |
+
img = PILImage.create(img)
|
8 |
+
pred, pred_idx, probs = learn.predict(img)
|
9 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
10 |
|
11 |
+
title = "NDP Aircraft Classifier"
|
12 |
+
description = "A NDP Aircraft classifier trained on images downloaded from the internet. Created as a demo for Gradio and HuggingFace Spaces."
|
13 |
+
|
14 |
+
image = gr.Image(shape=(224, 224))
|
15 |
+
label = gr.Label()
|
16 |
+
examples = ["f15.png", "f16.jpg", "chinook.jpg", "apache.jpg"]
|
17 |
+
interpretation = "default"
|
18 |
+
|
19 |
+
intf = gr.Interface(
|
20 |
+
fn=predict,
|
21 |
+
inputs=image,
|
22 |
+
outputs=label,
|
23 |
+
title=title,
|
24 |
+
description=description,
|
25 |
+
examples=examples,
|
26 |
+
interpretation=interpretation,
|
27 |
+
)
|
28 |
+
|
29 |
+
intf.launch(share=True)
|