A Hierarchical Multi-Model CNN System for Animal Identification
Smart Animal Classifier (AnimaAI) is a deep-learning system that identifies animals from images using a hierarchical pipeline of specialized convolutional neural networks (CNNs). Instead of relying on a single classifier to recognize dozens of species and breeds, our model routes an image through multiple networks to produce a more accurate prediction.
The system is capable of:
- 🐶 Classifying 70+ dog breeds
- 🦋 Classifying 70+ butterfly species
- 🐱 Recognizing multiple cat breeds
- 🐦 Identifying various bird families
- 🐾 Classifying 14 general animal categories
This makes it suitable for wildlife research tools, educational apps, and automated image-sorting systems.
Install required packages:
pip install torch torchvision pillow matplotlib gradioStart the Gradio interface:
python myApp.pyThis will:
- Load the router model
- Load all available specialist models
- Launch an interactive web app
- Allow users to upload images for real-time predictions
Image classification is one of the most fundamental tasks in machine learning. Animals are one of the most common real world targets: from wildlife monitoring and ecological research to educational apps and pet-ID tools. However animals are visually diverse and often have many breeds with similar appearances. A single monolithic neural network that tries to classify everything at once can struggle to distinguish each animal due to things like: large label space, imbalance datasets between species, fine-grained distinctions between visually similar classes, etc. Our project, AnimalAI, tackles this by combining a general router CNN with a set of specialized CNNs. Users upload an image and the system: uses a router model to predict a coarse animal category (e.g. Cat, dog, bird, butterfly, etc.) then, it routes the images to specialist models(e.g. Dog breeds, cat breeds, birds vs butterflies, etc.) finally, the network returns a final prediction with probabilities via Streamlit.
-
Cats, Dogs, Elephants, Horses, Lions
https://www.kaggle.com/datasets/antobenedetti/animalshttps://www.kaggle.com/datasets/yapwh1208/cats-breed-dataset?resource=download
- 70 Dog Breeds Image Dataset
https://www.kaggle.com/datasets/gpiosenka/70-dog-breedsimage-data-set
- Butterfly Image Classification Dataset
https://www.kaggle.com/datasets/phucthaiv02/butterfly-image-classification
Training data extracted fromTraining_set.csv
-
Bird Species Dataset
https://www.kaggle.com/datasets/linh123456/birds-dataset -
Additional Bird Dataset
https://www.kaggle.com/datasets/samuelayman/bird-dataset
- Dogs vs Wolves Dataset
https://www.kaggle.com/datasets/harishvutukuri/dogs-vs-wolves
- Chameleon, Crocodile, Alligator, Frog, Snake
https://www.kaggle.com/datasets/vencerlanz09/reptiles-and-amphibians-image-dataset
- Lions and Cheetahs Image Classification Dataset
https://www.kaggle.com/datasets/mikoajfish99/lions-or-cheetahs-image-classification
Training is performed through train_animals.py and additional scripts for specialist models.
The main dataset is organized as:
Animals/
cats/
dogs/
birds/
butterfly/
snake/
elephant/
...
Each folder contains images for a single coarse class.
Specialist datasets exist for:
- Cat breeds
- Dog breeds
- Butterflies
- Birds
- Big cats
- Snake / Chameleon
- Birds vs butterflies (ambiguity resolution)
- Architecture: ResNet-18 (ImageNet pretrained)
- Loss: CrossEntropy
- Optimizer: Adam (lr = 1e-4)
- Batch size: 32
- Epochs: 5–20 depending on dataset size
- Train/Val split: 80/20
All images are:
- Resized to 224×224
- Normalized using ImageNet mean and std
- Randomly flipped horizontally during training
Each trained model is saved as:
{
"model_state_dict": ...,
"class_names": ...,
"label_to_idx": ...
}Models are stored in the Models/ directory.
This project demonstrates how a trained neural network can be integrated into an actual software application.
Using Gradio, we built a functional web-based classifier that:
- Accepts user-uploaded images
- Feeds them through the router → specialist pipeline
- Outputs the predicted category or breed with probabilities
This shows how machine learning systems can move from development into real, accessible tools.
Developed for:
CSCI 4050U – Machine Learning
Ontario Tech University
Team Members:
- Christopher Kiige
- Tony Akinniranye
- Lucas Fenkam
- Jedidiah Dennis