File size: 654 Bytes
64baacf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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  = '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)