--- title: Video-Violence-Detection emoji: 🏃 colorFrom: purple colorTo: indigo sdk: gradio sdk_version: 5.5.0 app_file: app.py pinned: false short_description: A model for classifing a video to having violence or not --- ## Overview This Gradio app is built to classify uploaded videos as "Violent" or "Non-violent" using a pre-trained 3D CNN model (ResNet3D-18). Users can upload a video file, which the app will preprocess before passing it through the model. The app then displays the classification result along with the probability score indicating the likelihood of the video being violent. ## Training Data To develop our model for violence detection, we combined four datasets, amassing over 6,000 video clips. Here’s a breakdown of the datasets used: 1. **[Hockey fights Dataset](https://www.kaggle.com/datasets/yassershrief/hockey-fight-vidoes)** * **Description**: This dataset contains videos from hockey games, capturing both fight and non-fight scenes. It’s widely used for detecting aggressive behavior in sports. 2. **[Real-Life Violence Situations Dataset](https://www.kaggle.com/datasets/mohamedmustafa/real-life-violence-situations-dataset)** * **Description**: A dataset with real-world surveillance footage, covering various scenarios such as physical altercations and other violent incidents in public spaces. 3. **[Smart-City CCTV Violence Detection Dataset (SCVD)](https://www.kaggle.com/datasets/toluwaniaremu/smartcity-cctv-violence-detection-dataset-scvd)** * **Description**: Designed to aid smart-city systems, this dataset includes CCTV footage of different violent and non-violent interactions in urban areas. 4. **[A-Dataset-for-Automatic-Violence-Detection-in-Videos (_repo_)](https://github.com/airtlab/A-Dataset-for-Automatic-Violence-Detection-in-Videos)** * **Description**: A comprehensive dataset featuring varied video sources, covering numerous types of violent and non-violent events. ## Structure * **app.py**: The main Python script implements the Gradio, handles video uploads, and processes videos using the violence detection model. * **requirements.txt**: A text file contains all needed libraries. * **pre_3D_model.h5**: h5 file contains the model weights. ## How It Works * **Video Upload**: Users can upload videos in .mp4, .avi, or .mov format. * **Preprocessing**: The video is sampled to 40 frames, resized, and normalized. * **Classification**: The preprocessed video frames are fed into the 3D CNN model to classify the content. * **Results Display**: The result page displays the classification label and the probability of violence.