UCMe's picture
Update app.py
a0f7cfc
raw
history blame contribute delete
422 Bytes
from fastcore.all import *
from fastai.vision.all import *
learn = load_learner('model2.pkl')
labels = learn.dls.vocab
def predict(img) :
pred,id,probs = learn.predict(PILImage.create(img))
return {labels[i] : float(probs[i]) for i in range(len(labels)) }
import gradio as gr
from gradio.components import Image , Label
gr.Interface(fn=predict , inputs=Image(), outputs=Label(num_top_classes=2)).launch(share=True)