Skip to content

An AI-powered web service for real-time violence detection and analysis using YOLOv8, integrated with a Python MVC framework. Supports video uploads and live camera streaming for school and public safety.

Notifications You must be signed in to change notification settings

giekiwt/ViolenceGuard-YOLOv8-Web

Repository files navigation

🛡️ ViolenceGuard-YOLOv8-Web

Hệ thống nhận diện hành vi bạo lực sử dụng YOLOv8 và Web Service

Python YOLOv8 Flask License

📖 Giới Thiệu

ViolenceGuard là một dự án Computer Vision nhằm phát hiện và nhận diện các hành vi bạo lực trong video và camera real-time. Dự án sử dụng mô hình YOLOv8 được huấn luyện trên dataset Fignet và triển khai dưới dạng Web Service với kiến trúc MVC.

🎯 Mục Tiêu

  • Nhận diện các hành vi bạo lực trong môi trường học đường và xã hội
  • Cung cấp giải pháp giám sát an ninh tự động
  • Hỗ trợ phân tích video và camera real-time

✨ Tính Năng

  • Upload Video: Tải lên video và phân tích nhận diện hành vi bạo lực
  • Camera Real-time: Nhận diện trực tiếp qua camera
  • Bounding Box Visualization: Hiển thị kết quả với khung nhận diện
  • Lịch Sử Phân Tích: Lưu trữ và xem lại các phân tích trước đó
  • API RESTful: Tích hợp dễ dàng với các hệ thống khác

🏗️ Kiến Trúc

Dự án được xây dựng theo mô hình MVC (Model-View-Controller):

  • Model: YOLOv8 detector, Video processor, Database models
  • View: HTML/CSS/JavaScript frontend
  • Controller: Flask API endpoints, Request handlers

🚀 Quick Start

Yêu Cầu Hệ Thống

  • Python 3.8+
  • CUDA-capable GPU (khuyến nghị cho training)
  • 8GB RAM minimum
  • 50GB disk space (cho dataset và models)

Cài Đặt

# 1. Clone repository
git clone https://github.com/yourusername/ViolenceGuard-YOLOv8-Web.git
cd ViolenceGuard-YOLOv8-Web

# 2. Tạo virtual environment
python -m venv venv
source venv/bin/activate  # Linux/Mac
# hoặc
venv\Scripts\activate     # Windows

# 3. Cài đặt dependencies
pip install -r requirements.txt

# 4. Tạo các thư mục cần thiết
mkdir -p uploads outputs logs models dataset

Chạy Ứng Dụng

# Development mode
python run.py

# Truy cập: http://localhost:5000

📊 Dataset

Dự án sử dụng Fignet Dataset với các lớp hành vi:

  • fighting - Đánh nhau
  • hitting - Đấm đá
  • kicking - Đá
  • pushing - Đẩy
  • weapon - Sử dụng vũ khí
  • normal - Hành vi bình thường

Chuẩn Bị Dataset

python scripts/prepare_dataset.py --source /path/to/fignet --output ./dataset

🤖 Training Model

# Train YOLOv8 model
python scripts/train_model.py --data dataset/data.yaml --epochs 100 --img 640

# Hoặc sử dụng Jupyter Notebook
jupyter notebook notebooks/model_training.ipynb

📁 Cấu Trúc Dự Án

ViolenceGuard-YOLOv8-Web/
├── app/                    # Web application
│   ├── models/            # Model layer (YOLOv8, processors)
│   ├── controllers/       # Controllers (API endpoints)
│   ├── views/             # HTML templates
│   └── static/            # CSS, JS, images
├── dataset/               # Training data
├── models/                # Trained models
├── scripts/               # Utility scripts
├── notebooks/             # Jupyter notebooks
└── run.py                 # Application entry point

Xem chi tiết tại PROJECT_GUIDELINE.md

🔌 API Endpoints

Upload Video

POST /api/upload
Content-Type: multipart/form-data

Get Results

GET /api/results/{video_id}

Camera Stream

GET /api/camera/stream

🛠️ Tech Stack

  • Backend: Flask, Python
  • Deep Learning: YOLOv8 (Ultralytics), PyTorch
  • Computer Vision: OpenCV
  • Frontend: HTML5, CSS3, JavaScript, Bootstrap 5
  • Database: SQLite/PostgreSQL

📚 Tài Liệu

🤝 Đóng Góp

Mọi đóng góp đều được chào đón! Vui lòng:

  1. Fork repository
  2. Tạo feature branch (git checkout -b feature/AmazingFeature)
  3. Commit changes (git commit -m 'Add some AmazingFeature')
  4. Push to branch (git push origin feature/AmazingFeature)
  5. Tạo Pull Request

📝 License

Distributed under the MIT License. See LICENSE for more information.

👥 Team

  • Project Lead: [Your Name]
  • Contributors: [Team Members]

📧 Contact

Project Link: https://github.com/yourusername/ViolenceGuard-YOLOv8-Web


Made with ❤️ for Computer Vision Course

About

An AI-powered web service for real-time violence detection and analysis using YOLOv8, integrated with a Python MVC framework. Supports video uploads and live camera streaming for school and public safety.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages