--- language: en license: apache-2.0 # Or choose another appropriate license tags: - video-classification - violence-detection --- # Real Life Violence Detection Dataset This repository contains the "Real Life Violence Dataset" used for training video violence detection models, along with preprocessed versions. **Associated Model:** [ross-dev/violence-transformer](https://huggingface.co/ross-dev/violence-transformer) **Original Code Repository:** [ross-sec/violence-transformer](https://github.com/ross-sec/violence-transformer) ## Dataset Description The dataset consists of video clips categorized into two classes: "Violence" and "NonViolence". It includes real-world scenarios. Due to the nature of the content, user discretion is advised. ## Dataset Structure This repository contains two main ways to access the data: 1. **Raw Video Files:** * `Real Life Violence Dataset/Violence/`: Contains `.mp4`, `.avi`, etc., files depicting violent scenarios. * `Real Life Violence Dataset/NonViolence/`: Contains `.mp4`, `.avi`, etc., files depicting non-violent scenarios. 2. **Preprocessed NumPy Arrays:** * `features.npy`: A NumPy array containing sequences of preprocessed frames. Shape: `(num_videos, sequence_length, height, width, channels)`. * `labels.npy`: A NumPy array containing the corresponding labels (0 for NonViolence, 1 for Violence). Shape: `(num_videos,)`. * `video_files_paths.npy` (Optional): May contain paths to the original video files corresponding to the features/labels. ## Preprocessing (for `.npy` files) The `features.npy` and `labels.npy` files were generated using the `DatasetCreator` class within the associated model's training script (`train_transformer.py`). The process involves: * Extracting `SEQUENCE_LENGTH` (e.g., 16) frames evenly spaced throughout each video. * Resizing each frame to `IMAGE_HEIGHT` x `IMAGE_WIDTH` (e.g., 64x64). * Normalizing pixel values to the range [0, 1]. * Skipping videos that couldn't be processed or didn't have enough frames. Refer to the `DatasetCreator.frames_extraction` method in the [code repository](https://github.com/ross-sec/violence-transformer/blob/main/train_transformer.py) for the exact implementation details. ## How to Use * **With Raw Videos:** You can directly load and process the video files from the `Real Life Violence Dataset/` subdirectories using libraries like OpenCV or PyAV for custom preprocessing pipelines. * **With Preprocessed Features:** Load the `.npy` files using NumPy: ```python import numpy as np features = np.load("features.npy") labels = np.load("labels.npy") print("Features shape:", features.shape) print("Labels shape:", labels.shape) ``` These arrays can be directly used to create PyTorch or TensorFlow datasets for training models like the associated `VideoTransformer`. ## Citation Information Please cite the original source of the "Real Life Violence Dataset" if known. If using the preprocessing script or the models from the associated repository, please cite: ```bibtex @misc{violence_transformer_2025, author = {Andre Ross}, title = {Video Violence Detection Models (MobBiLSTM & Transformer)}, year = {2025}, published = {https://github.com/ross-sec/violence-transformer} } ``` ## Disclaimer The creators of this repository and the associated models are not responsible for the misuse of this dataset. User discretion is strongly advised when working with this data.