0% found this document useful (0 votes)
31 views

Depression Detection Using Convolutional Neural Networks 1

The document discusses a proposed system to detect depression using convolutional neural networks, OpenCV, Keras, TensorFlow, and other tools. The system analyzes facial expressions in images to detect signs of depression. An experimental dataset of 5000 images of depressed and non-depressed people was also generated to evaluate the proposed approach.

Uploaded by

BT20CS028 [AVI]
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Depression Detection Using Convolutional Neural Networks 1

The document discusses a proposed system to detect depression using convolutional neural networks, OpenCV, Keras, TensorFlow, and other tools. The system analyzes facial expressions in images to detect signs of depression. An experimental dataset of 5000 images of depressed and non-depressed people was also generated to evaluate the proposed approach.

Uploaded by

BT20CS028 [AVI]
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/357736059

Depression Detection Using Convolutional Neural Networks

Conference Paper · December 2021


DOI: 10.1109/SPICSCON54707.2021.9885517

CITATIONS READS
4 1,479

4 authors:

Farzana Arefin Nazira Sharna Rani Das


European University of Bangladesh Bangladesh University of Business and Technology
4 PUBLICATIONS 9 CITATIONS 1 PUBLICATION 4 CITATIONS

SEE PROFILE SEE PROFILE

Sadah Anjum Shanto M. Firoz Mridha Ph. D.


Bangladesh University of Business and Technology American International University-Bangladesh
9 PUBLICATIONS 43 CITATIONS 185 PUBLICATIONS 1,421 CITATIONS

SEE PROFILE SEE PROFILE

All content following this page was uploaded by Farzana Arefin Nazira on 04 February 2023.

The user has requested enhancement of the downloaded file.


Depression Detection Using Convolutional Neural
Networks

Abstract—Facial Expression Recognition (FER) has been an data visualization framework. Numpy uses arrays to turn the
essential field in the Deep Learning area since the arrival of images into arrays that may be used to store the trained
big data. Human psychological activity is reflected by human model. Seaborn is a python that aids with data exploration
facial expressions that can provide significant knowledge about
human nature. In that time, depression has become a severe and comprehension. The OS module provides functionality for
mental illness. It is vital to detect depressed people. To detect generating and destroying directories, retrieving their informa-
depression, we have proposed a system based on CNN, OpenCV, tion, and altering and detecting the folder. TensorFlow is used
Haar Cascade Classifier. Haar Cascade Classifier is a machine to build massive neural networks with multiple layers. Keras
learning algorithm used for face detection. Convolution layers is a high-level neural network API that is widely used.
are used in the proposed combination technique. Furthermore,
no datasets available that represents the natural expressions of In Deep learning analyze a person’s facial expression for
the depressed face and can be used to detect depression. So, We detecting depression is a difficult task because every depressed
have generated a Depressed and Not Depressed (DND) dataset human has a different facial expression [5,6]. Four convolu-
which contains the 5000 images. Our proposed system has been tional layers, three top pooling layers, two fully connected
evaluated using the DND dataset and achieved accuracy 81% , layers, and one softmax output layer are included in the CNN.
precision 87% , recall 88%.
Index Terms—CNN, Depression, Tensorflow, Keras, OpenCV,
The total contribution of the research can be summed up as
Haar Cascade Classifier follows:
• The Depressed and Not Depressed(DND) dataset, which

I. I NTRODUCTION consists of 5000 images from two different classes, has


been generated.
Depression is a mental illness that affects people of all ages • A CNN, OpenCV based architecture has been proposed
psychologically. In today’s world, depression has become a for classifying human depression. The proposed archi-
common illness. The physical structure of the brain can be tecture results are compared to the other consequences
affected due to depression. Depression causes many physical of CNN-based proposed architecture.
and emotional problems which affect a person’s daily life. The following is how the remaining part of the paper is
Due to depression, a person losses interest in life, and that organized: Section 2 describes the associated research. The
leads to suicide or self-harm. Depression can predict based overall architecture of the deep CNN hybrid architecture is
on the symptoms: feeling sad, anxious, hopeless, helpless, presented in section 3. Section 4 covers the model’s evaluation
restless continuously, thinking of committing suicide, losing as well as a comparison of the proposed architecture outcomes.
interest in his daily activities, oversleeping, Irritability, etc. At Finally, Section 5 brings the paper to a conclusion.
the early stage of depression, more than half of people would
not go to a doctor or psychologist because of social issues. II. R ELATED W ORK
Antidepressants, medicines, and counseling are the treatment The capacity to detect and recognize a person based on their
for depressions [1]. A deep learning technique has been facial traits is known as face recognition [1].
used to detect depressed people through image classification Nafiz Al Asad et al. [7] proposed a data-analytic-based model
using Convolutional Neural Network(CNN), OpenCV, Keras, for detecting depression from social media posts. Data has
TensorFlow, matplotlib, NumPy, seaborn, OS, Haar Cascade been collected from Twitter and Facebook. A fully structured
Classifier, depressionmodel.h5. The proposed architecture an- and semi-structured interview(SDI) method is a convenient
alyzes the human face for detecting depression. way of detect depression. For detecting depression in a ef-
A colossal computer vision techniques application has been ficient way natural language processing(NPL), Support Vector
developed using deep learning techniques. Deep learning Machine for classification(SVM) and Native Byes algorithm
researchers introduced a Convolutional Neural Network that can be used. The accuracy of their system is 74%. Whei-
follows a hierarchical model for solving pattern recognition dima Carneiro de Melo et al. [8] presents a deep learning
problems. Deep Convolutional Neural Networks have achieved architecture for detecting the depression level accurately us-
enormous success and are particularly well adapted for im- ing distribution learning. For underlying data distribution, a
age recognition applications involving large datasets [2,3]. new expectation loss function has been estimated. Dataset
OpenCV is a robust Python package for solving computer AVEC2013 and AVEC2014 have been used for an effective
vision problems. Haar Cascade Classifier detects faces from outcome. Mandar Deshpande et al. [9] developed a proposed
images or videos. Matplotlib is a NumPy-based multi-platform architecture to detect depression through emotion analysis
from Twitter feeds using Natural Language Processing. All B. Network Structured
tweets are categorized as neutral or sad based on the selected 1) Convolutional Neural Network(CNN): The convolu-
word list for detecting depression. The support vector machine tional neural network is a deep neural network that has three
and Naive-Bayes classifier were used in the class prediction. or more hidden layers. Scale-Invariant Feature Transform, and
Mutinomial Naive Bayes has an accuracy of 83% and SVM Histogram of Oriented Gradient techniques can be extracted
has an accuracy of 79%. Faisal Muhammad Shah et al. [10] by CNN more extensively [4]. Fig. 1 Demonstrate how to use
proposed a hybrid model to detect depression from user posts. CNN to learn and extract characteristics from images.
Trained the deep learning algorithm using the training data and
test the system using the published Reddit dataset pilot piece
of work, Early Detection of Depression in CLEF eRisk 2017. kernels number

Proposed a Bidirectional Long Short Term Memory (BiLSTM)


Result
with several word embed methods and metadata properties. At- CNN CNN
CNN
Risk Window 23, Word2VecEmbed and meta feature precision Input images Feature Size
is 0.78, recall 0.86, and risk is F1 score is 0.81. Kuhaneswaran
Layers
AL Govindasamy et al. [11] developed a proposed architecture
for detecting depression using social media data. Naı̈ve Bayes
and a hybrid model , NBTree classifier fed the twitter data. Fig. 1. The convolutional neural network architecture of depression image
The accuracy of the NBTree algorithm and Naive Bayes is classification from an enriched dataset. The result of the convolution is
represented by each cube. The height and breadth are obtained. The depth
over 3000 tweet dataset is 97.31% and over 1000 tweets of every cube is equivalent to the kernels. Every convolution pursues batch
92.34%. Swati Jain et al. [12] proposed architecture to an- normalization and an activation layer. It is then turned into a linear set of
alyze depression and detect suicidal ideation using XGBoost nodes after the final convolution.
algorithm, Random Forest Classifier, Logistic Regression, and
Support Vector Machine. Real-time data has been collected CNN has six convolutional layers with the sequential model
from parents and students by a Parent health questionnaire, and includes a ReLu activation function on each in our
and data has been collected from depressed tweets. XGBoost proposed architecture. Each layer has multiple convolution
algorithm gives 83.87% accuracy, and Logistic Regression kernels, which allows for various feature maps to be created. In
classifier accuracy is 86.45%. our proposed architecture, the kernel size is (3,3). The image is
However, the majority of paper works for detect depression in grayscale mode. The following is a mathematical definition
from social media text. of the convolution method:
X
yjl = f ( yil−1 ∗ kij
l
+ clj ) (2)
III. M ETHODOLOGY
iϵMj
The complete methodology will be into two phases: (a) data
preliminary processing (b) network structured Here yil−1 = the result of the prior layer’s characteristic map.
yjl = ith channel output of the jth convolution layer. Calculate
A. Data Preliminary Processing the activation function ujl , f (. ) using the Mj input feature
maps subset. kijl
= convolutional kernel and cjl = offset that
The proposed architecture has been trained and test using corresponds.
the DND dataset. The DND dataset has been processed using To Train each layer model independently batch normaliza-
data normalization techniques. tion technique has been used. Normalize the previous layer
1) Data Normalization: Data normalization is a necessary output and reduce the overfitting for a slight regularization
approach that ensures that every parameter has the same distri- effect. In our proposed architecture, We define batch size 128.
bution of data. Data normalization accelerates the convergence Define the batch normalization in the CNN layer. It makes
of the convolutional network during training. It is consid- deep neural network architectures more stable and allows for
ered as intensities offsets and minimizes the intrinsic feature faster convergence. The batch normalization equation can be
disparity. Standard derivation and gaussian normalization can defined as follows,
be used for data normalization because intensities offsets are
(m) (m)
fixed. All image data is molded into a grid of 64 pixels through yi − µC
64 pixels. Normalization equation, Yi′ (m) = q (3)
(m)2
   σC
d11 . . . d1m
(m)
N ormalize(D) =  ...
 .. ..  /127.5 − 1 (1) Here Yi′ (m) = mth hidden unit normalized value, µC = mean
. .   (m)2
dn1 ... dnm value, σC = mth hidden unit variance and C = the particular
data batch.
Here D = single-channel depressed and not depressed image We activate the (Rectified linear activation function) ReLU,
matrix, n = number of rows, and m = the number of depressed which is used for the calculation. ReLU aids in avoiding the
and not depressed image matrix columns. exponential development of computation required to run the
neural network. ReLU returns zero if it obtains any non- notdepressed. We have collected the depressed and notde-
positive value. If the value is positive, ReLU returns the input pressed people images from the web to evaluating our pro-
value. ReLU function can be defined as follows, posed architecture. We gathered 5000 images. 80% of images
have been used for training and 20% have been used for
ReLU = max(0, y) (4) testing. Fig. 3 Represents a visual of the mentioned dataset.
We are using MaxPooling2D layers. We define the pool
size (2,2). The input is downsampled throughout its spatial
dimensions by taking the highest value for each input channel
over an input window. Then we add the Dropout layer to
prevent the model overfitted. During the training time, with
the frequency rate, the dropout layer set randomly input units
zero. The dropout layer precludes the capacity of the network.
We can calculate the neural network output with dropout as
follows, X
m[pk] = n(p)pk (5)
r

Here p = neuron output , dropout probability n(p) is n.


The dense layer is a deeply connected neural network. The
input is received by each neuron from the previous layers Fig. 3. Represents the DND dataset.
neuron. The final convolutional layer output is the input of
a dense layer. The dense layer classifies the images using
the output of the convolutional layer. The following equation B. Experimental setup
represented a fully connected layer, For data pre-processing, experimentation, model evalua-
tions, Python programming language is used. The proposed
e(y) = Activation(un y + d) (6) system has been developed using CNN, OpenCV, Keras,
Here u = [u1 , u2 , u3 , u4 , ...., un ]n defines the dense layer TensorFlow, matplotlib, NumPy, seaborn, OS, Haar Cascade
weight vectora and d = the bias value of dense layer. Classifier, depressionmodel.h5.
2) OpenCV: To detect depression, we have used OpenCV C. Evaluation metrics
with Haar cascade classifier and depressionmodel.h5. Haar
Cascade Classifier used by OpenCV for face detection. Fig. 2 We apply a confusion matrix-based method to estimate ac-
Demonstrate the work flow of Haar Cascade Classifier. curacy, precision and recall in order to assess the performance
of our proposed system.
N umberof correctpredictions
Accuracy = (7)
T otalnumberof predictions
Gray image Detect other facial Calculate the accuracy in binary classifications focus on
Image Detect face
conversion organs positive and negative.
TP + TN
Draw a
Accuracy = (8)
rectangular frame
TP + TN + FP + FN
around the face
Calculate precision from the following equations,
TP
Fig. 2. Haar Cascade Classifier workflow. P recision = (9)
TP + FP
IV. E VALUATION Calculate recall from the following equations,
We create the DND dataset, which contains 5000 images, TP
Recall = (10)
and evaluating our proposed architecture on this dataset. First, TP + FN
the DND dataset and experimental setup are described. Next, Here TP = True Positives, TN = True Negatives, FP =
the metrics that were used to assess the system accuracy False Positives, and FN = False Negatives.
are discussed. Then the proposed architecture result has been
presented and compared with different proposed systems. D. Results analysis
The proposed system has been evaluated using the DND
A. The Depressed and Not Depressed dataset dataset. The research analyzes the impact of combining CNN,
The Depressed and Not Depressed dataset, which contains OpenCV, Haar Cascade classifier to detect depression. The
5000 images, has been used for system testing and training. CNN, OpenCV combination obtained good accuracy. Fig. 4
The DND dataset is divided into two classes depressed and represents depression detection.
necessary image processing research and enhance the intellect
and practicability in further research.
R EFERENCES
[1] E. Aragons, J. L. Piol, and A. Labad, “The overdiagnosis of depression
in non-depressed patients in primary care,” Family Practice, vol. 23, pp.
363–368, 2006
[2] Krizhevsky, A., Sutskever, I. and Hinton, G.E., 2017. Imagenet classifi-
cation with deep convolutional neural networks. Communications of the
ACM, 60(6), pp.84-90.
[3] Simonyan, K. and Zisserman, A., 2014. Very deep convolu-
tional networks for large-scale image recognition. arXiv preprint
arXiv:1409.1556.
[4] M. M. Kabir, A. Q. Ohi, M. S. Rahman and M. F. Mridha, ”An Evolution
Fig. 4. Depression and Notdepression Detection
of CNN Object Classifiers on Low-Resolution Images,” 2020 IEEE 17th
International Conference on Smart Communities: Improving Quality
of Life Using ICT, IoT and AI (HONET), 2020, pp. 209-213, doi:
In the following table, we will see the accuracy, precision, 10.1109/HONET50430.2020.9322661.
[5] Jung, H., Lee, S., Yim, J., Park, S. and Kim, J., 2015. Joint fine-tuning in
recall for our proposed architecture. Accuracy, precision, and deep neural networks for facial expression recognition. In Proceedings of
recall are calculated by the confusion matrix given in the the IEEE international conference on computer vision (pp. 2983-2991).
Evaluation metrics subsection. [6] Mollahosseini, A., Chan, D. and Mahoor, M.H., 2016, March. Going
deeper in facial expression recognition using deep neural networks.
In 2016 IEEE Winter conference on applications of computer vision
TABLE I (WACV) (pp. 1-10). IEEE.
THE TABLE DEMONSTRATES ACCURACY, PRECISION, RECALL [7] N. A. Asad, M. A. Mahmud Pranto, S. Afreen and M. M. Islam,
OF THE PROPOSED ARCHITECTURE ”Depression Detection by Analyzing Social Media Posts of User,”
2019 IEEE International Conference on Signal Processing, Informa-
Model Accuracy Precision Recall tion, Communication Systems (SPICSCON), 2019, pp. 13-17, doi:
Proposed Model 0.81 0.87 0.88 10.1109/SPICSCON48833.2019.9065101.
[8] W. C. de Melo, E. Granger and A. Hadid, ”Depression Detec-
tion Based on Deep Distribution Learning,” 2019 IEEE International
The proposed system accuracy is 81%, precision is 87%, Conference on Image Processing (ICIP), 2019, pp. 4544-4548, doi:
10.1109/ICIP.2019.8803467.
and recall is 88%. We measure the true positives, true nega- [9] M. Deshpande and V. Rao, ”Depression detection using emotion artificial
tives, false positives, false negatives values from the confusion intelligence,” 2017 International Conference on Intelligent Sustainable
matrix to calculate accuracy, precision, and recall. Now we Systems (ICISS), 2017, pp. 858-862, doi: 10.1109/ISS1.2017.8389299.
[10] F. M. Shah et al., ”Early Depression Detection from Social Net-
will compare our proposed architecture performance with the work Using Deep Learning Techniques,” 2020 IEEE Region 10
other proposed architecture performance. We will show the Symposium (TENSYMP), 2020, pp. 823-826, doi: 10.1109/TEN-
different proposed architecture accuracy in the following table. SYMP50017.2020.9231008.
[11] K. A. Govindasamy and N. Palanichamy, ”Depression Detection Using
Machine Learning Techniques on Twitter Data,” 2021 5th International
TABLE II Conference on Intelligent Computing and Control Systems (ICICCS),
THE TABLE DEMONSTRATES THE CNN ALGORITHM 2021, pp. 960-966, doi: 10.1109/ICICCS51141.2021.9432203.
ACCURACY OF DIFFERENT PROPOSED SYSTEMS [12] S. Jain, S. P. Narayan, R. K. Dewang, U. Bhartiya, N. Meena and V.
Kumar, ”A Machine Learning based Depression Analysis and Suicidal
Ideation Detection System using Questionnaires and Twitter,” 2019 IEEE
Reference Algorithm Dataset Accuracy
Students Conference on Engineering and Systems (SCES), 2019, pp. 1-
[13] CNN CK+, FER13 81%
6, doi: 10.1109/SCES46477.2019.8977211.
[14] CNN, RNN FER2013 65%, 41% [13] E. S. Hussein, U. Qidwai and M. Al-Meer, ”Emotional Stability Detec-
[15] CNN FERC-2013, JAFFE 70.14%, 98.65% tion Using Convolutional Neural Networks,” 2020 IEEE International
[16] CNN FER2013 88.56% Conference on Informatics, IoT, and Enabling Technologies (ICIoT),
2020, pp. 136-140, doi: 10.1109/ICIoT48696.2020.9089440.
[14] R. Qayyum et al., ”Android based Emotion Detection Using Convo-
Table II presents the accuracy for different proposed systems lutions Neural Networks,” 2021 International Conference on Computa-
using different algorithms. We have compared our proposed tional Intelligence and Knowledge Economy (ICCIKE), 2021, pp. 360-
365, doi: 10.1109/ICCIKE51210.2021.9410768.
architecture accuracy with that accuracy. Our Proposed archi- [15] A. Jaiswal, A. Krishnama Raju and S. Deb, ”Facial Emotion De-
tecture obtained good accuracy, precision, and recall. tection Using Deep Learning,” 2020 International Conference for
Emerging Technology (INCET), 2020, pp. 1-5, doi: 10.1109/IN-
V. C ONCLUSION CET49848.2020.9154121.
[16] H. Zhang, A. Jolfaei and M. Alazab, ”A Face Emotion Recogni-
The paper detects the depressed and not depressed people tion Method Using Convolutional Neural Network and Image Edge
analyzing the facial expression using the DND dataset. We Computing,” in IEEE Access, vol. 7, pp. 159081-159089, 2019, doi:
10.1109/ACCESS.2019.2949741.
combined the CNN, OpenCV, Haar Cascade classifier, de- [17] A. Zafar and S. Chitnis, ”Survey of Depression Detection using Social
pressionmodel.h5 for train and tested our proposed architec- Networking Sites via Data Mining,” 2020 10th International Conference
ture. The proposed architecture performance is also compared on Cloud Computing, Data Science Engineering (Confluence), 2020,
pp. 88-93, doi: 10.1109/Confluence47617.2020.9058189.
with different proposed architecture accuracy. The proposed
architecture gives good performance. We are certain that the
impact of our research effort will pave the path for future

View publication stats

You might also like