Rimi98/InsectRecognizer
0
1import gradio as gr2from fastai.vision.all import load_learner3from fastai import *4import torch5import os6from PIL import Image7 8 9model_path = 'model6-90%.pkl'10 11model = load_learner(model_path)12 13def result(path): 14 15 pred,_,probability = model.predict(path)16 pred = str(pred)17 pred = pred.upper()18 19 return {pred: float(probability.max())}20 21path = 'test_images/'22 23image_path = []24 25for i in os.listdir(path):26 image_path.append(path+i) 27 28 29image = gr.inputs.Image(shape =(128,128))30label = gr.outputs.Label()31 32iface = gr.Interface(fn=result, inputs=image, outputs=label, examples = image_path)33iface.launch(inline=False)