Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from fastai.vision.all import * | |
| def is_cat(x): return x[0].isupper() | |
| learn = load_learner('model.pkl') | |
| categories = ['dog', 'cat'] | |
| def predict_image(img): | |
| pred, pred_idx, probs = learn.predict(img) | |
| return dict(zip(categories, map(float, probs))) | |
| with gr.Blocks() as demo: | |
| gr.Markdown("# Cat or Dog Classifier Demo FastAI By Donald and Elvis") | |
| image = gr.Image() | |
| label = gr.Label() | |
| examples = ["cat.jpg", "dog.jpg"] | |
| gr.Interface(fn=predict_image, inputs=image, outputs=label) | |
| demo.launch() |