File size: 810 Bytes
77f51c4
c52a803
 
77f51c4
 
 
 
 
 
c52a803
77f51c4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from fastai.vision.all import *
import gradio as gr

learn = load_learner("ndpaircraft.pkl")
labels = learn.dls.vocab
def predict(img):
    img = PILImage.create(img)
    pred, pred_idx, probs = learn.predict(img)
    return {labels[i]: float(probs[i]) for i in range(len(labels))}

title = "NDP Aircraft Classifier"
description = "A NDP Aircraft classifier trained on images downloaded from the internet. Created as a demo for Gradio and HuggingFace Spaces."

image = gr.Image(shape=(224, 224))
label = gr.Label()
examples = ["f15.png", "f16.jpg", "chinook.jpg", "apache.jpg"]
interpretation = "default"

intf = gr.Interface(
    fn=predict,
    inputs=image,
    outputs=label,
    title=title,
    description=description,
    examples=examples,
    interpretation=interpretation,
)

intf.launch(share=True)