Spaces:
Sleeping
Sleeping
Download app.py from adarsh-007/Dog_Classification: direct link, hf CLI and curl.
- Browser
- Download file 732 Bytes
-
https://huggingface.co/spaces/adarsh-007/Dog_Classification/resolve/main/app.py
- Command line
-
hf download hf://spaces/adarsh-007/Dog_Classification/app.py
-
curl -L -o app.py https://huggingface.co/spaces/adarsh-007/Dog_Classification/resolve/main/app.py
732 Bytes
| import gradio as gr | |
| from fastai.vision.all import load_learner, PILImage | |
| # Load your exported fastai model | |
| model_path = "export.pkl" # your exported .pkl | |
| learn = load_learner(model_path) | |
| # Prediction function | |
| def predict(image): | |
| img = PILImage.create(image) # ensure it's a fastai PILImage | |
| pred_class, pred_idx, outputs = learn.predict(img) | |
| return (str(pred_class)) | |
| # Gradio interface | |
| iface = gr.Interface( | |
| fn=predict, | |
| inputs=gr.Image(type="pil"), | |
| outputs=gr.Textbox(label="Prediction"), | |
| title="FastAI Image Classification", | |
| description="Upload an image to get prediction from your exported fastai model." | |
| ) | |
| if __name__ == "__main__": | |
| iface.launch(server_name="0.0.0.0", server_port=7860) | |