Download app.py from AlGouvea/ML_Lesson8_Alvaro_ManualModel: direct link, hf CLI and curl.
- Browser
- Download file 653 Bytes
-
https://huggingface.co/spaces/AlGouvea/ML_Lesson8_Alvaro_ManualModel/resolve/main/app.py
- Command line
-
hf download hf://spaces/AlGouvea/ML_Lesson8_Alvaro_ManualModel/app.py
-
curl -L -o app.py https://huggingface.co/spaces/AlGouvea/ML_Lesson8_Alvaro_ManualModel/resolve/main/app.py
653 Bytes
| from fastai.vision.all import * | |
| import gradio as gr | |
| learn = load_learner('learn.pkl') | |
| categories = ('Polvo', 'Lula') | |
| # Function to classify the image using the selected model | |
| def classify_image(img): | |
| _, _, probs = learn.predict(img) | |
| return dict(zip(categories, map(float, probs))) | |
| # Define input and output components | |
| image = gr.Image() | |
| label = gr.Label() | |
| # Examples for testing | |
| examples = ['Squid.jpg','Octopus.jpg','Lula.jpeg','Polvo.jpg','Graploct.png','Jelly.png'] | |
| # Create Gradio Interface | |
| intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) | |
| # Launch the Gradio interface | |
| intf.launch(inline=False) |