Downloads · 30 days
0
leeChaerin/FER-2013-CNN-70.7Acc
FER-2013-CNN-70.7Acc is a image classification model from leeChaerin. Use it when you need a label for an image. The card lists the license as mit.
이 모델은 7가지 사람의 감정(표정)을 분류하기 위해 설계된 커스텀 VGG 스타일 합성곱 신경망(CNN) 모델입니다. 다양한 하이퍼파라미터 튜닝과 스케줄러 실험을 통해 최적화되었으며, 추가 데이터 학습 없이 Kaggle FER-2013 데이터셋 만으로 검증 데이터셋에서 "70.55%"의 정확도를 달성했습니다.
Downloads · 30 days
0
Access
Public
Updated Dec 8, 2025
Repo size
162 MB
Likes
0
Public
Click a slice to open those files.
.py162 MB · 100%
From the Hugging Face model README
이 모델은 7가지 사람의 감정(표정)을 분류하기 위해 설계된 커스텀 VGG 스타일 합성곱 신경망(CNN) 모델입니다. 다양한 하이퍼파라미터 튜닝과 스케줄러 실험을 통해 최적화되었으며, 추가 데이터 학습 없이 Kaggle FER-2013 데이터셋 만으로 검증 데이터셋에서 "70.55%"의 정확도를 달성했습니다.
이 모델은 48x48 크기의 작은 이미지를 효과적으로 처리하기 위해 VGG 네트워크를 경량화하여 설계했습니다.
(Conv -> BN -> ReLU) x 2 -> MaxPool 구조가 4번 반복되며 이미지의 특징을 깊이 있게 추출합니다.여러 초기 학습률(Learning Rate)과 스케줄러 설정을 비교 실험하여 최적의 값을 찾았습니다.
| 지표 (Metric) | 점수 (Score) | 비고 |
|---|---|---|
| 검증 정확도 (Val Accuracy) | 70.55% | Best Model |
| Patience 설정 | 3 | ReduceLROnPlateau 최적값 |
| 초기 학습률 (Initial LR) | 0.04 | 실험결과 가장 높은 성능 기록 |
💡 실험 노트: 초기 학습률을 0.01~0.05 사이에서 실험한 결과 0.04에서 가장 높은 성능을 보였으며,
ReduceLROnPlateau스케줄러의 Patience를 3으로 설정했을 때 학습 정체 구간을 가장 효율적으로 돌파하며 Global Minimum에 도달했습니다.
ReduceLROnPlateau (mode='max', factor=0.1, patience=3, min_lr=1e-6)PyTorch를 사용하여 모델을 로드하고 추론하는 예시 코드입니다.
import torch
import torch.nn as nn
import torch.nn.functional as F
from torchvision import transforms
from PIL import Image
# 1. 모델 클래스 정의 (학습 코드와 동일)
class Vgg(nn.Module):
def __init__(self, drop=0.2):
super().__init__()
# ... (모델 코드 생략, 학습 코드의 class Vgg 복사해서 넣으세요) ...
# (Github에는 전체 코드를 파일로 올리는 것이 좋습니다)
# 2. 모델 불러오기
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = Vgg()
# Hugging Face 또는 로컬에서 가중치 로드
# model.load_state_dict(torch.load("pytorch_model.pth", map_location=device))
model.to(device)
model.eval()
# 3. 이미지 추론 예시
def predict_emotion(image_path):
# 학습 때와 동일한 전처리 적용
transform = transforms.Compose([
transforms.Resize((48, 48)),
transforms.Grayscale(num_output_channels=1),
transforms.ToTensor(),
transforms.Normalize((0.5,), (0.5,))
])
image = Image.open(image_path)
image = transform(image).unsqueeze(0).to(device)
with torch.no_grad():
output = model(image)
_, predicted = torch.max(output, 1)
emotions = ['Angry', 'Disgust', 'Fear', 'Happy', 'Sad', 'Surprise', 'Neutral']
return emotions[predicted.item()]
# print(predict_emotion("test_face.jpg"))