Professional Documents
Culture Documents
I am extremely thankful to all my supporters whose input and feedback has made my project to turn
into a reality. This includes my college, Softwarica college of IT and e-commerce which has helped
me provide necessary environment to conduct an academic research for this thesis. I am thankful to
my module leader, Mr. Manoj Shrestha for supervising and motivating me throughout my thesis and
helping me with guidelines for research, implementation, and documentation. I have tried my best to
gather relevant document for this project. Furthermore, I don’t claim all the information presented
in this thesis are included perfectly. There may be shortcoming, factual errors, or mistakes in
implementation. Only I am responsible for those and I will try to give a better volume in future. Lastly,
I would like to show my gratitude to all my lecturers, friends, and family for supporting me
throughout this process.
Abstract
Psychological problems like depression, pessimism, anxiety, etc. are one of the major health issues in
this century (Scielosp, 2020) . An estimated 264 million people suffer from depression globally (WHO,
2020). An article published in American psychiatric association states $44 billion dollars are lost
because of workplace depression (Assosiation, 2020). Depression is not an untreatable condition
however, half of the employees are untreated (Assosiation, 2020). This number is only going up,
especially after the recent global pandemic. A survey was done among 3900 people who had a
previous case of covid-19 between May 2020 to January 2021. The study showed, 52% of them
suffered major depression (Reinberg, 2021). A more recent research that performed a meta-analysis
of multiple studies, that included 288,830 participants from multiple countries has found one in three
adults are experiencing symptom of depression because of covid-19 (Graciano, 2021). This gives an
idea of a serious issue that is coming. A proper solution should be considered to minimize the impact.
In the proposed system, an attempt to track emotional data of employees and usage of music as
therapy is being done. The system gets raw input data from webcam of computers and uses
convolutional neural networks to extract emotion data. The data is sent to a server and an
appropriate music is returned to user.
Keywords
Computer vision, Depression detection, Convolutional neural network, Facial feature extraction, Image
processing, Music as therapy
The mortality statistics show human life expectancy has increased all-time high in last century. While
the more famous killers like malaria, Polio, tuberculosis have been almost tackled by humanity, a new
killer with name of mental illness has been on rise (Scielosp, 2020). More than 264 million people
were suffering from a variation of depression worldwide in 2020. (WHO, 2020) Anxiety and
depression are two of the common reasons for various diseases globally. In developing countries like
Nepal, their condition is yet to be evaluated (Ajay Risal, 2016).
The modern life is extraordinarily easier than past. An average person does not have to fear predators
and live the hardship of highly physical life of past. While the mankind has moved on past these with
rise of technology, the wiring in the brain is still prevalent. Anxiety is a natural emotion that is
triggered in the condition of “Fight or Flight” (interestingengineering, 2020). The modern life is
complex, and many factors can lead to this condition being triggered. The factors can be anything like
Financial issues, Relationship issues, Family issues, Health issues or other reasons. Depression is the
leading reason for disability in the world (WHO, 2020). The modern world runs on money and
businesses, industries, tech firms, etc. play a crucial role in economy. These businesses thrive when
the people working there are satisfied. The stressful environment dealing with myriad of timelines
and schedules can be too stressing sometimes (Assosiation, 2020). Depression can lead to issues like
lower work performance, employee satisfaction, absenteeism, or low engagement, absenteeism, or
employees skipping the work (Assosiation, 2020). It can also be life threatening. However, it is not
untreatable. It is important to find out the suspect and help them to right direction. Depression can
be challenging to figure out as some symptoms are subtle and the patient themselves are not aware
of it. Although the typical symptoms like sadness and hopelessness are easy to find, things like forced
happiness, Fatigue and Lack of concentration are easy to figure out (medicalnewstoday, 2019). A
research has found, music can be used as a therapy to improve depressive tendencies (Aalbers, 2017).
So, we aim to create a system that tracks user activities and applies music as therapy.
The proposed system tries to tackle this by monitoring the employees periodically. The system makes
use of Convolutional neural network to process raw video/image data and send the response to
server. The server sends back a music according to mood. This system uses music as therapy to
prevent mental health issues from getting worse.
Figure 2: Effect of music on brain
1.1 Aim
The aim of this project is to create an appropriate solution that can be used in workplaces to battle
mental illness. It should be able to effectively track depressive tendencies among employees and
make use of music as therapy to help them.
1.2 Objective
1.2.1 PRIMARY OBJECTIVES
• Create a real time mental health tracker software.
• Understand effect of mental health in workplaces and ways to tackle it.
• Improve portability matrix by choosing dataset model with smallest memory footprint.
• Make use of music as therapy to prevent depressive tendencies among employees.
• Help managers figure out condition of their employees.
• Investigate the usage of artificial intelligence to solve complex human problems.
• Collect data about how usage of AI can change workplace environment and total productivity.
• Design a pleasant user interface with easy to use visualization tool.
• Obtain bachelor’s degree in computing.
According to WHO, Depression is a leading cause of disability in the world (WHO, 2020). Depression
can lead to issues like lower work performance, employee satisfaction, absenteeism, or low
engagement, absenteeism, or employees skipping the work (Assosiation, 2020). Despite it being a
notorious killer, it is not incurable. The tricky part about finding the depression is finding out. It does
not have a fixed reason. It can occur to anyone from children to adults for some reasons or no reason
at all (Schimelpfening, 2020). According to the national alliance on mental illness, 46% of people
committing suicides are suffering from some case of depression (nami, 2019). This issue has been
increasing since the recent pandemic. According to centres for disease control and prevention
(cdc.gov, 2020), a whopping 40% of U.S. adults reported struggling with mental health or substance
use.
From these reports, we can understand depression is a major issue currently and it is affecting many
people. At the top of being a life-threatening condition, it can also affect in professional works and
productivity (Davis, 2003). A necessary measure must be taken in order to battle this hindrance.
1.4 Research question
How can convolutional neural network be used to create a mental health detection system?
1.5 Background
The stress, deadlines, long hours and deskbound nature of modern work culture is one the main
reason people are destroying their health. Arounds 86% of American workers sit all day at work
(Giang, 2014). Another major issue that is uprising in the last century is Depression.
According to WHO, Depression is a leading cause of disability in the world (WHO, 2020). Depression
affects more than 17 million American adults every year (healthline, 2021). Surprisingly, as notorious
depression really is It is not an incurable disease. It can be diagnosed if found in earlier phases.
• No personal data is collected by server. All the processing of images is done in client side. The
user source of emotion data is untraceable and is used only once to send back music. The data
passes through an encrypted connection. No logs are kept so User Privacy can be guaranteed.
• It is made sure people are well informed about the objective of research honestly and interviews
were carried out only if permission was given.
• The copyrights, patents, etc of sources are respected. All the journals, papers, etc. are well
referenced using Harvard-Coventry references.
• The research can lead to getting an unpopular opinion here and there. Even if the opinions
sounded offensive to us, the opinion was respected. The research was not biased in any ways.
• The people involved in research are from various cultural background. Hence, a cultural
difference is likely to occur anytime. A proper filtering of data is our social responsibility to
prevent people from going on rampage.
2.2 GDPR
General data protection regulation (GDPR) is a regulation created in 2016 to protect European
citizens. It makes sure businesses protect the personal data of all the European citizens and respect
their privacy. This is mandatory to all the businesses and failure to comply can cost dearly (Nadeau,
2020).
Businesses have been continuously evolving and making digital transition past decade. They have
been using different services and large quantity of data regularly. However, a regulating body was
not present so GDPR was created. Since its inception, it has been quite successful. Big corporations
like Google, British Airways, Facebook were fined when they did not follow (eset, 2020). So, It has
been quite a success so far. Some principles set by GDPR are:
• The lawfulness, fairness and transparency states businesses should ask for consent first and
lawfully get the data of EU citizens. The data should not be sold to third party without consent
from owner.
• The personal limitation states individuals should be informed about all the reasons for data
collection.
• The data collection states businesses should not collect any data more than required. The
collected data must be justified and well documented.
• The accuracy states the data should always be up to date.
• The Storage limitations makes sure data is deleted after a certain period. This period should be
justified and well documented.
• The Integrity and confidentiality states businesses should implement a anonymisation system
should be implemented to protect user data from attackers.
In 2017, Dr louis Philippe Morenci and his team on collaboration with McLean hospital studied on a
possible use of Convolutional neural network in depressive patients (saleh, 2017). The system uses
facial landmark detection technique to get position of 68 facial landmarks of the face. These muscle
change can be tracked with these landmarks and finally predict the emotion user is showing. The
early study was done with 500 volunteers who were patients and regular people. The people were
asked to fill a set of questionnaires before and after interacting with the system. Among those 500,
15-20% showed symptoms of depression and same range for PTSD. The study contained all the types
of population which represented real world. The eventual goal of the application was to be used at
screening however, initially it was used to track patient mood during treatment. According to Dr
louis, the goal of this system was never to treat depression as that is the job of doctor. The calibration
was not perfect in the beginning, but they managed to get 78% correlation with time. This is a
important improvement as limited people were used.
A paper published by Namboodiri Sandhya Parameswaran (Parameswaram, 2019) made the use of
SVM classifier to train the feature data extracted using Gabor filter bank. The author experimented
with five different student multiple times and performed an experimental analysis. The experiment
resulted into following output
Figure 9: Results of research done by N.S. Parameswaran
Out of five different videos, first and second video resulted into matching actual and predicted result.
The fourth video was satisfactory as it showed High depression for actual mild depression. The third
and fifth however wrong. The overall system accuracy was 64.34%. This system was used in schools
to find student with depressive tendencies. A teacher or class monitor was informed accordingly.
Another research done by J. Singh used similar approach to decode depressive disorder with the use
of computer vision. A study was conducted between group of four hundred volunteers. Among the
total of 254 males and 147 females, The proposed system was able to attain 74 percent identification
success (Jaiteg Singh, 2020).
4 RESEARCH METHODOLOGY
Both the quantitative and qualitative analysis has been used to address the research objective of this
paper. Primary data has been used for quantitative analysis and Secondary data has been used for
qualitative analysis. The survey was used for primary data collection and literatures, past papers,
journals, etc were used for secondary data collection.
The collected data can be represented in any graph, charts and calculated statistical data like mean,
median or average. For the survey several participants are given questionnaires with multiple choice
questions and some optional written questions. The close ended MCQs however, are mandatory.
These questions allow us to get exact data for our research question.
• The topic was quite unique, and the research was based on recent pandemic so, there was limited
resources online. so, most of the research took more time than necessary. This resulted into
issues with time management and deadlines were difficult to meet.
• The methodology played crucial part in data collection. As data collection is the major part of this
research, we had to be careful to select appropriate methodology.
• Finding relevant information was difficult because of ongoing pandemic. Even though internet
has helped tremendously, it was difficult to get access to books, papers, etc.
• It was difficult to conduct find people for survey because of pandemic. Most of the working people
around me were unfamiliar with google sheets so I had to attach a tutorial for them. Initially,
finding variation in people for research was troublesome.
5 DATA COLLECTION
A number of office workers were presented with a list of questionnaires and the responses were
recorded. Total of 30 people participated during this process. Initially, a huge list with multiple
questions was presented but people engagement was low. So, we had to remove the unnecessary
questions. The participants increased after removing those questions. Participants were presented
with following questions.
The questions that did not matter much for research were made optional. All the data entered by user
are represented by google in appropriate charts like bar graph and pie-chart. The results of our
survey are explained below
Figure 16: People who find office stressful
It is found that a humongous 76.7% of total people find working at office stressful. This is a huge
problem since modern humans spend most of their life at work. The answer to this question can be
quite difficult as work can sometime be lovely and sometime difficult. To address this, we allowed
people an ability to choose both yes and no if wanted. However, people still picked yes.
Among 30 people present, 93.3% of them had a case of covid-19 in the past. We can be sure these
people have experienced the issues we are trying to address in this paper. The resulting 36.7% of
people were not affected by it.
Figure 18: People affected mentally by covid-19
Despite only 63.3% people being affected from covid-19, 90% of the total reported to being affected
mentally because of pandemic directly or indirectly. This is a important data as it shows not only
people with cases of covid-19 are in danger from workplace depression.
Figure 19: People who welcome an idea of AI based mental health detector
When asked how people like the idea of installing an AI based mental detector that only tracks the
emotion of users, there were mixed responses. 10% of them discarded the idea, 20% of them
welcomed the idea but were not too sure. However, Majority (70%) of people were very likely to
allow installation. This should be a good data to instigate the process.
An optional field asking for suggestions was added too but only 4 of the response was recorded. They
wanted the system to run faster and improve technical factors. There was not any complain about
trust issues. However, we should still take ethical issues seriously and provide a most secure system.
6 APPLICATION DEVELOPMENT
A web application was developed as a final product. The application is easily accessible with the help
of browser as it is powered by JavaScript. The application allows user to record their face with
webcam in real time. Users are shown their emotion data on screen and they can get some idea too.
The application also shows music according to mood of users. The application tries to use music as
therapy to cure the mood of user by this process.
Analyse the requirements: All the requirements necessary for the system were considered in this
phase. A suitable programming language, database and development environment is chosen in this
phase.
Designing the system: An overall system architecture taking consideration of requirements from
previous phase is designed in this phase. The application architecture is designed in this step with
tools such as class diagram, entity diagram, use-case diagram, etc.
Implementation: This phase covers all the implementation part. The coding takes place and the
running status of application is confirmed.
Testing: After the implementation phase, the functionality of software is almost completed.
However, there are likely to be some bugs and issues. Each unit of the application are tested for faults
and failures.
Deployment: The product is deployed after functional and non-functional testing in this phase. It is
then provided to the client. This is the one of the crucial phases as customer gets access to the
working software after this.
Maintenance: Even though the software is provided to client, some bugs or security vulnerabilities
might occur in future. This phase tries to solve those issues with patches and updates.
6.2 Tools
Visual studio code: Visual studio is a lightweight text editor that can turn into a full fletched IDE
with plugins. It also provides some key features like debugger and version control by default. It is
also the most popular text editor currently (hackr.io, 2021). The installation and configuration can
be found at appendix.
Microsoft office: Microsoft office is one of the most popular suites of office and productivity
software. We have utilized the MS word for writing the paper and MS project for creating a time
management Gantt chart.
Postman: Postman is a software used to test APIs. It makes the developer workflow easier by
minimizing the tedious process of writing the tests in code. The collection feature can be used to
create an abstract test endpoint and customized as needed.
Git and Github: Git is the most popular version control system in the world and Github is an online
platform providing hosting, management, and collaboration between developers. Both of them are
free to use and are made used on tremendously in the project.
Google Chrome: Google chrome is the most popular browser used currently (statcounter, 2021). It
is developed by google and based on chromium browser. All the JavaScript codes has been checked
using this browser.
Canva: Canva is a popular cloud-based design tool. It offers a free version with some limitations. The
infographics and charts necessary for this project are made with the use of it.
Figma: Figma is another cloud-based design tool. It was used for custom designs and images.
Node.js is a programming runtime that runs asynchronously, making it faster than traditional
languages like PHP. Node.js also includes nice package called npm. Npm package enables user to get
access to npm repository and install any libraries as required. Nodejs is quite lightweight and
requires only few modules to run. This was not the cases for previous frameworks like Laravel. The
asynchronous nature of NodeJS enables the software to run multiple operation at once. This
scalability is the reason the application is developed on NodeJS.
There are various frameworks like Express, Nest, Meteor, etc for development of backend using
NodeJS. However, express is the most popular among them. and rightly so, Express provides a
minimal syntax and easy to understand architecture. On top of that, It also provides a nifty tool called
express generator.
MongoDB was chosen as the preferred database as it is a highly performant database solution. It is
a NoSQL database and highly scalable as file based noSQL database are faster to read and write as
SQL based database. The system fills the gap of a highly required solution, so users are likely to
increase exponentially. Therefore, the industry standard combination of NodeJS and MongoDB is
used.
Figure 24: Technologies used in the development of system
7.1 Security
Despite NodeJS being a highly performant framework, it is still new. It was developed by Ryan Dahl
in 2009. This makes it quite prone to issues occasionally. Well, none of them are too threatening as
NodeJS has been used by likes of LinkedIn, Netflix, Uber, etc. The good news is any major issue can
be fixed with some package updates. Since our application deals with important data like emotion, it
is necessary to prepare a secure and robust solution. We have used following tools to make this
system secure and robust.
Authentication: A proper login is required to access the application. Following tools are used to
achieve a robust authentication system.
Bcrypt.js: Bcrypt.js is a JavaScript library that provides the application with ability to hash
passwords to create their salts. This protects the user from rainbow table attacks. It can also be used
to verify the password with hash from database. This is one of the most secure solution to store
passwords.
CORS: The default browser function is to avoid people get access to file from outside the domain. This
can be solved with a NodeJS package called CORS. This allows our backend to be separate from our
frontend. The isolation between backend and frontend is one of the reasons NodeJS is preferred over
other frameworks.
Regular updates are necessary to protect the system. This could be tedious process if it was for
others. Utilizing npm, we can update all the out of date packages at one and keep the system secure.
Using these packages, the security of application was ensured. The usage of bcrypt ensure all the
sensitive data are encrypted and regular update solves breaking changes and package security issues.
7.2 Usability
Despite our system being pretty small visually, it is not difficult to make it look messy. A good design
always attracts the users. A careful selection of colour palette is to be implemented and
complementary fonts are to be used. Most of the application is hardcoded and checked so errors are
very unlikely to occur. A proper DOM manipulation can yield highly performant applications. All the
codes are commented properly making sure that even non-technical person can understand the flow
of data.
Figure 26: Usability of proposed system
7.3 Scalability
The application fills the demand of a major problem solution. The pandemic especially has increased
this applications potential exponentially. Hence, the application is to be developed considering the
scalability factor of it. The usage of NodeJS which uses non-blocking I/O and asynchronous operation
solves the performance issue of the server. Even though server is performant, using NoSQL instead
of traditional SQL could leverage faster performance. MongoDB also offers a cloud solution called
MongoDB atlas. Using this cloud solution ensures the data are not compromised in future. The Pay as
you go pricing model allows the system to always work performantly.
Figure 27: Scalability of proposed system
7.5 Reliability
The most important aspect of any application is reliability. Nobody wants to use a software that is
going to break on them down the road. This is especially true for a software like ours which deals
with developing a solution for a mental health issue. The application makes use of modern NodeJS
ecosystem and uses MongoDB for database. MongoDB is a industry proven database for highly
performant systems. The libraries and modules used in the application were chosen carefully such
that no breaking changes occur in future.
Users are presented with a camera screen. The faces are tracked and a small rectangular box shows
emotion data.
The application displays the rectangle according to mood and shows values too. The faces are tracked
every second and if a person is sad for more than 10 secs, they are presented with a motivating music.
Figure 33: Music is played when sadness count reaches 10
9 DISCUSSION
One of the main reasons why workers are going to choose this solution is it does all the processing
client side. This prevents any anxiety users may have about turning the camera on most of the time.
The system makes use of Convolutional neural network to process raw video/image data and send
the response to server. The server sends back a music according to mood. This system uses music as
therapy to prevent mental health issues from getting worse.
10 PEST ANALYSIS
The PEST analysis was used to organize, evaluate, and track multiple factors that can impact the
overall process at present or in future. It can help us discover opportunities and threats due to
Political, Economic, Social and Technological factors (GroupMap, 2021).
The application was made completely following cyber laws and policies to ensure no legal issues
occur at past. Artificial intelligence is a new technology and many governments are yet to amend laws
on this topic. Our system, however, does all the processing in client side and only emotion data are
sent to server. The emotion data do not contain any personal information and they are not kept in
logs. Another advantage of processing client side is a huge server is not necessary anymore. This
solves the possible economic issues. A social analysis found; people were quite welcoming about the
application. The questionnaire for this is included in the appendix at the bottom. Finally, a technical
analysis was performed, and it was revealed that there is a low probability for a new technology to
evolve.
Figure 34: PEST analysis
11 ISSUE LOG
12 CONCLUSION
The study done in this paper was done with image data in variable time. Some were taken after a few
hours’ session of writing paper and some at the morning. The presence of Angry, Disgust were
prominent in the photos after intensive work. The Happy and Neutral faces were prominent. The
free, portable and pretrained models provided by faceAPI-js were used for image processing. These
models were originally made for Keras. however, it has been converted to a JavaScript supported
.json file by good folks of internet. These models are trained with utilization of RAFDB, a huge
collection of diverse facial expressions. This is a huge training set and should be sufficient for general
use. If accuracy is to be improved in future, A custom set of local image data can be use to train the
model using Microsoft FERPlus. At first, implementation of this system seemed too difficult however
after a through research and hours of hard work, a prototype was possible. Learning from others
research paper has helped a lot to understand underlying process of the Convolutional neural
network, training the models with dataset, etc. The classifier was quite reliable and found the correct
reason most of the time, especially for angry and happy faces.
Depression is a complex human condition and different people show different emotion. This system
can only show results based on physical attributes associated with depression. To get actual idea of
the situation, other activities of employees such as work efficiency, attendance, etc are to be
considered. Though music as therapy is performed by the system, a regular sport session or a
refreshment would help too. The goal is to loosen up employees and keep them distracted from
stressful tasks while keeping the productivity same. By taking consideration of above activities, the
mental health of employees can be tracked, and necessary measures can be taken to solve it
effectively.
13 FUTURE WORK
After completing the through research and development of the system, there are numbers of
improvements that can be made. Some of them are:
• The people who answered the questionnaire during the research were friends of my age. Though
more than a dozen of people participated, only a tiny group of age was considered. This can be
improved by asking the questionnaires again to diverse age group.
• The dataset used in training the used machine learning model was not local. hence, a lot of faces
were of foreign people. Though this can be fine for most of the cases, it can be improved by usage
of a custom dataset of local faces.
• The application uses the most portable model, tiny face detector and runs totally on client side.
This system should run without any problems in desktop systems. However, Problems may arise
on mobile devices. So, native apps can be made in future to address this issue.
• The functionality of the system is done but UI/UX aspect were not prioritized in this iteration.
This can be solved in future versions with help of graphic designers.
• This system is highly versatile and can run anywhere. Currently, we are considering using it in a
workplace, but these can be implemented in other institutions like schools, hostels, etc with few
tweaks.
• There are limited, royalty free music used in the system currently. Despite them being shown
according to mood, they are not optimized for a usage of music as therapy. A custom-made
collection of music can do a much better job.
14 BIBLIOGRAPHY
Aalbers, S., 2017. [Online]
Available at: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6486188
Ceja, E. G., 2018. Mental health monitoring with multimodal sensing and machine learning: A survey.
[Online]
Available at: https://www.sciencedirect.com/science/article/pii/S1574119217305692#b23
eset, w. b., 2020. Two years later, has GDPR fulfilled its promise?. [Online]
Available at: https://www.welivesecurity.com/2020/05/25/two-years-later-has-gdpr-fulfilled-its-
promise/
Guru99, 2021. What is Waterfall Model in SDLC? Advantages & Disadvantages. [Online]
Available at: https://www.guru99.com/what-is-sdlc-or-waterfall-model.html
healthline, 2021. Work Depression: How to Take Care of Your Mental Health on the Job. [Online]
Available at: https://www.healthline.com/health/depression/work-depression
interestingengineering, 2020. [Online]
Available at: https://interestingengineering.com/can-technology-cause-anxiety-and-depression
Jaiteg Singh, G. G., 2020. Decoding depressive disorder using computer vision. [Online]
Available at: https://link.springer.com/article/10.1007/s11042-020-10128-9
Nadeau, M., 2020. General Data Protection Regulation (GDPR): What you need to know to stay
compliant. [Online]
Available at: https://www.csoonline.com/article/3202771/general-data-protection-regulation-
gdpr-requirements-deadlines-and-facts.html
[Accessed 2021].
Parameswaram, N., 2019. A computer vision based image processing system for depression detection
among students for counseling. [Online]
Available at:
https://www.researchgate.net/publication/331147769_A_computer_vision_based_image_processi
ng_system_for_depression_detection_among_students_for_counseling
saleh, M., 2017. Computer Vision Applications in Mental Health: An Interview with Dr. LP Morency.
[Online]
Available at: https://www.medgadget.com/2017/06/computer-vision-applications-mental-health-
interview-dr-lp-morency.html
Node.js installation:
The latest and stable version of Node.js is downloaded from official website. It is available here:
https://nodejs.org/en/download/
Installation of mongoDB database:
https://www.mongodb.com/download-center/community
MongoDB compass was installed as follows
Configuring Express.js
Other modules necessary for our backend are added:
The dependencies required for the backend and frontend are Bcrypt.js, Body-parser, Cors, Json web
token (JWT), Mongoose, Morgan, Multer and validator.