my_first_space / app.py
root
updaedd app script with missing code
f0a9686
raw
history blame contribute delete
689 Bytes
"""import gradio as gr
def greet(name):
return "Hello " + name + "!!"
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
iface.launch()"""
#|export
from fastai.vision.all import *
import gradio as gr
#|export
learn = load_learner("export.pkl")
#|export
def classify_image(img):
predict, idx, probs = learn.predict(img)
categories = learn.dls.vocab
return dict(zip(categories,map(float,probs)))
#|export
image = gr.inputs.Image(shape=(192,192))
label = gr.outputs.Label()
examples = ["sunflower.jpg","Peonies.jpeg","Hellebore.jpg","Rose.jpg"]
intf = gr.Interface(fn=classify_image, inputs=image,outputs=label,examples=examples)
intf.launch(inline=False)