Spaces:
Runtime error
Runtime error
File size: 990 Bytes
8f62061 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import gradio as gr
from fastai import *
from fastai.vision.all import *
import pathlib
plt = platform.system()
if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath
learn_inf = load_learner("export.pkl")
new_label = {'asian male': 'θε
¬', 'glasses asian female': 'θε©'}
def predict_person(img):
pred, pred_idx, probs = learn_inf.predict(img)
return f'Prediction: {new_label[pred]}; Probability: {probs[pred_idx]:.04f}'
gr.inputs.Image(tool=False, optional=False)
webpage = gr.Interface(fn=predict_person, inputs=gr.inputs.Image(tool=False, optional=False), outputs="text", title="Special Detector", live=True, theme="dark-peach", description="It is a special detector...")
# webpage = gr.Interface(fn=predict_person, inputs=gr.inputs.Image(tool=False, optional=False), outputs="text", title="Special Detector", live=True, theme="dark-peach", description="It is a special detector...", examples=[["example1.jpg"], ["example2.jpg"], ["example3.jpg"]])
webpage.launch() |