Spaces:
Sleeping
Sleeping
| from fastai.vision.all import * | |
| import gradio as gr | |
| def is_cat(x): return x[0].isupper() | |
| # cell | |
| learn = load_learner('model2.pkl') | |
| # cell | |
| categories = ['Dog', 'Cat'] | |
| def classify_image(img): | |
| pred,idx,probs = learn.predict(img) | |
| return dict(zip(categories, map(float, probs))) | |
| # cell | |
| #image = gr.inputs.image(shape=(192, 192)) | |
| #label = gr.outputs.Label() | |
| #examples = ['dog.jpg', 'cat.jpg', 'dunno.jpg'] | |
| intf = gr.Interface(fn=classify_image, inputs="image", outputs="label") | |
| #intf = gr.Interface(fn=classify_image, inputs="image", outputs="label", examples="examples") | |
| intf.launch(inline=False) | |
| #cell | |
| #import gradio as gr | |
| #gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3)).launch(share=True) | |