|
from fastai.vision.all import * |
|
import gradio as gr |
|
|
|
learn = load_learner('export.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))} |
|
|
|
examples = ['adonis.jpg', |
|
'atlas moth.jpg', |
|
'american snoot.jpg'] |
|
title = "ButterFly Image Classifier🦋" |
|
description = "A ResNet18 feature extractor computer vision model to classify images of butterfly in 100 classes!" |
|
article = "[Chris Olande.](https://github.com/Chrisolande)" |
|
|
|
image = gr.Image() |
|
label = gr.Label(num_top_classes = 3) |
|
gr.Interface(fn=predict, inputs=image, outputs=label, examples = examples, title = title, description = description, article = article).launch(share=True) |
|
|