LMR-CL : Learning Modality-Fused Representations with Contrastive Loss for Multimodal Emotion Recognition
- Duration: 2023.02 ~ 2023.07
- Role: Project Leader, Text Feature Extraction, Contrastive Loss Design & Modeling
- Tech Stack:
Pytorch,HuggingFace - Results & Awards:
- Overview: A deep-learning-based emotion recognition model that classifies 7 emotions (including neutral) from multimodal data -- text, audio, and biosignals -- collected during free conversation between two speakers using the KEMDy20 dataset. We propose Intra-modal and Inter-modal Contrastive Losses to align multimodal representations and achieved the highest macro F1-score in the competition.
- Press: **[news1] [news2] [news3]**
The "Han Hye-sung" team, composed of students from the Graduate School of Software Convergence at Kyung Hee University, won the Minister of Science and ICT Award at the '2nd ETRI Human Understanding AI Paper Competition' held by the Electronics and Telecommunications Research Institute (ETRI).
(link : https://www.gttkorea.com/news/articleView.html?idxno=5685)
LMR-CL/
├── config.py # Configuration and hyperparameters (CLI arguments)
├── utils.py # Utility functions and custom loss modules (DiffLoss, CMD, IAMC, IEMC, F1_Loss)
├── dataloader.py # PyTorch Dataset & DataLoader for BERT and WAV modalities
├── train.py # Unified training entry point (supports --finetuning flag)
├── models/ # Model architectures
│ ├── bert.py # LMR model (Text + Biosignal + Acoustic with contrastive loss)
│ └── wav.py # Wav2Vec2-based audio classification model
├── solvers/ # Training and evaluation logic
│ ├── solver_bert.py # Solver for text (BERT) modality training
│ └── solver_wav.py # Solver for audio (WAV) modality training
├── Data/ # Data preprocessing and dataset creation
│ ├── create_dataset.py # KemDY20 dataset builder (bert/wav/wav_finetuning)
│ └── preprocess/
│ └── bio_feature_extractor.py # Biosignal feature extraction pipeline
├── checkpoints/ # Saved model checkpoints
├── environment.yml # Conda environment specification
├── LICENSE # MIT License
└── README.md
Key changes from previous structure:
- Single-file folders (
config/,utils/,dataloaders/) were flattened to root-level scripts (config.py,utils.py,dataloader.py). - The
train/folder (with separate scripts for wav, wav_finetuning, and bert) was merged into a singletrain.pywith a--finetuningflag. solver_wav_finetuning.pywas merged intosolver_wav.py.previous_code_files/(legacy code) was removed.- Import paths were simplified (e.g.,
from config import get_configinstead offrom config.config import get_config).
- Conda (Miniconda or Anaconda)
- Python 3.7+
- CUDA 10.1 (for GPU-enabled training)
- Clone the repository:
git clone https://github.com/hannn0403/LMR-CL.git cd LMR-CL - Create the Conda environment:
conda env create -f environment.yml conda activate lmr_cl
- Download the KEMDy20_v1_1 dataset and place it in the
Data/directory:Data/ └── KEMDy20_v1_1/ ├── audio/ ├── text/ └── biosignal/ config.pywill look for this path by default; adjust--data_dirif your directory differs.
All hyperparameters and experiment settings are defined via CLI arguments in config.py. Key options include:
--mode [train|eval] # Run mode
--data kemdy20 # Dataset name
--use_bert True # Enable text modality
--use_cmd_sim True # Use contrastive similarity loss
--batch_size 256
--n_epoch 3
--learning_rate 1e-4
--optimizer Adam
--activation relu
--diff_weight 0.1 # Contrastive loss weight
--recon_weight 0.3 # Reconstruction loss weightTo view all options:
python -c "from config import get_config; get_config(parse=True)"python train.py \
--mode train \
--data kemdy20 \
--name wav_experimentpython train.py --finetuning \
--mode train \
--data kemdy20 \
--name wav_ft_experimentBERT training is handled directly through the solver:
python solvers/solver_bert.py \
--mode train \
--data kemdy20 \
--use_bert True \
--name bert_experimentCheckpoints will be saved under checkpoints/<experiment_name>/.
Use the corresponding solver to evaluate on the validation/test split:
# BERT evaluation
python solvers/solver_bert.py \
--mode eval \
--load_checkpoint checkpoints/bert_experiment/best_model.pth
# WAV evaluation
python solvers/solver_wav.py \
--mode eval \
--load_checkpoint checkpoints/wav_experiment/best_model.pthThis project is licensed under the MIT License. See the LICENSE file for details.
- Paper: Han et al., Learning Modality-Fused Representations with Contrastive Loss for Multimodal Emotion Recognition.
- Competition: Minister of Science and ICT Award, 2nd ETRI Human Understanding AI Paper Competition.
- Dataset: KEMDy20