Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from fastai.vision.all import * | |
| import os | |
| def is_cat(x): | |
| if x[0].isupper(): | |
| return 'cat' | |
| else: | |
| return 'dog' | |
| learn_inference = load_learner('is_Cat_resnet.pkl') | |
| def image_mod(image): | |
| detect, _, predict = learn_inference.predict(image) | |
| return detect | |
| image = gr.inputs.Image(shape=(192,192)) | |
| label = gr.outputs.Label() | |
| examples=[ | |
| "images/db.jpg", | |
| "images/dog2.jpg", | |
| "images/cat3.jpg", | |
| "images/dog4.jpg", | |
| "images/pug1.jpg", | |
| "images/cat2.jpg", | |
| ] | |
| # examples=[ | |
| # os.path.join(os.path.dirname(__file__), "images/db.jpg"), | |
| # os.path.join(os.path.dirname(__file__), "images/dog1.jpg"), | |
| # os.path.join(os.path.dirname(__file__), "images/dog2.jpg"), | |
| # os.path.join(os.path.dirname(__file__), "images/dog3.jpg"), | |
| # os.path.join(os.path.dirname(__file__), "images/dog4.jpg"), | |
| # os.path.join(os.path.dirname(__file__), "images/pug1.jpg"), | |
| # ] | |
| demo = gr.Interface( | |
| image_mod, | |
| inputs = image, | |
| outputs = label, | |
| examples = examples | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() | |