File size: 517 Bytes
5e8b157
3bf9a9a
76616f1
3129282
e30b75a
5e8b157
 
 
 
76616f1
5e8b157
 
8f62f6a
5e8b157
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from fastai.vision.all import *
import torch
import gradio as gr
learn = torch.load('export.pkl',  map_location=torch.device('cpu'))

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

image = gr.Image(height=192, width= 192)
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)