Spaces:
Sleeping
Sleeping
from huggingface_hub import from_pretrained_fastai | |
import gradio as gr | |
def is_cat(x): return x[0].isupper() | |
# repo_id = "YOUR_USERNAME/YOUR_LEARNER_NAME" | |
repo_id = "shinmemkuf/lesson2_demo" | |
learn = from_pretrained_fastai(repo_id) | |
categories = ('Dog', 'Cat') | |
def classify_image(img): | |
pred, idx, probs = learn.predict(img) | |
return dict(zip(categories, map(float, probs))) | |
image = gr.Image(height=192, width=192) | |
label = gr.Label() | |
examples = ['dog.jpg', 'cat.jpg'] | |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) | |
intf.launch(inline=False) | |