This repository corresponds to the PyTorch implementation of our model for calculating SHAPE score.
Install Python >= 3.5 Install Cuda >= 9.0 and cuDNN Install PyTorch >= 0.4.1 with CUDA (Pytorch 1.x is also supported).
Install SpaCy and initialize the GloVe as follows:
$ pip install -r requirements.txt
$ wget https://github.com/explosion/spacy-models/releases/download/en_vectors_web_lg-2.1.0/en_vectors_web_lg-2.1.0.tar.gz -O en_vectors_web_lg-2.1.0.tar.gz
$ pip install en_vectors_web_lg-2.1.0.tar.gz
This dataset is from the work https://github.com/jbdel/MOSEI_UMONS
, who took more pre-precessing for the original dataset. You can Download it from here
This dataset can be download from here.
This dataset can be download from here
We also provide the processed data to help quickly implement our code. The processed data can be download as follows:
- Baidu Driver. Code:
qnwy
- Google Driver
Finally, the datasets
folders will have the following structure
|-- datasets
|-- MOSEI
| |-- train_mels.p
| |-- train_sentences.p
| |-- train_sentiment.p
| |-- valid_mels.p
| |-- valid_sentences.p
| |-- valid_sentiment.p
| |-- test_mels.p
| |-- test_sentences.p
| |-- test_sentiment.p
| |-- key_list (Processed Data)
|-- T4SA
| |-- b-t4sa_train.txt
| |-- b-t4sa_val.txt
| |-- b-t4sa_test.txt
| |-- data (images)
| |-- raw_tweets_text.csv
| |-- t4sa_text_sentiment.tsv
| |-- data_pro (Processed Data)
|-- SNLI
| |-- flickr30 (images)
| |-- vsnli
| | |-- VSNLI_1.0_train.tsv
| | |-- VSNLI_1.0_dev.tsv
| | |-- VSNLI_1.0_test_hard.tsv
| | |-- VSNLI_1.0_test.tsv
| |-- token (Processed Data)
The following script will start training with the default hyperparameters:
$ python train.py --model= "Dynamic" --dataset= "T4sa" --root_dir="/xx"
--model=str
, e.g. Dynamic', 'Dense', 'Late','Early'--dataset=str
, e.g. 'T4sa', 'Mosei', 'SNLI'
Other setting can be found in the trian.py
script.
Here we provede two scripts evaluate.py
and evaluate_perceptual.py
, which can be used to calculate the sub-factor of SHAPE Score.
You can get `accuracy' and the 'accuracy' of zero-padded input for a specific modality through:
$ python evaluate.py --model="Dynamic" --dataset= "T4sa"
Then you can calculate the finaly Shape score through those ouput accuracy
, following the description of our paper.
To get in-class
and out-class
version of the Perceptual Score
:
$ python evaluate_perceptual --model="Dynamic" --dataset="T4sa" --average_number=10