gowtham58's picture
Update app.py
281d48d verified
raw
history blame contribute delete
574 Bytes
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)