import gradio as gr from fastai.vision.all import load_learner from fastai import * import torch import os from PIL import Image model_path = 'model3-86%.pkl' model = load_learner(model_path) def result(path): pred,_,probability = model.predict(path) pred = str(pred) pred = pred.upper() return {pred: float(probability.max())} path = 'test/' image_path = [] for i in os.listdir(path): image_path.append(path+i) image = gr.inputs.Image(shape =(200,200),image_mode='L',invert_colors=False) label = gr.outputs.Label() iface = gr.Interface(fn=result, inputs=image, outputs=label, examples = image_path) iface.launch(inline=False)