
감정 분류
(val)
Emotion Count: Counter({'surprise': 300, 'neutral': 300, 'fear': 300, 'disgust': 300, 'sad': 300, 'angry': 300, 'happy': 300})
Emotion Ratio: {'surprise': 0.14285714285714285, 'neutral': 0.14285714285714285, 'fear': 0.14285714285714285, 'disgust': 0.14285714285714285, 'sad': 0.14285714285714285, 'angry': 0.14285714285714285, 'happy': 0.14285714285714285}
(train)
Emotion Count: Counter({'neutral': 1500, 'fear': 1500, 'disgust': 1500, 'sad': 1500, 'angry': 1500, 'surprise': 1499, 'happy': 1495})
Emotion Ratio: {'surprise': 0.14284352963598246, 'happy': 0.14246235944349153, 'neutral': 0.1429388221841052, 'fear': 0.1429388221841052, 'disgust': 0.1429388221841052, 'sad': 0.1429388221841052, 'angry': 0.1429388221841052}
(test)
Emotion Count: Counter({'surprise': 300, 'neutral': 300, 'fear': 300, 'disgust': 300, 'happy': 300, 'sad': 300, 'angry': 300})
Emotion Ratio: {'surprise': 0.14285714285714285, 'neutral': 0.14285714285714285, 'fear': 0.14285714285714285, 'disgust': 0.14285714285714285, 'happy': 0.14285714285714285, 'sad': 0.14285714285714285, 'angry': 0.14285714285714285}
성별 연령 인종 분류
(val)
Gender Count: Counter({'F': 1368, 'M': 1232})
Gender Ratio: {'M': 0.47384615384615386, 'F': 0.5261538461538462}
Age Count: Counter({1: 1917, 2: 526, 0: 157})
Age Ratio: {2: 0.2023076923076923, 1: 0.7373076923076923, 0: 0.060384615384615384}
Race Count: Counter({'oriental': 2183, 'other': 417})
Race Ratio: {'other': 0.16038461538461538, 'oriental': 0.8396153846153847}
(train)
Gender Count: Counter({'F': 7086, 'M': 6008})
Gender Ratio: {'F': 0.5411638918588667, 'M': 0.45883610814113335}
Age Count: Counter({1: 9514, 2: 2883, 0: 697})
Age Ratio: {0: 0.0532304872460669, 2: 0.22017718038796397, 1: 0.7265923323659691}
Race Count: Counter({'oriental': 10928, 'other': 2166})
Race Ratio: {'other': 0.16541927600427678, 'oriental': 0.8345807239957233}
(test)
Gender Count: Counter({'F': 1410, 'M': 1190})
Gender Ratio: {'M': 0.4576923076923077, 'F': 0.5423076923076923}
Age Count: Counter({1: 1900, 2: 571, 0: 129})
Age Ratio: {0: 0.04961538461538462, 2: 0.21961538461538463, 1: 0.7307692307692307}
Race Count: Counter({'oriental': 2184, 'other': 416})
Race Ratio: {'other': 0.16, 'oriental': 0.84}
class EmotionDataset(Dataset):
def __init__(self, json_file, image_dir, transform=None):
# JSON 파일 로드
with open(json_file, 'r') as f:
self.annotations = json.load(f)
self.image_dir = image_dir
self.transform = transform
# 감정 라벨 맵핑
self.emotion_mapping = {
"neutral": 0,
"happy": 1,
"sad": 2,
"surprise": 3,
"fear": 4,
"disgust": 5,
"angry": 6
}
model = DDAMNet(num_class=7, num_head=2, pretrained=True).to(device)
# 손실 함수와 옵티마이저 정의
criterion = nn.CrossEntropyLoss()
optimizer = optim.Adam(model.parameters(), lr=1e-4)
# 학습률 스케줄러 설정
scheduler = optim.lr_scheduler.StepLR(optimizer, step_size=5, gamma=0.1)

part1, part2.. 순서대로 있으면 subprocess.run()의 'e'를 사용하여서 원하는 목록만 압축해제 할 수 있다.
스케줄러
학습률 스케줄러(Learning Rate Scheduler)는 모델을 학습할 때 학습률(learning rate을 동적으로 조정해주는 기법
스케줄러 사용이유
효율적 학습: 초반에는 학습률을 크게 설정해 빠르게 수렴하도록 하다가, 학습이 진행됨에 따라 학습률을 점차 작게 줄여서 더 안정적인 수렴을 유도합니다.
오버슈팅 방지: 학습률이 계속 크다면 최적점을 지나쳐 버릴 수 있으므로, 학습을 마무리할 때 학습률을 줄여서 정확한 최적점을 찾습니다.
과적합 방지: 학습 후반부에서 학습률을 줄이면 과적합을 줄이는 데 도움이 됩니다.
scheduler = optim.lr_scheduler.StepLR(optimizer, step_size=5, gamma=0.1)
import os
print("작업이 완료되었습니다. 런타임을 해제합니다.")
os._exit(0)