|
from fastai.vision.all import * |
|
import gradio as gr |
|
from pathlib import Path |
|
import pathlib |
|
|
|
plt = platform.system() |
|
if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath |
|
|
|
categories = ('Man', 'Woman') |
|
learner = load_learner('export.pkl') |
|
|
|
|
|
def classify_img(img): |
|
pred, idx, probs = learner.predict(img) |
|
return dict(zip(categories, map(float, probs))) |
|
|
|
inputs = gr.Image(height=224, width=224) |
|
outputs = gr.Label() |
|
|
|
examples = ['0.jpg', '71.jpg', '47.jpg', '19.jpg'] |
|
|
|
intf = gr.Interface(fn= classify_img, inputs=inputs, outputs=outputs, examples=examples) |
|
intf.launch(inline=False) |