This repository contains code for detecting hate speech in videos and memes using multimodal architectures. The project includes Simple Embedding Fusion (aka Simple Fusion) and MO-Hate architectures.
- Dataset
- Installation
- Preprocessing
- Running Simple Fusion Experiments
- Running MO-Hate Architecture Experiments
- Testing on Specific Videos/Memes
The datasets used in this project are HateMM and Hateful Memes. You can download it from the following link:
- HateMM Dataset
- Hateful Memes Dataset on Kaggle or Hugging Face
To install the necessary packages, run the following command:
pip install -r requirements.txt
Before running the experiments, you need to preprocess the dataset to extract features. The preprocessing scripts are located in the Preprocessing/
directory. Make sure to specify the correct path to the downloaded datasets in the below code files.
-
Video Frames and Audio Transcript:
python Preprocessing/frameExtract.py
and then
python Preprocessing/WhisperTranscript.py
-
Audio Features:
python Preprocessing/AudioMFCC_Features.py
or
python Preprocessing/CLAP_and_Wav2Vec2_features.py
-
Text Features:
python Preprocessing/BERT_HXP_Embeddings.py
-
Image Features:
python Preprocessing/CLIP_image_features.py
or
python Preprocessing/DINOv2_image_features.py
or
python Preprocessing/ViT_Memes_Features.py
-
Video Features:
python Preprocessing/ViT_VideoFrame_Features.py
The Simple Fusion architecture experiments are implemented in the Simple Fusion/
directory. To run the simple fusion experiments, follow these steps:
-
Train the Simple Fusion Model on HateMM:
python Simple-Fusion/HateMM_Fusion.py
-
Train the Simple Fusion Model on Hateful Memes:
python Simple-Fusion/HateMemesFusion.py
The MO-Hate architecture experiments are implemented in the MO-Hate/
directory. To run these experiments, follow these steps:
-
Train the MO-Hate Model on HateMM:
python MO-Hate/main.py
-
Train the MO-Hate Model on Hateful Memes:
python MO-Hate/memes.py
For testing either on random or specific images from the test set, follow these steps:
Load the trained model and run the file:
python test_videos.py
or
python test_memes.py
Note: Some parts of the preprocessing and training codes for Simple Embedding Fusion and MO-Hate have been taken from their respective GitHub repositories. Please refer to the following links for more details: