|
from fastai.vision.all import * |
|
import gradio as gr |
|
|
|
learn = load_learner('model.pkl') |
|
|
|
labels = learn.dls.vocab |
|
|
|
def classify_image(img): |
|
pred, pred_idx, probs = learn.predict(img) |
|
return dict(zip(labels, map(float,probs))) |
|
|
|
title = "The Grand Cheese Oracle. π§β¨" |
|
description = "What on Earth is that cheese? π€ Cheese classifier trained on 1200 delicious images of 6 cheeses from DDG " |
|
image = gr.components.Image(shape=(192,192)) |
|
label = gr.components.Label() |
|
examples=["brie.jpg", "mozarella.jpg", "gorgonzola.jpg", "parmigiano.jpg", "feta.jpg" ] |
|
|
|
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, title = title, description = description, examples=examples) |
|
|
|
|
|
intf.launch(inline=False) |
|
|