A lightweight image classifier that tells you whether your image contains a bird, a forest, or neither!
Built using FastAI, Gradio, and Python, this app is ideal for a quick image check — powered by a fine-tuned computer vision model.
- The model was trained on images of birds and forests scraped using
duckduckgo_search. - I trained a
resnet18model using FastAI and exported only the model weights to amodel.pthfile (instead ofmodel.pkl) for safe deployment on Hugging Face Spaces. - The app uses a confidence threshold to return
"Uncertain"if it's not sure the image is a bird or forest.
Upload an image and see the prediction:
- Bird image →
"bird" - Forest image →
"forest" - Other →
"Uncertain – this might not be a bird or forest 🤔"
- Trained on a small custom dataset of birds and forest images.
- Built with FastAI and exported with learn.export().
- Includes a confidence threshold — if the model isn't at least 85% confident, it returns "Uncertain".
Clone the repo:
git clone https://github.com/Geff115/bird-or-not-classifier.git
cd bird-or-not-classifierCreate a virtual environment (optional but recommended)
python -m venv venv
source venv/bin/activate # or venv\Scripts\activate on WindowsInstall dependencies:
pip install -r requirements.txtLaunch the app locally:
python3 app.pyVisit http://127.0.0.1:7860 and upload an image to classify.
bird-or-not-classifier/
├── app.py # Gradio app
├── model.pkl # Exported FastAI model
├── requirements.txt # Dependencies
└── README.md Image | Prediction
- 🐦 Bird (parrot) | bird
- 🌲 Forest Scene | forest
- 🚗 Random Car Photo | Uncertain – this might not be a bird or forest 🤔
I avoid using
model.pkldue to unsafe pickle serialization in hosted environments like Hugging Face.
Instead, I manually reconstruct the model architecture inapp.pyand loadmodel.pth.
- v2: Train with a third "other" class for better generalization.
- Add image augmentation + more diverse training data.
- Deploy to Hugging Face Spaces.
MIT License — use freely for research, projects, or fun 🕊️