File size: 574 Bytes
2b069b5
 
 
 
 
5e8b157
76616f1
a585d20
e30b75a
5e8b157
 
 
 
76616f1
281d48d
5e8b157
8f62f6a
5e8b157
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import pathlib
import platform
plt = platform.system()
if plt == 'Linux': 
    pathlib.WindowsPath = pathlib.PosixPath
from fastai.vision.all import *
import gradio as gr
learn = load_learner(Path('export.pkl'))

actors = learn.dls.vocab
def classify_images(img):
    pred, idx, prob = learn.predict(img)
    return dict(zip(actors, map(float, prob)))

image = gr.Image()
label = gr.Label()
examples = ['rajini.jpg', 'vijay.jpg', 'raka.jpeg', 'ajith.jpeg']
intf = gr.Interface(fn = classify_images, inputs = image, outputs=label, examples=examples)
intf.launch(inline=False)