Skip to the content.

← go back to the list

APT (AI Personal Trainer)

WELCOME TO AI-FITNESS FRIEND
YOUR PERSONAL AI TRAINING ASSITANT


Member

Jemin Rhee, Minsik Kim, Inseon Choi, Jun Park






Background

1) Problems


1.1) Due to the COVID-19, there are problems with fitness and outdoor exercise. It is difficult to exercise in the public indoor space and feels uncomfortable to exercise outdoors which requires contact with other people.

This data is the result of <Awareness Survey on the Relationship between COVID-19 and Exercise> conducted in December 2020 by the market research company, Embrain Trend Monitor. (For 1,000 men and women aged 19 to 59)

Exercise survey results with difficulties due to COVID-19 (Embrain, 2020)

As you can see from the results of the survey, it was confirmed that COVID-19 significantly increased people’s fear and discomfort about indoor fitness and outdoor exercise that need to do with a partner.

1.2) People’s new lifestyle and effects of COVID-19 increase interest in Home Training.

Increasing the amount of social mentions and consumer counseling related to home training (Korea Consumer Agency, 2021)

Consumer’s interest in Home Training is increasing, and as a result, needs for various new Home Training services is also increasing. In this situation, we want to provide an interesting home training service through AI, voice functions, and additional interactions.


2) Target User

1) People who often exercise at home
2) People who cannot go to the gym due to COVID-19
3) People who need help because they do not know how to exercise alone (ex. exercise routine, correct posture…)
4) People who are bored when exercising alone at home or need fun elements (motivation)


3) Goal

App Goal
AI-FITNESS FRIEND (AFF)’s goal is to help our users when they have difficulty doing fitness, training, or doing exercise. To be specific, we want to offer a personalized fitness training that can be done anytime, anywhere. It can guide our users full body posture information, which shows the exact current posture of their exercises, especially sit-ups, push-ups, squats, and lunges.

  1. Be active and healthy with AI-Fitness Friend (AFF)
  2. AI-FITNESS FRIEND (AFF) can make home fitness highly effective and can provide you a great motivation
  3. AI-FITNESS FRIEND (AFF) can give you guidance for your exercise posture and motions

Our Goal Throughout this semester, we want to build an application - AI-FITNESS FRIEND - that can check a user’s body posture. As people accelerate more into more digital forms of fitness guide, our application is expected to become more increasingly relevant. Users can use their computer or smartphone camera to recognize their exercise postures and movements, while this app can guide you through the correct postures with voice helpers. Whether your fitness goals are to build muscle, get toned or lose weight fast, AI-FITNESS FRIEND Training will be the simplest way to do fitness training exercises.


Main Contents

1) Modeling

Good Image for Modeling(LEFT)

Bad Image for Modeling(RIGHT)


</br>

System Modeling Design


</br>

2) Demo Video

3) Screens Definition

Before starting the exercise, a user can select the language of the ‘voice’ that is used in the service. (Korean/English).

Allows the user to select the concept of AI trainer voice from multiple concepts (e.g. sweet, scary, swearing version).

Allows the user to select the exercise method and exercise routines. Method selection: (set or individual) exercise. Routine selection: exercise course selections.


Allows the user to select the type of full body workouts.


Allows the user to select the partial exercise.


When the user select full body workout, it guides the exercise routines. There is the ‘Start’ button on the bottom


AI-FITNESS FRIEND counts the number when the user is doing the exercise. Check exercise postures. AI-FITNESS FRIEND ensures that the user is performing the selected exercise in the correct position. Correct exercise postures.


After the user reaches to the goal number of repetitions, it automatically redirects to the encouraging message page before the result page. The user can select whether go back to the homepage or do workout more. (*There is a background song playing in the encouraging message page.)


It shows exercise time, number of repetitions, and calories burned etc


On the screen, a user can see list of recommended exercises.


4) User test

Result
User’s Opinion :


</br>

Result
User’s Opinion :





Conclusion

Limitation

Jun Park:

  1. Due to time constraints, we could not implement more exercises postures. It was time consuming when we had to remove the dirty data because it could not detect our poses.

Future Plan

Review


Our Progress

Reference

Reference News

Source Code for LOADING A WORKOUT MODEL

코드 설명 #01

// the link to your model provided by Teachable Machine export panel
        const URL = "./models/SQUAT_MODEL/my-pose-model/";
        let model, webcam, ctx, labelContainer, maxPredictions;

        
        async function init() {
            const modelURL = URL + "model.json";
            const metadataURL = URL + "metadata.json";

            var audio = new Audio('./data/Voice/English/AreYouReady.mp3')
            audio.play()
            
            // load the model and metadata
            // Refer to tmImage.loadFromFiles() in the API to support files from a file picker
            // Note: the pose library adds a tmPose object to your window (window.tmPose)
            model = await tmPose.load(modelURL, metadataURL);
            maxPredictions = model.getTotalClasses();

            // Convenience function to setup a webcam
            const size = 500;  // WebCam Size
            const flip = true; // whether to flip the webcam
            webcam = new tmPose.Webcam(size, size, flip); // width, height, flip
            await webcam.setup(); // request access to the webcam
            await webcam.play();
            window.requestAnimationFrame(loop);

            // append/get elements to the DOM
            const canvas = document.getElementById("canvas");
            canvas.width = size; canvas.height = size;
            ctx = canvas.getContext("2d");
            labelContainer = document.getElementById("label-container");
            for (let i = 0; i < maxPredictions; i++) { // and class labels
                labelContainer.appendChild(document.createElement("div"));
            }
        }

Source Code for PREDICTING AND COUNTING

코드 설명 #02

// Prediction #1: run input through posenet
            // estimatePose can take in an image, video or canvas html element
            // GOOD POSTURE
            if (prediction[0].probability.toFixed(2) >= 0.90) {
                if (status == "squat") {
                    count++
                    var audio = new Audio('./data/Voice/한글/유학생/' + count%10 +'_유학생.mp3');
                    audio.play();

                    progress = progress-32.7
                    if(progress <= 0) {
                        progress = 327-32.7
                    }
                    $('.progress').css('stroke-dashoffset', progress);
                    $('#counter').html(count);

                    if((count >= 10) && (count % 10==0)){
                        var audio = new Audio('./data/Voice/English/VeryGood_UK.mp3')
                        audio.play()    
                    }
                }
                status = "stand"
            } else if (prediction[1].probability.toFixed(2) >= 0.90) {
                status = "squat"
            } 

            // BAD POSTURE
            if (prediction[2].probability.toFixed(2) >= 0.90) {
                if (count % 2 == 0){
                   if (count > 10){
                      covar audio = new Audio('./data/Voice/한글/유학생/한글_장난치세요.mp3');
                      audio.play();   
                   } else {
                      covar audio = new Audio('./data/Voice/한글/유학생/일본_장난치세요.mp3');
                      audio.play();   
                   }
                } else {
                   covar audio = new Audio('./data/Voice/한글/유학생/장난쳐_유학생.mp3');
                   audio.play();
                }
            }

            // QUIT
            if (prediction[3].probability.toFixed(2) >= 0.91) {
                await sleep(330);
                if (prediction[3].probability.toFixed(2) >= 0.90) {
                   if (count % 2 == 0){
                      var audio = new Audio('./data/Voice/한글/유학생/한글_열정없구나.mp3');
                      audio.play();
                  } else {
                     var audio = new Audio('./data/Voice/한글/유학생/일본_열정없구나.mp3');
                      audio.play();
                  }
                }
            }

            // MUSIC_PLAY
            if (prediction[4].probability.toFixed(2) >= 0.75) {
               await sleep(500);
                if (prediction[4].probability.toFixed(2) >= 0.80) {
                   var audio = new Audio('./data/Voice/HoldOn.mp3');
                   audio.play();
                }
            }

Source Code for DRAWING POSE ON WEB CAM

코드 설명 #03

function drawPose(pose) {
            if (webcam.canvas) {
                ctx.drawImage(webcam.canvas, 0, 0);
                // draw the keypoints and skeleton
                if (pose) {
                    const minPartConfidence = 0.5;
                    tmPose.drawKeypoints(pose.keypoints, minPartConfidence, ctx);
                    tmPose.drawSkeleton(pose.keypoints, minPartConfidence, ctx);
                }
            }
        }
        

Source Code for UPDATING

코드 설명 #04

// It lets a web page keeps update web cam frame
        async function loop(timestamp) {
            webcam.update(); // update the webcam frame
            await predict();
            window.requestAnimationFrame(loop);
        }

Source Code for TERMINATION CONDITION

코드 설명 #05

// When the user reaches the number of reps that the user set,
            // it directs to 'Result.html'
            if(document.getElementById("MaxRepHa").value == count){
                var audio = new Audio('./data/Voice/한글/유학생/고생했어요.mp3');
                audio.play();
                count++;
                location.replace("Result.html");
            }