Spaces:
Build error
Build error
File size: 732 Bytes
30c415e 9382292 38aadeb a91cddc 30c415e 9382292 a91cddc 30c415e 38aadeb a91cddc 30c415e 38aadeb 30c415e 38aadeb 30c415e 38aadeb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import fastai.vision.all as faiv
# import pathlib
from pathlib import Path
import gradio as gr
# make this work on Windows
#temp = pathlib.PosixPath
#pathlib.PosixPath = pathlib.WindowsPath
# load model
learn = faiv.load_learner('aih_model.pkl')
# define categories
categories = ('AI Hand', 'Human Hand')
# set classifier function
def classify_image(img):
pred,idx,probs = learn.predict(img)
return dict(zip(categories, map(float,probs)))
# set interface
image = gr.Image(shape=(512,512))
label = gr.Label()
examples = [str(x) for x in Path('./samples').glob('*')]
intf = gr.Interface(
fn=classify_image,
inputs=image,
outputs=label,
examples=examples,
title='AI Hand Classifier')
intf.launch()
|