File size: 556 Bytes
1474326 080dc65 2f12f05 080dc65 1474326 6071fc8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
from fastai.vision.all import *
import gradio as gr
classifier=load_learner("model.pkl")
labels = classifier.dls.vocab
def classify_image(img):
img = PILImage.create(img)
pred,pred_ix,pred_prob = classifier.predict(img)
return dict(zip(labels,map(float,pred_prob)))
images = gr.inputs.Image(shape=(192,192))
label = gr.outputs.Label(num_top_classes=4)
examples = ['airplane.jpg','helicopter.jpg','missile.jpg','rocketship.jpg']
intr = gr.Interface(fn = classify_image,inputs=images,outputs=label,examples=examples)
intr.launch(inline=False) |