Spaces:
Runtime error
Runtime error
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) |