Spaces:
Runtime error
Runtime error
| from fastai.vision.all import * | |
| import gradio as gr | |
| import pathlib, os | |
| categories = ['daisy', 'dandelion', 'rose', 'sunflower', 'tulip'] | |
| def classify_image(img): | |
| if os.name == 'posix': # workaround for Linux | |
| pathlib.WindowsPath = pathlib.PosixPath | |
| 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', | |
| 'dandelion.jpg', | |
| 'how-to-draw-sunflower.jpg', | |
| 'sunflower.jpg', | |
| 'sunflower1.jpg', | |
| 'tulip-drawing.jpg', | |
| 'broken-tulip-flower.jpg', | |
| 'rose01.jpg', | |
| 'rose02-blue.jpg', | |
| 'top-25-most-beautiful-daisy-flowers.jpg', | |
| 'daisy-varieties.jpg' | |
| ] | |
| iface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) | |
| iface.launch() |