Spaces:
Runtime error
Runtime error
import gradio as gr | |
import pathlib | |
from pathlib import Path | |
from fastai.text.all import * | |
categories = ('Korean','Vietnamese') | |
def predict_input_image(img): | |
pred,idx,probs = learn_inf.predict(img) | |
return dict(zip(categories,map(float,probs))) | |
path = Path() | |
#import pathlib | |
#if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath | |
#temp = pathlib.PosixPath | |
plt = platform.system() | |
print(f"Platform : {plt}") | |
if plt == 'Windows': | |
pathlib.PosixPath = pathlib.WindowsPath | |
learn_inf = load_learner(path/'korean.pkl') | |
image = gr.inputs.Image(shape=(180,180)) | |
label = gr.outputs.Label(num_top_classes=2) | |
gr.Interface(fn=predict_input_image, inputs=image, outputs=label,interpretation='default').launch(debug='True') |