Spaces:
Sleeping
Sleeping
from fastai.vision.all import * | |
import gradio as gr | |
import pathlib, os | |
categories = ['daisy', 'dandelion', 'rose', 'sunflower', 'tulip'] | |
def classify_image(img): | |
learn = load_learner('flowers.pkl') | |
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 = [ | |
'dandelion+seeds.jpg', | |
'common-dandelion-seeds-medical-herb-taraxacum-officinale.jpg', | |
'dandelion-seedhead.jpg', | |
'how-to-draw-sunflower.jpg', | |
'sunflower.jpg', | |
'sunflower1.jpg', | |
'tulip-drawing.jpg', | |
'broken-tulip-flower.jpg', | |
'rose01.jpg', | |
'rose02-blue.jpg' | |
] | |
iface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) | |
iface.launch() |