Skip to content

The main aim of the project is to detect any theft activity and alert the authorized person which uses computer vision ,machine learning .

Notifications You must be signed in to change notification settings

NeerajChristoMathew/Theft-Analyzer-Using-Computer-Vision-and-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Theft Analyzer using-Computer-Vision and AI

:


This project uses YOLO (You Only Look Once) object detection model for real-time theft detection using computer vision. The system is trained on custom datasets with annotated theft-related activities and tested using live or recorded video. It leverages AI to automate surveillance tasks and alert when suspicious behavior or objects (e.g., unauthorized access, weapons, stolen items) are detected.


Project Structure

theft-detection-ai/
├── data/
│   ├── images/
│   │   ├── train/
│   │   ├── val/
│   │   └── test/
│   ├── labels/
│   │   ├── train/
│   │   ├── val/
│   │   └── test/
│   └── conf.yaml
├── train.ipynb
├── detection.py
├── README.md

Requirements

Install dependencies:

pip install ultralytics opencv-python numpy

Dataset Creation and Annotation

  1. Collect Data: Gather video frames/images showing normal and suspicious activity (e.g., trespassing, object lifting, carrying bags in restricted zones).

  2. Annotation:

    • Use Roboflow or LabelImg to annotate each image.
    • Define custom classes like: thief, weapon, bag, suspicious_action.
  3. Export in YOLO Format:

    • Each image must have a corresponding .txt label file with YOLO bounding box format.

    • Organize as:

      /images/train, /val, /test
      /labels/train, /val, /test
      

Dataset Splitting

  • You can use Roboflow’s export tool to automatically split the dataset into train, val, and test.
  • Alternatively, use this command in Python:
import splitfolders
splitfolders.ratio("images/", output="data/", seed=42, ratio=(.8, .1, .1))

Ensure the YAML config file data.yaml includes:

train: data/images/train
val: data/images/val
test: data/images/test

nc: 3
names: ['thief', 'weapon', 'bag']

Training the Model

Train a YOLOv8 model using Ultralytics:

yolo task=detect mode=train model=yolov8n.pt data=data.yaml epochs=50 imgsz=640

  • You can choose yolov8n.pt, yolov8s.pt, etc., depending on your hardware.
  • After training, weights are saved in runs/detect/train/weights/best.pt.

Testing and Inference

Run inference on a video or webcam:

yolo task=detect mode=predict model=runs/detect/train/weights/best.pt source=your_video.mp4

Or for real-time webcam detection:

yolo task=detect mode=predict model=runs/detect/train/weights/best.pt source=0

About

The main aim of the project is to detect any theft activity and alert the authorized person which uses computer vision ,machine learning .

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages