import gradio as gr from fastai.vision.all import * import pathlib # gradio==3.50 plt = platform.system() if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath learn = load_learner('YomeRecognition.pkl') labels = learn.dls.vocab # list of model classes def predict(img): img = PILImage.create(img) pred,pred_idx,probs = learn.predict(img) return {labels[i]: float(probs[i]) for i in range(len(labels))} gr.Interface( fn=predict, inputs =gr.Image(), outputs=gr.Label(num_top_classes=5), title="😍 Sugar 🐶 Yome 🦮 Yang Chenchen 💕 Recognition 🐕", description="Classifier trainded on images of Yang Chenchen Yome, Wang Xinyao, and others. ", examples=['jpg/a.jpg', 'jpg/b.jpg', 'jpg/c.jpg', 'jpg/1.jpg', 'jpg/2.jpg', 'jpg/4.jpg', 'jpg/5.JPG', 'jpg/6.JPG', 'jpg/9.JPG'], ).launch() # def greet(name): # return "Hello " + name + "!!" # iface = gr.Interface(fn=predict, # inputs="text", # outputs="text") # iface.launch()