|
|
import gradio as gr |
|
|
from fastai.vision.all import * |
|
|
import skimage |
|
|
|
|
|
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))} |
|
|
|
|
|
title = "Pengenalan Ras Hewan Peliharaan Kucing dan Anjing" |
|
|
description = "Selamat Datang di Aplikasi Pengklasifikasi ras Hewan Peliharaan yang di training pada kumpulan data Oxford Pets dengan Fastai :D" |
|
|
article="<p style='text-align: center'><a href='https://wahyupebrianto.github.io/' target='_blank'>Blog post</a></p>" |
|
|
examples = ['cat.jpg'] |
|
|
|
|
|
image = gr.Image(type="pil") |
|
|
label = gr.Label(num_top_classes=3) |
|
|
|
|
|
gr.Interface(fn=predict,inputs=image, |
|
|
outputs=label,title=title, |
|
|
description=description,article=article,examples=examples).launch() |