Spaces:
Build error
Build error
| import gradio as gr | |
| from fastai.vision.all import * | |
| from huggingface_hub import from_pretrained_fastai | |
| import pathlib | |
| # loading the model | |
| windows_backup = pathlib.WindowsPath | |
| pathlib.WindowsPath = pathlib.PosixPath | |
| learn = from_pretrained_fastai("pka007/flowerclassifier_model") | |
| pathlib.WindowsPath = windows_backup | |
| labels = ['Jasmine', 'Marigold', 'Rose', 'sunflower', 'tulip'] | |
| def predict(img): | |
| img = PILImage.create(img) | |
| pred,pred_idx,probs = learn.predict(img) | |
| return {labels[i]: float(probs[i]) for i in range(len(labels))} | |
| title = "Flower Classifier" | |
| description = "A flower classifier trained on the images downloaded from the internet." | |
| examples = ['sunflower.jpg','marigold.jpg'] | |
| intf = gr.Interface(fn=predict,inputs=gr.Image(type="pil"),outputs=gr.Label(),title=title,description=description,examples=examples) | |
| intf.launch() | |