gender-guesser / app.py
romangurovich's picture
Tiny app to guess gender of faces
1c2baab
raw
history blame contribute delete
490 Bytes
import gradio as gr
from fastai.vision.all import *
def is_man(face): return face[0].isupper()
learn = load_learner('gender-classifier-model.pkl')
categories = 'Man', 'Woman'
def classify_image(img):
pred,idx,probs = learn.predict(img)
return dict(zip(categories, map(float, probs)))
image = gr.Image(shape=(192, 192))
label = gr.Label()
examples = ['man.jpeg', 'woman.jpeg']
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
intf.launch()