File size: 662 Bytes
16357db 46352e6 d56f307 6c2e9d5 46352e6 d01e3ab 46352e6 16357db 46352e6 16357db 46352e6 3c01f22 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import gradio as gr
from fastai.vision.all import *
from fastbook import *
from fastai.vision.widgets import *
import gradio as gr
from pathlib import Path
import pathlib
plt = platform.system() if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath
learn_inf = load_learner(Path('export.pkl'))
categories = ("maxi", "kairat")
def classify_image(img):
pred,idx,probs = learn_inf.predict(img)
return dict(zip(categories, map(float, probs)))
examples = ["maxi.jpg", "kairat.jpeg"]
intf = gr.Interface(fn=classify_image, inputs=gr.inputs.Image(shape=(192, 192)), outputs=gr.outputs.Label(), examples=examples)
intf.launch(inline=False,share=True)
|