File size: 643 Bytes
0101d40
1950f82
0101d40
77e4300
 
 
0101d40
1950f82
 
 
 
 
 
 
 
77e4300
1950f82
 
 
 
 
 
0101d40
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gradio as gr
from fastai.vision.all import *

#import pathlib
#temp = pathlib.PosixPath
#pathlib.PosixPath = pathlib.WindowsPath

catergories = ('bunny girl', 'cat neko girl', 'fox kitsune girl', 'wolfgirl')

def load_model_and_predict(img):
    #img = PILImage.create(image_path)
    pred, idx, probs = learn.predict(img)
    #return pred, probs
    return dict(zip(catergories, map(float,probs)))

model_path = "export_resnet18_e12_3.pkl"
learn = load_learner(model_path)

image = gr.inputs.Image(shape=(224, 224))
label = gr.outputs.Label()

iface = gr.Interface(fn=load_model_and_predict, inputs=image, outputs=label)
iface.launch()