Skip to content

parkjjoe/sleep-position-classification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Sleep Position Classification App Using Deep Learning

Capstone design project for graduation

Abstract

This is a repository for the capstone design project that allow users to identify their sleep positions by classifying the sleep position image data received by a deep learning model, recording them on the app screen, and generating statistics.

In this work, ResNet50 was trained by Google Colab. We purchased a home CCTV and recorded sleeping videos. Plus, we applied data transformation, data augmentation and various improvement techniques improving overfitting to increase the test accuracy to over 90%. The ResNet50 was converted to 'tflite' format and saved in Android Studio. Then, we created an application so that users can easily identify their sleep positions. The application is divided into MAIN, INFO, RECORDS, and STAT screens. The functions of each screen are as follows:

  • MAIN: The sleeping video is uploaded, goes through preprocessing, and then ResNet50 classifies the sleep positions.
  • INFO: Users can check the pros, cons, and improvements for 10 different sleeping positions.
  • RECORDS: Classified images are recorded.
  • STAT: A representative image and two charts are provided.

Flow Chart

Capstone Design Flow Chart

Android Studio Files Matching

Screen Name .java (@java) .xml (@layout) Additional files (@java, @drawable)
MAIN FirstActivity.java first.xml
loading.xml
FileHelper.java
FileHelper2.java
border.xml
border_red.xml
INFO InfoActivity.java info.xml back.jpg
back_hurray.jpg
back_left.jpg
back_right.jpg
front.jpg
front_hurray.jpg
front_left_raised.jpg
front_right_raised.jpg
left.jpg
right.jpg
SOURCE SourceActivity.java source.xml
RECORDS RecordActivity.java records.xml
dialog_image.xml
HISTORY2 (RECORDS) History2Activity.java history2.xml
dialog_image.xml
STAT MainActivity.java capstonedesign.xml border.xml
border_chart.xml
HISTORY (STAT) HistoryActivity.java history.xml border.xml
border_chart.xml

border_info.xml is not used.

Usage

πŸ”΄ MAIN

MAIN1

When you first run the app, this screen appears. Only the 'INFO' and 'SELECT' buttons are activated.

MAIN2_Select_Video1 MAIN3_Select_Video2 MAIN4_After_Selecting_Video

When you click the 'SELECT' button, you can select a video. After selecting the video in your gallery, the video name is displayed in a black box on the MAIN screen, and the toast message 'μ˜μƒμ΄ μ—…λ‘œλ“œλ˜μ—ˆμŠ΅λ‹ˆλ‹€.' appears. And then, the 'CLASSIFY' button is activated.

MAIN5_CLASSIFY MAIN6_After_Classifying

When you click the 'CLASSIFY' button, the images are extracted from the uploaded video in designated frame units. The video path, classification results, and extracted frame units are written and stored in two txt files. After classifying, the 'RECORDS' and 'STAT' buttons are activated.

classification.txt

The txt files are written as shown in the picture above. One is used in the INFO, RECORD, and STAT screens, and the other is used in the HISTORY and HISTORY2 screens. Up to 30 txt files used in HISTORY and HISTORY2 are stored, and more are stored in place of the oldest file.

🟠 INFO

INFO1

When you click the 'INFO' button on the MAIN screen before classifying, this screen appears.

INFO2 SOURCE1

When you click the image in the table below, the pros, cons and improvement information of that sleep position are displayed in a dialog window. When you click the 'SOURCE' button, you can see the sources for the images and information.

INFO3

When you click the 'INFO' button on the MAIN screen after classifying, the classified classes are displayed at the top, and the classe names written in the table are changed to bold.

🟑 RECORDS

RECORDS1 RECORDS2

When you click 'RECORDS' button on the MAIN screen after classifying, you can see the image extracted for each frame and the classification class of the image. If you click any image, the image will be enlarged in the center of the screen.

🟒 HISTORY2 (RECORDS)

HISTORY2_RECORDS

When you click 'HISTORY2' button on the RECORDS screen, you should choose one txt file. After that, the classification information in the selected txt file is output as if displayed on the RECORDS screen.

πŸ”΅ STAT

STAT1 STAT2 STAT3

When you click 'STAT' button on the MAIN screen after classifying, you can see the most classified class and representative image, a chart of changes in sleep position over time, and a chart of sleep position percentage indicators.

🟣 HISTORY (STAT)

HISTORY_STAT

Like the HISTORY2 screen, when you click 'HISTORY' button on the STAT screen, you should choose one txt file. After that, the classification information in the selected txt file is output as if displayed on the STAT screen.