rubi242's picture
use webcam for input
023fc7f
raw
history blame contribute delete
459 Bytes
from fastai.vision.all import *
import gradio as gr
learn = load_learner('model.pkl')
categories = [cat[:-4] for cat in learn.dls.vocab]
def classify_image(img):
pred, pred_idx, probs = learn.predict(img)
return dict(zip(categories, map(float, probs)))
demo = gr.Interface(
fn=classify_image,
inputs=[gr.Image(shape=(192,192), source='webcam')],
outputs=[gr.Label()],
examples=['male.jpg', 'female.jpg']
)
demo.launch(inline=False)