[캡스톤] 솔루션 1 - 제스처 인식부

이정연·2023년 5월 4일
0

Project

목록 보기
9/11

본 포스팅은 캡스톤 프로젝트의 [제스처 인식부] 리뷰입니다.

미디어파이프 hands란?

미디어파이프에는 객체 탐지를 위한 다양한 라이브러리를 제공하는데 우리 프로젝트는 제스처 인식이 목표다.

따라서, 손을 탐지할 도구가 필요했고 미디어파이프의 여러가지 카테고리중 손을 인식해주는 도구가 바로 hands solution이다.

설명

손을 21개의 2차원 텐서(x,y)로 나타낸다.

각각의 제스처마다 이 21개의 좌표값들이 달라질테니 우리는 이 값들을 통해 어떠한 제스처인지 판단할 수 있다.
(정확히 말하면 이것을 컴퓨터에게 알려줘 제스처 학습을 시킨다 😊)

제스처 학습

  • 텐서플로우 사용
  • None ➡️ 0으로 처리
  • 45프레임을 단위로 학습
  • 두 벡터간 각도로 분류 / 데이터 개수 = 15
  • 학습 모델 = DNN
  • 45프레임중 0.999의 confidence의 제스처가 30프레임 동안 동일할 경우 제스처 입력으로 간주
  • 제스처 선정 기준: 한국 수어 사전

모델

from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import LSTM, Dense

model = Sequential([
    Dense(64, activation='relu', input_shape = x_train.shape[1:2]),
    Dense(len(actions), activation='softmax')
])

model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['acc'])
model.summary()
  • 활성화 함수: relu
  • 최종 출력: softmax
  • optimizer: adam
  • 손실 함수: categorical_crossentropy
  • 기준: accuracy

다중 분류 문제이기 때문에 소프트맥스와 categorical 손실 함수를 사용했다.

from tensorflow.keras.callbacks import ModelCheckpoint, ReduceLROnPlateau
import time
created_time = int(time.time())
history = model.fit(
    x_train,
    y_train,
    validation_data=(x_val, y_val),
    epochs=1000,
    callbacks=[
        ModelCheckpoint('models/model_{created_time}.h5', monitor='val_loss', verbose=1, save_best_only=True, mode='auto'),
        ReduceLROnPlateau(monitor='val_acc', factor=0.5, patience=50, verbose=1, mode='auto')
    ]
)

에포크 1000번으로 학습 진행

profile
0x68656C6C6F21

0개의 댓글