Spaces:
Sleeping
Sleeping
Download app.py from Analyzer/fastai-pet: direct link, hf CLI and curl.
- Browser
- Download file 950 Bytes
-
https://huggingface.co/spaces/Analyzer/fastai-pet/resolve/main/app.py
- Command line
-
hf download hf://spaces/Analyzer/fastai-pet/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Analyzer/fastai-pet/resolve/main/app.py
950 Bytes
| import gradio as gr | |
| from fastai.vision.all import * | |
| def is_cat(x): return x[0].isupper() #this is being internally referenced by the model, DONT REMOVE | |
| learn = load_learner('model.pkl') | |
| categories = ('Dog', 'cat') | |
| def classify_img(img): | |
| pred,idx,probs = learn.predict(img) | |
| return dict(zip(categories, map(float,probs))) | |
| # image = gr.inputs.Image(shape=(192, 192), label="Upload an image of a dog or cat") | |
| # label = gr.outputs.Label() | |
| image = gr.components.Image(height=192, width=192, label="Upload an image of a dog or cat") | |
| label = gr.components.Label() | |
| examples = ['dog.jpg', 'cat.jpg', 'bird.jpg'] | |
| intf = gr.Interface(fn=classify_img, inputs=image, outputs=label, title="Dog or Cat Classifier", description="Upload an image of a dog or cat to get a prediction.",examples=examples) | |
| intf.launch() | |
| # def greet(name): | |
| # return "Hello " + name + "!!" | |
| # demo = gr.Interface(fn=greet, inputs="text", outputs="text") | |
| # demo.launch() | |