Skip to content

About

VisionSafe – AI powered safe vs unsafe activity detection system using YOLOv8, Mediapipe and Flask with a React dashboard.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚨VisionSafe – AI Powered Public Safety Monitoring System

VisionSafe is an AI-powered video surveillance system designed to detect safe and unsafe activities in uploaded videos using computer vision.

The system analyzes videos, detects objects using YOLOv8, and highlights unsafe scenarios with bounding boxes.

It provides a web dashboard where users can upload videos and view processed results.

🎯 Key Features

🎥 Upload video through a modern web interface

🤖 AI-based object detection using YOLOv8

🟥 Detect unsafe objects (vehicles, suspicious objects, actions)

🟩 Detect safe activities (people)

📦 Bounding box visualization on detected objects

🎞 Processed video output generation

📊 Detection result displayed on dashboard

⚡ Fast inference using OpenCV and Ultralytics

🌐 Full-stack web application (React + Flask)

🧠 AI Detection Logic

The AI model classifies detected objects into Safe and Unsafe categories.

Detected Object Classification Person SAFE Car UNSAFE Motorcycle UNSAFE Bus UNSAFE Truck UNSAFE

Bounding boxes are drawn around objects with labels.

Example:

🟩 Green box → SAFE

🟥 Red box → UNSAFE

🏗 Project Architecture safe-usafe-activity-detection │ ├── client/ # React Frontend │ ├── src │ └── package.json │ ├── server/ # Flask Backend │ ├── routes │ ├── controllers │ ├── services │ └── app.py │ ├── Label/ # AI Model & Inference │ ├── inference.py │ ├── yolov8n.pt │ └── outputs │ ├── screenshots # UI screenshots │ ├── README.md └── .gitignore 🛠 Tech Stack Frontend

React

Vite

JavaScript

CSS

Backend

Python

Flask

Flask-CORS

AI / Computer Vision

YOLOv8 (Ultralytics)

OpenCV

NumPy

Development Tools

VS Code

Git

GitHub

▶️ How to Run the Project 1️⃣ Clone Repository git clone https://github.com/kareena0229/safe-usafe-activity-detection.git cd safe-usafe-activity-detection 2️⃣ Start Backend

Navigate to server folder:

cd server

Install dependencies:

pip install flask flask-cors ultralytics opencv-python numpy pandas mediapipe

Run backend server:

python app.py

Server will start at:

http://127.0.0.1:5000 3️⃣ Start Frontend

Open another terminal.

Navigate to client folder:

cd client

Install dependencies:

npm install

Run frontend:

npm run dev

Frontend will start at:

http://localhost:5173 📷 Project Screenshots Dashboard

Upload Video

Detection Output

🎞 Example Workflow

1️⃣ Upload a video through the dashboard 2️⃣ AI processes frames using YOLOv8 3️⃣ Objects are detected 4️⃣ Bounding boxes are drawn 5️⃣ Safe / Unsafe result is displayed 6️⃣ Processed video is returned to user

🚀 Future Improvements

Real-time CCTV monitoring

Activity recognition (yoga, smoking, fighting)

Multi-person tracking

Suspicious object detection

Alert system

Cloud deployment

Mobile app integration

📊 Model Evaluation Results

The activity detection system was evaluated on a labeled dataset of 2,551 test samples using a Random Forest classifier trained on extracted pose features.

Overall Performance Metric Score Accuracy 97.14% Precision 97.03% Recall 97.14% Weighted F1 Score 97.06% Macro F1 Score 48.00%

The high weighted metrics indicate strong performance across the dominant classes, while the macro score highlights the impact of class imbalance.

📈 Per-Class Performance Class Precision Recall F1 Score Support Class 0 0.93 0.63 0.75 105 Class 1 0.97 1.00 0.99 2414 Class 2 1.00 0.10 0.18 31 Class 3 0.00 0.00 0.00 1

Observation

Class 1 dominates the dataset

Rare classes reduce macro-average score

Model performs strongly on frequent activity types

🔍 Confusion Matrix Predicted C0 C1 C2 C3 Actual C0 66 39 0 0 Actual C1 5 2409 0 0 Actual C2 0 28 3 0 Actual C3 0 1 0 0

Interpretation:

Most predictions fall correctly on the diagonal

Misclassifications occur mainly between C0 and C1

Extremely rare classes are harder for the model to learn

🧠 AI Processing Pipeline

The VisionSafe detection pipeline consists of the following stages:

Video Input │ ▼ Frame Extraction (OpenCV) │ ▼ Object Detection (YOLOv8) │ ▼ Pose Feature Extraction │ ▼ Activity Classification │ ▼ Safe / Unsafe Decision │ ▼ Bounding Box Rendering │ ▼ Processed Video Output ⚙️ Model Architecture Object Detection

Model used:

YOLOv8n

Advantages:

Lightweight

Fast inference

Good real-time performance

Activity Classification

Model:

Random Forest

Input features:

Pose landmark angles

Motion patterns

Bounding box context

🧪 Inference Performance Metric Value Average inference time ~30-40 ms per frame Model size ~6 MB FPS (CPU) ~20-25 FPS Detection framework Ultralytics YOLOv8 📊 System Performance Summary Component Technology Object Detection YOLOv8 Pose Analysis MediaPipe Activity Classification Random Forest Backend Flask Frontend React + Vite 🧩 System Architecture Diagram React Dashboard │ ▼ Flask Backend API │ ▼ AI Inference Engine ┌───────────────┐ │ YOLOv8 Model │ │ Pose Analysis │ │ RF Classifier │ └───────────────┘ │ ▼ Processed Video Output 🧠 Why This Project Is Important

VisionSafe demonstrates how AI can assist public safety monitoring by automatically identifying risky activities in video feeds.

Potential applications:

Smart city surveillance

Public transport monitoring

Campus safety systems

Traffic monitoring

👩‍💻 Author

Kareena Kumari

GitHub Profile https://github.com/kareena0229

⭐ Support

If you found this project useful, please consider giving it a star ⭐ on GitHub.

It helps others discover the project.

About

VisionSafe – AI powered safe vs unsafe activity detection system using YOLOv8, Mediapipe and Flask with a React dashboard.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages