Upload README.md with huggingface_hub
Browse files
README.md
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# DLF: Disentangled-Language-Focused Multimodal Sentiment Analysis, AAAI 2025.
|
2 |
+
|
3 |
+
### [Arxiv Paper](https://arxiv.org/abs/2412.12225)
|
4 |
+
|
5 |
+
## Main Contributions
|
6 |
+
|
7 |
+
Our main contributions can be summarized as follows:
|
8 |
+
|
9 |
+
- **Proposed Framework:** In this study, we propose a Disentangled-Language-Focused (DLF) multimodal representation learning framework to promote MSA tasks. The framework follows a structured pipeline: feature extraction, disentanglement, enhancement, fusion, and prediction.
|
10 |
+
- **Language-Focused Attractor (LFA):** We develop the LFA to fully harness the potential of the dominant language modality within the modality-specific space. The LFA exploits the language-guided multimodal cross-attention mechanisms to achieve a targeted feature enhancement ($X$->Language).
|
11 |
+
- **Hierarchical Predictions:** We devise hierarchical predictions to leverage the pre-fused and post-fused features, improving the total MSA accuracy.
|
12 |
+
|
13 |
+
|
14 |
+
## Usage
|
15 |
+
|
16 |
+
### Prerequisites
|
17 |
+
- Python 3.9.13
|
18 |
+
- PyTorch 1.13.0
|
19 |
+
- CUDA 11.7
|
20 |
+
|
21 |
+
### Installation
|
22 |
+
- Create a conda environment. Please make sure you have installed conda before.
|
23 |
+
```
|
24 |
+
conda create -n DLF python==3.9.13
|
25 |
+
```
|
26 |
+
- Activate the built DLF environment.
|
27 |
+
```
|
28 |
+
conda activate DLF
|
29 |
+
```
|
30 |
+
- Install Pytorch with CUDA
|
31 |
+
```
|
32 |
+
pip install torch==1.13.0+cu117 torchvision==0.14.0+cu117 torchaudio==0.13.0 --extra-index-url https://download.pytorch.org/whl/cu117
|
33 |
+
```
|
34 |
+
- Clone this repo.
|
35 |
+
```
|
36 |
+
git clone https://github.com/pwang322/DLF.git
|
37 |
+
```
|
38 |
+
- Install the necessary packages.
|
39 |
+
```
|
40 |
+
cd DLF
|
41 |
+
pip install -r requirements.txt
|
42 |
+
```
|
43 |
+
|
44 |
+
### Datasets
|
45 |
+
Data files (containing processed MOSI, MOSEI datasets) can be downloaded from [here](https://drive.google.com/drive/folders/1BBadVSptOe4h8TWchkhWZRLJw8YG_aEi?usp=sharing).
|
46 |
+
You can first build and then put the downloaded datasets into `./dataset` directory and revise the path in `./config/config.json`. For example, if the processed the MOSI dataset is located in `./dataset/MOSI/aligned_50.pkl`. Please make sure "dataset_root_dir": "./dataset" and "featurePath": "MOSI/aligned_50.pkl".
|
47 |
+
Please note that the meta information and the raw data are not available due to the privacy of YouTube content creators. For more details, please follow the [official website](https://github.com/ecfm/CMU-MultimodalSDK) of these datasets.
|
48 |
+
|
49 |
+
### Run the Codes
|
50 |
+
- Training
|
51 |
+
|
52 |
+
You can first set the training dataset name in `./train.py` as "mosei" or "mosi", and then run:
|
53 |
+
```
|
54 |
+
python3 train.py
|
55 |
+
```
|
56 |
+
By default, the trained model will be saved in `./pt` directory. You can change this in `train.py`.
|
57 |
+
|
58 |
+
- Testing
|
59 |
+
|
60 |
+
You can first set the testing dataset name in `./test.py` as "mosei" or "mosi", and then test the trained model:
|
61 |
+
```
|
62 |
+
python3 test.py
|
63 |
+
```
|
64 |
+
We also provide pre-trained models for testing. ([Google drive](https://drive.google.com/drive/folders/1GgCfC1ITAnRRw6RScGc7c2YUg5Ccbdba?usp=sharing))
|
65 |
+
|
66 |
+
#### 🤗 Option 2: Load Pretrained Models from Hugging Face Hub
|
67 |
+
|
68 |
+
We also release pre-trained models on Hugging Face for direct use:
|
69 |
+
|
70 |
+
```
|
71 |
+
from trains.singleTask.model.DLF import DLF
|
72 |
+
model = DLF.from_pretrained("Peter180/DLF_mosei") # or "Peter180/DLF_mosi"
|
73 |
+
```
|
74 |
+
|
75 |
+
### Citation
|
76 |
+
If you find the code and our idea helpful in your research or work, please cite the following paper.
|
77 |
+
|
78 |
+
```
|
79 |
+
@article{wang2024dlf,
|
80 |
+
title={DLF: Disentangled-Language-Focused Multimodal Sentiment Analysis},
|
81 |
+
author={Wang, Pan and Zhou, Qiang and Wu, Yawen and Chen, Tianlong and Hu, Jingtong},
|
82 |
+
journal={arXiv preprint arXiv:2412.12225},
|
83 |
+
year={2024}
|
84 |
+
}
|
85 |
+
```
|
86 |
+
|
87 |
+
|
88 |
+
|
89 |
+
|