RomainFLaine's picture
Upload app.py
a83c92b
raw
history blame contribute delete
No virus
719 Bytes
from fastai.vision.all import *
import gradio as gr
# def greet(name):
# return "Hello " + name + "!!"
# iface = gr.Interface(fn=greet, inputs="text", outputs="text")
# iface.launch()
def is_cat(x): return x[0].isupper()
# learn = load_learner('model.pkl')
learn = load_learner('cool_hot_model.pkl')
categories = ('Cool dog', 'Hot dog')
def classify_image(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 = ['cool_dog1.jpeg', 'cool_dog2.jpeg', 'hot_dog2.jpeg']
intface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
intface.launch(inline=False)