Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from fastai.vision.all import * | |
| import pathlib | |
| import os | |
| from PIL import Image | |
| temp = pathlib.PosixPath | |
| if os.name == 'nt': | |
| pathlib.PosixPath = pathlib.WindowsPath | |
| def is_cat(x): return x[0].isupper() | |
| def greet(name): | |
| return "Hello " + name + "!!" | |
| learner = load_learner('model.pkl') | |
| categories = ('Dog', "Cat") | |
| def classify_image(img): | |
| resized_image = img.resize((192, 192)) # Resize here manually | |
| prediction, index, probs = learner.predict(resized_image) | |
| return dict(zip(categories,map(float,probs))) | |
| image = gr.Image(type="pil") | |
| label = gr.Label() | |
| examples = ['samples/cute_dog.jpg',"samples/cat_graffity.jpg"] | |
| intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) | |
| intf.launch(inline=False) |