Download app.py from PavanKumarD/Fish_Image_Classification: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/spaces/PavanKumarD/Fish_Image_Classification/resolve/029c8d5ddc7b8b5b0fd9723904250d07805446de/app.py
- Command line
-
hf download hf://spaces/PavanKumarD/Fish_Image_Classification@029c8d5ddc7b8b5b0fd9723904250d07805446de/app.py
-
curl -L -o app.py https://huggingface.co/spaces/PavanKumarD/Fish_Image_Classification/resolve/029c8d5ddc7b8b5b0fd9723904250d07805446de/app.py
1.03 kB
| import streamlit as st | |
| import gradio as gr | |
| from inference import predict_image # Importing the predict_image function from inference.py | |
| # Streamlit UI | |
| st.title("Fish Image Classification with AI") | |
| st.markdown(""" | |
| This app allows you to upload a fish image, and it will classify the fish into one of the categories using two different AI models: | |
| - **ResNet18** | |
| - **MobileNetV2** | |
| Upload an image below to get predictions. | |
| """) | |
| # Gradio Interface | |
| def gradio_interface(): | |
| # This will load the models and use Gradio's interface to interact | |
| gradio_interface = gr.Interface( | |
| fn=predict_image, # Function that performs inference | |
| inputs=gr.inputs.Image(type="pil"), # Image input | |
| outputs=gr.outputs.JSON(), # Output format (JSON with predictions) | |
| live=True, | |
| title="Fish Image Classification", | |
| description="Classify fish images using AI models (ResNet18, MobileNetV2).", | |
| ) | |
| return gradio_interface | |
| # Add the Gradio Interface | |
| gradio_interface().launch(inline=True) | |