Spaces:
Runtime error
Runtime error
from fastai.vision.all import * | |
import gradio as gr | |
#is_black(x) : return x[0].isupper() | |
def input_img(img): | |
learn=load_learner('model.pkl') | |
race,_,probs = learn.predict(img) | |
#print(f"This is a: {race}.") | |
processed_output=(f"This is a: {race}./nProbability it's a black person: {probs[0]:.4f}.\nProbability it's a white person: {probs[1]:.4f}") | |
return processed_output | |
# 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 = gr.Interface(fn=input_img, inputs="image", outputs="label") | |
demo.launch(inline=False) | |
#image=gr.inputs.Image(shape=(192,192)) | |
#label=gr.outputs.Label() | |
#examples=('Black people','White people') | |
#demo = gr.Interface(fn=func_classi, inputs=[gr.func_classi()], outputs=[gr.Textbook(label="Results")]) | |
#demo.launch(inline=False) | |