peazy's picture
Upload folder using huggingface_hub
c83dede
from fastai.vision.all import *
import gradio as gr
learn = load_learner('model.pkl')
categories = ('Meth Damon', 'Matt Damon')
def classify_image(img):
pred, idx, probs = learn.predict(img)
return dict(zip(categories, map(float, probs)))
image = gr.inputs.Image(shape=(192, 192))
label = gr.outputs.Label()
examples = ['matt damon.jpg', 'jesse.jpeg', 'matt damon 2.webp', 'jesse 2.jpeg',
'matt damon 3.webp', 'jesse 3.webp', 'matt damon 4.webp', 'jesse 4.webp']
intf = gr.Interface(fn=classify_image, inputs=image,
outputs=label, examples=examples)
intf.launch(inline=False)