Spaces:
Runtime error
Runtime error
File size: 635 Bytes
d78bec8 f703f2c 7a644d9 7fe72e0 f703f2c 3a0a958 f703f2c d9f3598 717336b d78bec8 f703f2c 717336b d9f3598 717336b 31eb1e1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
from fastai.vision.all import *
import gradio as gr
learn=load_learner('model.pkl')
is_black,_,probs = learn.predict(PILImage.create('Black people.jpg'))
print(f"This is a: {is_black}.")
print(f"Probability it's a black person: {probs[0]:.4f}")
#is_black(x) : return x[0].isupper()
categories=('Black people','White people')
def func_classi(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=('Black people','White people')
demo = gr.Interface(fn=func_classi, inputs="image", outputs="label")
demo.launch(inline=False)
|