How anuza08/violencedetection works
Main Components
• Web Interface (Frontend):
• Represents the UI layer: the HTML templates (e.g., templates/index.html) and static assets (CSS, uploaded files, processed media).
• That static files are divided into directories for uploads (raw data) and processed (annotated output).
• Application Server (Backend):
• The main Flask app (app.py) provides endpoints such as the root page “/”, and routes like “/predict_image” and “/predict_video”, which handle media uploads and responses.
• The run.py file (if used as an alternative entry point) should be noted as part of the application startup workflow.
• Model Processing Component:
• The model.py file contains the Model class that initializes the CLIP model (using a deep learning framework such as PyTorch) and carries out image/video predictions.
• Its methods include image pre-processing and video processing (batching frames for efficiency).
• Configuration and Utilities:
• The settings.yaml file holds configuration parameters (e.g., model device settings, prediction thresholds, and label definitions).
• The utils.py file likely includes helper functions for common tasks (such as processing media files, reading configurations, etc.).
Relationships and Data Flow
• User Interaction:
• Users interact with the Web Interface to upload images/videos via the main page.
• Request Processing:
• Once a file is uploaded, the Flask application routes the request to the appropriate endpoint.
• The endpoint then invokes the Model Processing Component (via functions in model.py) to perform the violence detection using the CLIP model.
• Interaction with Configuration:
Architectural Patterns and Important Technologies
• Use an MVC-like (Model-View-Controller) structure:
• The “View” corresponds to templates and static assets.
• The “Controller” is implemented by the Flask routing in app.py.
• The “Model” layer handles the deep learning prediction logic in model.py.
• Technologies and Libraries:
• Flask (for web framework)
• PyTorch and CLIP (for the deep learning model)
• OpenCV (for processing video and image frames)
• NumPy and Pillow (for numerical operations and image manipulation)
• YAML configuration (via settings.yaml)