Animals species detection using Deep learning(African wildlife)

HamoyeHQ
6 min readSep 15, 2023

--

HAMOYE WINTER ’23 CAPSTONE PROJECT, TEAM LIGHT GBM(Github)

INTRODUCTION

In recent years, AI-driven systems for tracking animal populations have displayed significant potential. The availability of vast datasets and advancements in deep learning algorithms has enabled researchers to develop models capable of real-time detection and tracking of animal behavior.

AI has the potential to revolutionize wildlife population monitoring, facilitating the identification of behavioral changes that may signal health issues or threats like poaching. This enables swift responses from wildlife conservationists, who can implement targeted interventions to enhance the well-being of animals.

PROBLEM STATEMENT

The task of detecting and classifying animal species in images presents a formidable challenge with diverse applications in conservation, ecology, and wildlife management. Traditional methods of species identification often demand extensive manual labor and face limitations stemming from the intricacies of animal environments and appearances.

Deep learning algorithms offer promise in overcoming these challenges by autonomously learning features and patterns from extensive datasets. Nevertheless, significant hurdles remain in creating precise and efficient deep learning models for animal species detection that can adapt to various environments and species. Therefore, the central problem revolves around developing deep learning algorithms capable of accurately and efficiently recognizing and categorizing animal species in images, spanning a wide range of environments and species.

THE AIMS AND OBJECTIVES

This project aims to harness the latest advancements in Deep Learning and Machine Learning to construct a model capable of predicting animal species in real-world situations. The project’s specific objectives are outlined as follows:

1. Develop a predictive model to analyze, detect, and forecast patterns in African wildlife.

2. Investigate the model’s utility in accurately identifying wildlife within authentic real-life scenarios.

SIGNIFICANCE OF PROJECT / EXPECTED OUTCOME

This project will be useful for wildlife conservationists, as an assisting tool to rapidly extract patterns that lead to certain decisions relating to the identification and detection of African wildlife species.

DATASET

The dataset used for this project was sourced from Kaggle (Dataset).

The dataset comprises four South African nature reserve animal classes: buffalo, elephant, rhino, and zebra. These classes were labeled for object detection using Google’s image search, with each example consisting of a jpg image and a txt label file. The images vary in aspect ratios and include at least one representation of each animal class.

METHODOLOGY

This project employed a quantitative approach for data analysis during the data processing and evaluation stages. Here’s how the data (images) were managed:

1. Data Collection and Extraction: Secondary data was sourced from Kaggle, provided in zip file format. Custom code was implemented to extract images from this zip file.

2. Data Cleaning: The dataset description indicated that the images were in jpg format. To ensure data consistency, the data extraction process included code lines to filter out non-jpg images, ensuring that only jpg images were used in this project.

3. Data Validation: Sequential Deep learning models were trained and assessed on distinct train, validation, and test sets.

4. Model Improvement: An evident discrepancy between training and validation accuracy hinted at potential overfitting. To mitigate overfitting and enhance model performance, data augmentation techniques were applied.

EXPLORATORY DATA ANALYSIS (EDA)

The Exploratory Data Analysis done on the dataset showed that the dataset contained 1501 images in total.

Where:
Number of Buffalos: 375

Number of Elephants: 375

Number of Rhinos: 375

Number of Zebras: 376

The image above is the visualization of random wildlife images present in the dataset.

MODEL DEVELOPMENT AND IMPROVEMENT

The data set was split into train, validation and test with ratios of 0.8, 0.1 and 0.1 respectively.

A sequential model was trained and it was observed that there was overfitting due to the noticeable difference between the training and validation accuracy.

To improve the performance of the model, the model hyper-parameters were tuned. The visualization of the result can be seen below.

Lastly, the Data Augmentation process:

Data augmentation is a method that expands and diversifies a dataset by generating new synthetic data from existing data. This technique is commonly employed in machine learning and deep learning to enhance model performance and resilience. The core concept of data augmentation involves applying various transformations to the original data, including flipping, rotating, scaling, cropping, and introducing noise, to produce fresh samples that are similar yet not identical to the originals. This strategy aids in enabling the model to acquire more generalized and invariant features from the data while mitigating the risk of overfitting. For instance, in image classification, data augmentation is utilized to create new images by randomly altering attributes like cropping, flipping, rotation, brightness, and contrast from the original images.

After the Augmentation process, the model was trained again to achieve a better performance.

Despite the various tuning techniques, the CNN model has poor performance. The accuracy on the test set for the various CNN models ranges between 60 and 70.

Transfer learning incorporated with the CNN Model

To incorporate transfer learning in a CNN model, you can use pre-trained models like VGG16, VGG19, ResNet50, InceptionV3, etc., which have been trained on large datasets such as ImageNet. These models are able to recognize various patterns and features in images and can be fine-tuned to recognize patterns in your specific dataset.

1. VGG16 model

To implement a VGG16, we first load the pre-trained VGG16 model and freeze all its layers. Then we add new layers on top of the base model, which we can train on our specific dataset. Finally, we compile and train the model on our dataset and got a better accuracy of approximately 9.0 as seen below:

2. InceptionV3 model
We implemented the Inception V3 model by loading the pre-trained model and removing the top layer (the classification layer) by setting include_top=False. We then add a global spatial average pooling layer to the output of the base model, followed by a fully-connected layer with 512 units and ReLU activation. Finally, we add a logistic layer with 4 units and softmax activation to classify the 4 classes in our dataset.

We freeze all layers in the base model by setting their trainable attribute to False, so that only the weights of the fully-connected and logistic layers are updated during training.

The result is a high performing model with an accuracy of about 0.96. A great improvement from the other models as shown below:

MODEL EVALUATION:

Among the various models, InceptionV3 exhibits the highest performance in animal species detection. It achieves an impressive accuracy of 97.35% on the training set and 98.96% on the validation set, indicating that the model avoids overfitting. With a test accuracy of 96.67%, the model demonstrates robust generalization to new data, accurately classifying 96.67% of test images.

CONCLUSION:

This project focused on developing a deep learning model, specifically InceptionV3, to accurately recognize endangered species, including buffalo, rhino, elephant, and zebra. Extensive training with large datasets allowed the model to learn distinct patterns associated with each species.

The project’s primary goal is to monitor these animals in their natural habitats, safeguarding them from extinction and curbing human-driven poaching. Deep learning expedites data processing with precision, automating tasks and affording more time to devise effective conservation strategies.

Accurate identification and monitoring of African wildlife populations yield vital data for comprehending behavior, habitats, and migration patterns. This information informs robust conservation strategies and policy decisions. In summary, deep learning models for African wildlife species detection serve as indispensable tools for preserving and protecting these animals for future generations.

--

--

HamoyeHQ

Our mission is to develop an army of creative problem solvers using an innovative approach to internships.