art / app.py
sja820's picture
Update app.py
e4c7268 verified
raw
history blame contribute delete
636 Bytes
from fastai.vision.all import *
import gradio as gr
# # get image
# im=PILImage.create("dog.jpg")
# im.thumbnail((255,255))
# im
# export
learn=load_learner('model.pkl')
categories=("Impressionist", "Romanticist", "Realist")
# # learns on image
# learn.predict(im)
# gradi orequires function
def classify_img(img):
pred,idx,probs=learn.predict(img)
return dict(zip(categories, map(float,probs)))
# image=gr.inputs.Image(shape=(192,192))
# label=gr.outputs.Label()
# examples=['i.jpg', 'r.jpg','re.jpg']
intf=gr.Interface(fn=classify_img,inputs=gr.Image(type="pil"),outputs=gr.Label())
intf.launch(inline=False)