논문 #8. CNN을 이용한 emotion detector
데이터는 다음 링크의 데이터를 사용함.
DATASET
The dataset consists of 48x48 pixel grayscale images of faces. The faces have been automatically registered so that the face is more or less centered and occupies about the same amount of space in each image. Each face is based on the emotion shown in the facial expression in one of seven categories (Angry, Disgust, Fear, Happy, Sad, Surprise, Neutral).
The training set consists of 28,708 images and the test set consists of 7,178 images. Compressed version of the dataset takes 92 MB space whereas uncompressed version takes 140 MB space.
This dataset was prepared by Pierre-Luc Carrier and Aaron Courville for the Facial Expression Recognition
https://github.com/katoch99/Emotion-Recognition
[GitHub - katoch99/Emotion-Recognition: The project titled “Emotion Recognition using Keras” has been developed to use Convol
The project titled “Emotion Recognition using Keras” has been developed to use Convolutional Neural Networks (CNNs) to detect the emotion state of the human. A data set of different facial expressi...
github.com](https://github.com/katoch99/Emotion-Recognition)
참고
[EMOTION DETECTOR USING KERAS — WITH SOURCE CODE — EASIEST WAY — EASY IMPLEMENTATION
So guys in today’s blog we will be building an Emotion Detector model in Keras using Convolutional Neural Networks. This is one of my…
Colab GPU 사용
결국 Pro 구매해버림..
시간도 너무 오래걸리고 이미지가 많아서 아마 학습하는데 시간이 엄청 소요될 것으로 예상함.
드라이브 연결해서 dataset.zip 업로드하는데 드는 시간만 해도 20분걸림..
모델 구조:
- 입력층 (Input Layer):
- 입력 이미지의 크기는 (48 \times 48) 픽셀이며 흑백 이미지이기 때문에 채널 수는 1입니다. 따라서 입력 텐서의 형태는
(48, 48, 1)
입니다.
- 입력 이미지의 크기는 (48 \times 48) 픽셀이며 흑백 이미지이기 때문에 채널 수는 1입니다. 따라서 입력 텐서의 형태는
- 합성곱 계층 (Convolutional Layer) 1:
- 필터 개수: 64
- 필터 크기: (3 \times 3)
- 활성화 함수 (Activation): ReLU
- 패딩 (Padding): 같음 (Same)
- 배치 정규화 (Batch Normalization) 포함
- 풀링 계층 (Pooling Layer) 1:
- 풀링 유형: 최대 풀링 (Max Pooling)
- 풀링 크기: (2 \times 2)
- 드롭아웃 (Dropout): 비율 0.25
- 합성곱 계층 2:
- 필터 개수: 128
- 필터 크기: (5 \times 5)
- 활성화 함수: ReLU
- 패딩: 같음
- 배치 정규화 포함
- 풀링 계층 2와 같은 드롭아웃 구조 반복
- 합성곱 계층 3:
- 필터 개수: 256
- 필터 크기: (3 \times 3)
- 활성화 함수: ReLU
- 패딩: 같음
- 배치 정규화 포함
- 풀링 계층 3와 같은 드롭아웃 구조 반복
- 합성곱 계층 4:
- 필터 개수: 512
- 필터 크기: (3 \times 3)
- 활성화 함수: ReLU
- 패딩: 같음
- 배치 정규화 포함
- 풀링 계층 4와 같은 드롭아웃 구조 반복
- 평탄화 계층 (Flatten Layer)
- 밀집층 (Dense Layer) 1:
- 유닛 개수: 256
- 활성화 함수: ReLU
- 배치 정규화 포함
- 드롭아웃: 비율 0.25
- 밀집층 2:
- 유닛 개수: 512
- 활성화 함수: ReLU
- 배치 정규화 포함
- 드롭아웃: 비율 0.25
- 출력층 (Output Layer):
- 유닛 개수: 7 (각 감정 라벨링에 해당)
- 활성화 함수: Softmax
모델은 주로 합성곱 계층, 배치 정규화, 활성화 함수, 풀링 계층, 및 드롭아웃으로 구성되어 있습니다. 이러한 구조를 통해 이미지 내의 지역적 특징들을 추출하고, 과적합을 방지하며, 감정 분류를 수행합니다.
1차 결과
Model 재설정
https://github.com/katoch99/Emotion-Recognition/blob/master/Emotion%20Recognition.ipynb
이미지속 얼굴 표정을 세세하게 디텍트할 수 있는 충분한 층이 없었다. 그리고 파라미터수도 현저히 작았기에 더 큰 모델을을 짜보았다.
같은 데이터셋을 Convolution2D 을 높이고 epoch=15로 돌려보았다. acc도 0.7 가까이 상승하고있고, Loss 또한 줄어드는 것을 확인할 수 있다.
Acc를 늘려보자.
epoch=40
거기서 거기이군.
+-------------+-------+--------------+--------+--------------+---------+------------+
| | Image size | Learning rate | Epochs | Loss (Train) | Accuracy (Train) | Loss (Test) | Accuracy (Test) |
+-------------+-------+--------------+--------+--------------+---------+------------+
| Value | 48x48 | 0.0005 | 40 | 0.941 | 64.4% | 0.997 | 63.2% |
+-------------+-------+--------------+--------+--------------+---------+------------+