Spaces:
Runtime error
Runtime error
File size: 726 Bytes
42eed67 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import gradio as gr
from fastai.vision.all import load_learner
from fastai import *
import torch
import os
from PIL import Image
import pathlib
temp = pathlib.PosixPath
pathlib.PosixPath = pathlib.WindowsPath
model_path = 'C:\pythons\Deep Learning\insect\insects-recognizer\models\model3-86_.pkl'
model = load_learner(model_path)
def result(path):
pred,_,probability = model.predict(path)
return {pred: float(probability.max())}
path = 'test_images/'
image_path = []
for i in os.listdir(path):
image_path.append(path+i)
image = gr.inputs.Image(shape =(128,128))
label = gr.outputs.Label()
iface = gr.Interface(fn=result, inputs=image, outputs=label, examples = image_path)
iface.launch(inline = False) |