|
|
|
|
|
|
|
from fastai.vision.all import * |
|
from fastbook import load_learner |
|
import gradio as gr |
|
|
|
inf = load_learner('LeopardCheetah (1).pkl') |
|
|
|
categories = ('Cat', 'Cheetah', 'Other', 'Leopard', 'Lion', 'Snow Leopard', 'Tiger') |
|
|
|
def classify_img(img): |
|
pred, idx, probs = inf.predict(img) |
|
return dict(zip(categories,map(float,probs))) |
|
|
|
|
|
|
|
|
|
|
|
image = gr.Image(shape=(192,192)) |
|
label = gr.outputs.Label() |
|
|
|
examples = ['cheetah.jpg','leopard.jpg','img.jpg'] |
|
|
|
intf = gr.Interface(fn = classify_img, inputs=image,outputs=label,examples = examples) |
|
|
|
intf.launch() |
|
|