Wild Animal Detection System

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

BioGecko Vol 12 Issue 03 2023

ISSN NO: 2230-5807

Wild Animal Detection and Warning System Using Machine Learning and
Deep Learning Algorithms
Dr V Sindhu1, Afsar Alam2, Punam Thapa3
1
Assistant Professor School of Computer Applications Lovely Professional University
2
Master of Computer Applications, School of Computer Applications Lovely Professional University
3
Master of Computer Applications School of Computer Applications Lovely Professional University

Abstract
Animal detection and classification are crucial for the monitoring and preservation of wildlife. This
project aims to develop a deep learning algorithm using Convolutional Neural Networks (CNN) to
detect and categorize animals as either dangerous or non-dangerous in their natural habitat. As there
are numerous animal species, manual identification can be a challenging task. The algorithm utilizes
image classification to identify animals, which allows for efficient monitoring and prompt
communication of safety concerns to the jungle supervisor. Animal detection and classification can
help to safeguard people from animal-related hazards, prevent animal-vehicle accidents, track
animals, and deter wildlife theft. Additionally, tourists can ensure their safety by avoiding dangerous
animals or maintaining a safe distance while trucking in the forest. The successful implementation of
deep learning techniques can lead to achieving this goal.

Keywords: CNN, machine learning, deep learning algorithms.

1. INTRODUCTION
Biodiversity is a vital feature of our planet, but the world's biodiversity is facing a high risk of decline
due to various factors. Many organizations are working to improve the situation using new
technologies such as machine learning (ML) and deep learning (DL). ML and DL have the potential
to help in the identification and preservation of endangered species.

Machine learning refers to a branch of artificial intelligence that allows computer systems to enhance
their performance through experience, without the need for explicit programming [1]. The goal is to
allow computers to train themselves without human intervention and make better decisions in the
future. Deep neural networks, including convolutional neural networks (CNNs), have been
particularly successful in visual image analysis [2]. CNNs require relatively minimal preprocessing
and can learn from data without prior knowledge or human intervention in feature design. CNN is
used in various fields and its results are promising in accuracy.

Problem Statement
Monitoring wild animals in their natural habitats is critical for maintaining ecosystem health.
However, increasing human populations and economic development have led to the excessive
exploitation of natural resources and significant changes in the Earth's ecosystems. Human activities
have also altered natural wildlife populations, habitats, and behaviors [3]. Many species have become
endangered or extinct, and others have been displaced to new areas, causing disruptions to both
natural and human resources.

Convolutional Neural Network


Convolutional Neural Networks (CNNs) have shown remarkable effectiveness in image recognition
and classification tasks [4]. They have been used to identify various objects, animals, faces, traffic
signs, and even power vision in robots and self-driving cars. CNNs have proven to be powerful tools

167
A Journal for New Zealand Herpetology
BioGecko Vol 12 Issue 03 2023

ISSN NO: 2230-5807

for image recognition and classification tasks due to their ability to capture complex patterns and
features in images.

A convolutional neural network (CNN) is a specific type of deep learning neural network that is
intended for processing and analyzing data that has a grid-like structure, such as images or time series
data. CNN leverages convolutional layers to discover patterns and features in the data [5]. The
convolutional layer is the backbone of the CNN, as it extracts these features from the input image.
Multiple convolutional layers are stacked on top of one another in the CNN, with each layer capable
of recognizing increasingly complex structures. This architecture enables CNN to excel at the image
and pattern recognition tasks.

ReLU and SoftMax are important components of a CNN that help introduce non-linearity into the
network and make accurate predictions on image classification tasks Rectified Linear Unit (ReLU) is
an activation function utilized in neural networks, which sets any negative values to zero and passes
positive values through unchanged. It is frequently used to introduce non-linearity in the neural
network [6]. SoftMax is an activation function that converts a vector of real numbers into a
probability distribution over the classes in a multiclass classification problem, commonly used in the
output layer of neural networks.

The CNN is structured with three primary layers, which are the input layer, the convolutional layer,
the pooling layer, and the fully connected layer.

A. Convolutional Layer
The convolutional layer is a fundamental component of deep learning models used in various fields,
including computer vision tasks such as animal tracking. This layer extracts features from input
images by convolving them with filters that detect patterns such as edges, corners, and textures [7].
These features are used to train models that can track the animal in subsequent frames based on its
past behavior. The convolutional layer preserves the association between pixels by analyzing small
squares of input data, allowing for operations like edge detection, blur, and sharpening of images. The
convolutional layer generates a feature map that identifies significant areas within the input image,
which can be utilized for precise animal tracking.

B. Pooling
The pooling layer is a key component in convolutional neural networks that can effectively reduce the
spatial dimensions of the input while retaining its significant features. Among various types of
pooling layers, max pooling is widely used to shrink the input size by selecting the highest value
within a local neighborhood [8]. The primary purpose of max pooling is to downsample the input
image and decrease its dimensions, which can be beneficial for preventing overfitting and increasing
the network's efficiency. In addition to reducing parameters, the pooling layer can accelerate the
training process and enhance the network's overall performance.

C. Flattening
The flattening layer is responsible for transforming multi-dimensional arrays into a single linear
vector. [9] It achieves this by breaking down the spatial structure of the data and converting the multi-
dimensional tensor into a one-dimensional tensor, or vector [10]. By extracting and highlighting
relevant features in the input data, the complexity of the data is reduced, allowing the neural network
to analyze and process the data more effectively.

D. Fully connected layers


Fully connected layers, also known as dense layers, are a crucial component of Convolutional Neural
Networks (CNNs). These layers are responsible for combining the learned features from earlier layers

168
A Journal for New Zealand Herpetology
BioGecko Vol 12 Issue 03 2023

ISSN NO: 2230-5807

and creating a set of attributes that are then used to predict the output.[11] In a CNN, fully connected
layers are typically added after the convolutional and pooling layers to create a more abstract
representation of the input that can predict the outputs more accurately [12].They are a necessary
component of CNNs and are responsible for much of their success in image recognition and other
tasks.

2. PROPOSED RESEARCH METHODOLOGY

Stage:1 Data Collection - The first step for animal detection and classification is to collect an
appropriate dataset. The dataset that contains images of animals that are to be identified and classified
is collected from online resources like flicker.com and Kaggle.com. The dataset contains 14648
images of different types of animals and variations in lighting, background, and angle.

Stage:2 Pre-processing: Before we use the dataset for training our deep learning algorithm, we need
to pre-process the images. This pre-processing step includes resizing the images to a common size,
converting the images to grayscale or RGB, normalizing the pixel values to a common range, and
augmenting the dataset by applying transformations such as rotation, cropping, and flipping [13].
We use the image dataset_from_directory () function from TensorFlow's Keras API to load the
images from the directories into the training and validation datasets. The images are resized to a
resolution of 128 x 128 pixels and normalized by subtracting the mean and dividing by the standard
deviation. Additionally, the class names are extracted from the image labels and then associated with
their corresponding categories of "Dangerous" or "Non-Dangerous".

Stage:3 Deep Learning Algorithm: For animal detection and classification, we use a deep learning
algorithm Convolutional Neural Networks (CNNs). We use a convolutional neural network (CNN)
model with several layers of convolutional and pooling operations, followed by fully connected layers
with dropout regularization, and a softmax output layer. The CNN model uses the Keras Sequential
API and includes the following layers:

A. Normalization layer: The input image is normalized by subtracting its mean and dividing it by its
standard deviation.

B. Conv2D layers: The convolution operation is carried out using a specified number of filters (8, 16,
32, 64, 128) and a kernel size of 3x3, with the padding set to 'same'. This implies that zeros are
padded to the input image to produce an output feature map that has the same spatial dimensions as
the input.[14] The resulting output is then subject to the ReLU activation function.

C. MaxPool2D layers: Apply max pooling operation with a pool size of (2,2) to reduce the spatial
dimensions of the output feature map.

D. Dropout layers: Apply dropout regularization to prevent overfitting.

E. Flatten layer: The output from the convolutional layers is transformed into a 1D vector by
flattening it.
F. Dense layers: Apply fully connected layers with a specified number of units and activation
functions. The last dense layer has the same number of units as the number of classes in the dataset.

G. Softmax layer: Apply a softmax activation function to the output of the last dense layer to obtain
the probability distribution over the classes.

169
A Journal for New Zealand Herpetology
BioGecko Vol 12 Issue 03 2023

ISSN NO: 2230-5807

Figure:1: Proposed Methodology

Training and Validation


To train the deep learning algorithm, the dataset must be divided into two parts: the training set and
the validation set. The training set is utilized to teach the algorithm to recognize patterns within the
images, while the validation set is used to assess the algorithm's performance during the training
process. The training dataset is utilized to train the model with the Adam optimizer and categorical
cross-entropy loss function, with a batch size of 412 and 10 epochs. The model's performance is
evaluated after each epoch utilizing the validation dataset. The best model is determined based on the
highest validation accuracy and is saved [15].

170
A Journal for New Zealand Herpetology
BioGecko Vol 12 Issue 03 2023

ISSN NO: 2230-5807

TRAIN DATASET

Figure:2 Animal Dataset

TEST DATASET

Figure:3 Animal Dataset

5. Evaluation Metrics: For the performance of our algorithm, we use evaluation metrics such as
precision, recall, F1 score, and Confusion matrix.

A. Accuracy: The proportion of correctly classified images in the test dataset.

(𝑇𝑃 + 𝑇𝑁)
𝐴𝑐𝑐𝑢𝑟𝑎𝑐𝑦 = 𝐸𝑞 1
(𝑇𝑃 + 𝐹𝑃 + 𝑇𝑁 + 𝐹𝑁)

B. Precision: The proportion of true positives (correctly classified dangerous animals) out of all the
animals classified as dangerous by the model.

𝑇𝑟𝑢𝑒 𝑃𝑜𝑠𝑖𝑡𝑖𝑣𝑒
𝑃𝑟𝑒𝑐𝑖𝑠𝑖𝑜𝑛 = 𝐸𝑞 2
𝑇𝑟𝑢𝑒 𝑃𝑜𝑠𝑖𝑡𝑖𝑣𝑒 + 𝐹𝑎𝑠𝑙𝑒 𝑃𝑜𝑠𝑖𝑡𝑖𝑣𝑒

C. Recall: The proportion of true positives out of all the actual dangerous animals in the dataset.

171
A Journal for New Zealand Herpetology
BioGecko Vol 12 Issue 03 2023

ISSN NO: 2230-5807

𝑇𝑟𝑢𝑒 𝑃𝑜𝑠𝑖𝑡𝑖𝑣𝑒
𝑅𝑒𝑐𝑎𝑙𝑙 = 𝐸𝑞 3
𝑇𝑟𝑢𝑒 𝑃𝑜𝑠𝑖𝑡𝑖𝑣𝑒 + 𝐹𝑎𝑙𝑠𝑒 𝑁𝑒𝑔𝑎𝑡𝑖𝑣𝑒

D. F1-score: It is a measure of a binary classification model's accuracy, calculated based on precision


and recall, with values ranging from 0 to 1.

𝑃𝑟𝑒𝑐𝑖𝑠𝑖𝑜𝑛 ∗ 𝑅𝑒𝑐𝑎𝑙𝑙
𝐹1 = 2 ∗ 𝐸𝑞 4
𝑃𝑟𝑒𝑐𝑖𝑠𝑖𝑜𝑛 + 𝑅𝑒𝑐𝑎𝑙𝑙
.
E. Confusion matrix: A confusion matrix is a 2x2 table used in binary classification that shows the
number of true positives, false positives, true negatives, and false negatives, which are used to
calculate precision, recall, and F1-score.

3. RESULTS AND DISCUSSION

This research is to promote responsible behavior around animals during wildlife tourism by providing
accurate and reliable information on detecting dangerous and non-danger animals and safe distance
guidelines. The successful implementation of a convolutional neural network (CNN) model to classify
images of dangerous and non-dangerous animals.

WILD AND DANGEROUS

NON-DANGEROUS

WILD-DANGEROUS

NON-DANGEROUS

172
A Journal for New Zealand Herpetology
BioGecko Vol 12 Issue 03 2023

ISSN NO: 2230-5807

Figure: 4 Classified Animal Category

The model achieved an accuracy of 98.26% on the training set, with a corresponding loss of 0.0592.
On the validation set, the model achieved an accuracy of 95.63% with a loss of 0.1471. Finally, on the
test set, the model achieved an accuracy of 93.28% with a loss of 0.4445. These results demonstrate
the effectiveness of the model in accurately predicting the target variable.

Based on the confusion matrix provided, the model achieved an accuracy of 93.28% on the test
dataset, indicating that it can effectively distinguish between the two categories.When the scores for
each category are examined, it can be observed that most categories were performed very well by the
model, with high precision, recall, and F1 scores.

precision recall f1-score Support


0.97 0.97 0.97 500
0.98 0.98 0.98 65
0.95 0.97 0.96 500
0.95 0.80 0.87 49
0.75 0.97 0.85 49
0.75 0.97 0.85 78
0.90 0.91 0.91 126
0.97 0.95 0.96 103
Table:1 Classification Results

The classification results showed that the model was effective in distinguishing between dangerous
and non-dangerous animals. The implications of this research suggest that this type of model can be
used for wildlife conservation efforts by helping to identify and track endangered species, as well as
identifying potential threats to human safety in areas where dangerous animals are present.

4. CONCLUSION
In this research, the effectiveness of using a convolutional neural network (CNN) for animal
classification in the context of wildlife conservation and management was successfully demonstrated.
173
A Journal for New Zealand Herpetology
BioGecko Vol 12 Issue 03 2023

ISSN NO: 2230-5807

An accuracy of around 93% on the test set was achieved by the model, indicating potential application
in real-world scenarios, such as the identification and tracking of dangerous animals in the wild and
the reduction of human-wildlife conflicts. The robustness of the model was ensured through the pre-
processing of data and split into training, validation, and test sets. Additionally, a sequential neural
network with multiple convolutional layers, pooling layers, and dropout layers was utilized to prevent
over fitting, further enhancing the accuracy of the model. The results of this study also highlight the
power of deep learning algorithms in image recognition tasks and their potential for application in
various fields beyond wildlife conservation. Overall, this research provides valuable insights into the
potential of CNNs for image classification and their applications in real-world scenarios.

5. REFERENCES
1. Animal Detection Using Deep Learning Algorithm N. Banupriya1, S. Saranya2, Rashmi
Jayakumar3 , Rashmi Swaminathan4, Sanchithaa Harikumar5, Sukitha Palanisamy, Vol 7.
2. A Survey on Lightweight CNN-Based Object, Detection Algorithms for Platforms with Limited
Computational Resources, Bouguettaya Abdelmalek, Kechida Ahmed, and Taberkit
Mohammed Amine, Research Center in Industrial Technologies CRTI, P.O. Box 64, Cheraga.
Algeria, Vol. 2, No. 2, 28-44
3. Animal Detection Using Deep Learning Algorithm, N. Banupriya1, S. Saranya2, Rashmi
Jayakumar3, Rashmi Swaminathan4, Sanchithaa Harikumar5, Sukitha Palanisamy6, Vol 7,
Issue 1, 2020
4. Antônio, W. H., Da Silva, M., Miani, R. S., & Souza, J. R. (2019). A proposal of an animal
detection system using machine learning. Applied Artificial Intelligence, 33(13), 1093-1106.
5. Sharma, S., & Shah, D. J. (2013). A brief overview on different animal detection methods.
Signal & Image Processing, 4(3), 77.
6. Banupriya, N., Saranya, S., Swaminathan, R., Harikumar, S., & Palanisamy, S. (2020). Animal
detection using deep learning algorithm. J. Crit. Rev, 7(1), 434-439.
7. Sharma, S. U., & Shah, D. J. (2016). A practical animal detection and collision avoidance
system using computer vision technique. IEEE access, 5, 347-358.
8. Sharma, S. U., & Shah, D. (2017). Design and Development of Animal Detection Algorithm
Using Image Processing. A Research Thesis, Gujarat Technological University.
9. Koik, B. T., & Ibrahim, H. (2012). A literature survey on animal detection methods in digital
images. International Journal of Future Computer and Communication, 1(1), 24.
10. Jeevitha, S., & Kumar, S. V. (2019, December). A study on sensor based animal intrusion alert
system using image processing techniques. In 2019 Third International conference on I-SMAC
(IoT in Social, Mobile, Analytics and Cloud)(I-SMAC) (pp. 20-23). IEEE.
11. Amrutha, H. M., Naresh, E., Kambli, P., Dayananda, P., & Niranjanamurthy, M. (2022,
December). Identification of Harmful animal detection using Image Processing Technique. In
2022 Fourth International Conference on Cognitive Computing and Information Processing
(CCIP) (pp. 1-5). IEEE.
12. Parikh, M., Patel, M., & Bhatt, D. (2013). Animal detection using template matching algorithm.
Int. J. Res. Mod. Eng. Emerg. Technol, 1(3), 26-32.
13. Dhillon, A., & Verma, G. K. (2020). Convolutional neural network: a review of models,
methodologies and applications to object detection. Progress in Artificial Intelligence, 9(2), 85-
112.
14. Saxena, A., Gupta, D. K., & Singh, S. (2021). An animal detection and collision avoidance
system using deep learning. In Advances in Communication and Computational Technology:
Select Proceedings of ICACCT 2019 (pp. 1069-1084). Springer Singapore.
15. Vatsavayi, V. K., & Andavarapu, N. (2022). Identification and classification of wild animals
from video sequences using hybrid deep residual convolutional neural network. Multimedia
Tools and Applications, 81(23), 33335-33360.

174
A Journal for New Zealand Herpetology

You might also like