Spaces:
Sleeping
Sleeping
| # import gradio as gr | |
| # def greet(name): | |
| # return "Hello " + name + "!! (welcome to testing)" | |
| # iface = gr.Interface( | |
| # fn = greet, | |
| # inputs = "text", | |
| # outputs = "text" | |
| # ) | |
| # iface.launch(share = True) | |
| from fastai.vision.all import * | |
| import gradio as gr | |
| def is_cat(x): | |
| return x[0].isupper() | |
| #|export | |
| dog_path = 'aku.jpeg' | |
| cat_path = 'munchkin.jpeg' | |
| dunno_path = 'dunno.jpeg' | |
| model_path = 'model.pkl' | |
| learn = load_learner(model_path) | |
| #|export | |
| categories = ('Dog', 'Cat') | |
| def classify_image(image): | |
| predict, index, probabilities = learn.predict(image) | |
| output = dict(zip(categories, map(float, probabilities))) | |
| return output | |
| image = gr.Image() # image = gr.inputs.Image(shape = (192, 192)) | |
| label = gr.Label() # label = gr.Label() | |
| examples = [dog_path, cat_path, dunno_path] # examples = ['aku.jpeg', 'munchkin.jpeg', 'dunno.jpeg'] | |
| interface = gr.Interface( | |
| fn = classify_image, | |
| inputs = image, | |
| outputs = label, | |
| examples = examples | |
| ) | |
| interface.launch(inline = False, share = True) |