Spaces:
Runtime error
Runtime error
Download app.py from Mapakashi/swagclassifier: direct link, hf CLI and curl.
- Browser
- Download file 748 Bytes
-
https://huggingface.co/spaces/Mapakashi/swagclassifier/resolve/main/app.py
- Command line
-
hf download hf://spaces/Mapakashi/swagclassifier/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Mapakashi/swagclassifier/resolve/main/app.py
748 Bytes
| # app.py | |
| from fastai.vision.all import * | |
| import gradio as gr | |
| # Load the trained model | |
| learn = load_learner('export.pkl') | |
| # Define the classification function that Gradio will use | |
| def classify_image(img): | |
| pred, idx, probs = learn.predict(img) | |
| # Assuming your model's predictions are 'T-shirt' and 'Trousers' | |
| return {pred: max(probs.tolist())} | |
| # Define the Gradio interface | |
| gr_interface = gr.Interface(fn=classify_image, | |
| inputs=gr.inputs.Image(type='pil'), | |
| outputs=gr.outputs.Label(num_top_classes=2), | |
| examples=['path/to/sample_tshirt.jpg', 'path/to/sample_trousers.jpg']) | |
| # Launch the Gradio app | |
| if __name__ == "__main__": | |
| gr_interface.launch() | |