Download app.py from PavanKumarD/Fish_Image_Classification: direct link, hf CLI and curl.
- Browser
- Download file 1.08 kB
-
https://huggingface.co/spaces/PavanKumarD/Fish_Image_Classification/resolve/37a21b247c1617e5b8b51e08fbb4134e903ade4d/app.py
- Command line
-
hf download hf://spaces/PavanKumarD/Fish_Image_Classification@37a21b247c1617e5b8b51e08fbb4134e903ade4d/app.py
-
curl -L -o app.py https://huggingface.co/spaces/PavanKumarD/Fish_Image_Classification/resolve/37a21b247c1617e5b8b51e08fbb4134e903ade4d/app.py
1.08 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 for prediction | |
| 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.Image(type="pil"), # Image input (gr.Image in Gradio v3.x) | |
| outputs=gr.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 inside the Streamlit app | |
| gradio_interface().launch(inline=True) | |