Spaces:
Sleeping
Sleeping
File size: 626 Bytes
42eed67 9303550 42eed67 7c4f624 42eed67 59056c1 |
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 |
import gradio as gr
from fastai.vision.all import load_learner
from fastai import *
import torch
import os
from PIL import Image
model_path = 'model6-90%.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_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) |