who_is_this_app / app.py
mirtti's picture
Update app.py
cd72a80 verified
raw
history blame contribute delete
720 Bytes
import gradio as gr
from fastai.vision.all import *
from huggingface_hub import from_pretrained_fastai
learn = from_pretrained_fastai("mirtti/who_is_this")
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 = "Who is this?"
description = "I've had three cats: Smoky, Lisa and Inger. This model allows you to find similarities between other cats and my own."
examples = ['Lisa', 'Smoky', 'Inger']
gr.Interface(
fn=predict,
inputs=gr.Image(),
outputs=gr.Label(num_top_classes=3),
title=title,
description=description,
examples=examples,
).launch()