자세교정 웹페이지 - 클래스별 label 내용 다르게 해주기

neulilanikka·2022년 11월 26일
0

프로젝트(Project)

목록 보기
12/27


다음과 같이 티쳐블머신을 사용하고 label의 내용을 달리 하고 싶다고요?????

그렇다면 코드 수정이 답입니다

늘 그랬듯 ^^

async function predict() {
        // Prediction #1: run input through posenet
        // estimatePose can take in an image, video or canvas html element
        const { pose, posenetOutput } = await model.estimatePose(webcam.canvas);
        // Prediction 2: run input through teachable machine classification model
        const prediction = await model.predict(posenetOutput);

        for (let i = 0; i < maxPredictions; i++) {
            const classPrediction =
                prediction[i].className + ": " + prediction[i].probability.toFixed(2);

		    if(prediction[0].probability.toFixed(2)==1.00){
                labelContainer.childNodes[0].innerHTML = "바른 자세입니다. 지금 자세를 유지하세요.";
                }
            else if(prediction[1].probability.toFixed(2)==1.00){
                labelContainer.childNodes[0].innerHTML = "얼굴이 오른쪽으로 기울었습니다. 바른 자세를 유지하세요.";
                //alert('바른자세를 유지하세여');
                }
            else if(prediction[2].probability.toFixed(2)==1.00){
                labelContainer.childNodes[0].innerHTML = "얼굴이 왼쪽으로 기울었습니다. 바른 자세를 유지하세요.";
                }
            else if(prediction[3].probability.toFixed(2)==1.00){
                labelContainer.childNodes[0].innerHTML = "거북목 자세입니다. 바른 자세를 유지하세요.";
                }
            else if(prediction[4].probability.toFixed(2)==1.00){
                labelContainer.childNodes[0].innerHTML = "오른쪽 어깨가 올라갔습니다. 바른 자세를 유지하세요.";
                }
            else if(prediction[5].probability.toFixed(2)==1.00){
                labelContainer.childNodes[0].innerHTML = "왼쪽 어깨가 올라갔습니다. 바른 자세를 유지하세요.";
                }
        }

        // finally draw the poses
        drawPose(pose);
    }
profile
Now: Mobile Developer

0개의 댓글

관련 채용 정보