minimal / app.py
nimapourjafar's picture
made gradio interface
14df844
raw
history blame contribute delete
484 Bytes
from fastai.vision.all import *
import gradio as gr
def is_cat(x): return x[0].isupper()
learn = load_learner("model.pkl")
categories = ("Cat", "Dog")
def classify_image(img):
pred,pred_idx,probs = learn.predict(img)
return dict(zip(categories, map(float, probs)))
image = gr.inputs.Image(shape=(224, 224))
label = gr.outputs.Label()
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, capture_session=True)
if __name__ == "__main__":
intf.launch()