/Night_Watch_DL

Problem Statement:

Primary LanguageJupyter Notebook

Night_Watch

An AI/ML model to find suspicious activity of cycle stealing using camera footage or videos.

Tools Used

  • Google Colab & VS Code with libraries
  • Yolov5 Architecture
  • OpenCV

GitHub Repository Structure

  • dataset : Directory containing the dataset (images)
  • Night_watch.ipynb : file takes the yolov5 real-time objective detection model then we give our dataset here to learn our dataset and it builds a model. Also adds bounding box if tested on an uploaded video.
  • custom.yaml : Directory which gives the path of our dataset
  • cycle_theft: file to run the model after downloading it with live webcam
  • demo.mp4: file for testing the model
  • problemStatement_year_4.pdf : problem statement of the problem

Working

1. Data Collection and Training :

  • Dataset : It consists of images for training and testing, including normal and suspicious events related to cycle theft.
  • Training : Image frames were extracted and resized for compatibility with the model.

2. Anomaly Detection :

  • Confidence : The first step of thief detection is on its confidence level. The confidence level of the person detection should be at least 80 percent.
  • Time Spent : The second step of thief detection is the time spent by the person to work on opening the lock.
If both conditions are satisfied, then our model prints "Hello, thief" on the console, declaring the presence of a cycle thief.

How to run

  • Before running any terminal, ensure you are running your notebook on GPU instead of CPU. To check, go on runtime/change runtime type it should be on GPU (Can change it on Google Colab; in case you are running it on PC, make sure that your GPU is active while running this file).
  • First download the ipynb file.
  • Run the first kernel to download the some files and dependencies for yolov5.
  • Now we need to add custom.yaml file inside the yolov5/data folder for the code to work furthur.
  • Add the dataset folder into your drive.
  • Run the second kernel of the notebook. It will connect to your drive to fetch the dataset.
  • Now run the third kernel for prediction or model validation.
  • Now to test the model that it is running fine, upload the demo.mp4 file inside your notebook.
  • Now run the fourth terminal to run the model in our video.
  • Download the video from the directory yolov5/runs/detect/exp2 then download the demo.mp4 file again and run it you will see some prediction there.

Run on live webcam

to run on a live webcam

  • First Download the last.pt model which after running the above steps.
  • Download from the directory yolov5/models/last.pt model.
  • Put the path of your last.pt model inside the cycle_theft.ipynb jupyter file in the path.
  • After running make sure you have permission for your webcam to open then you will able to see that the model is working.

For more you see our presentation uploaded to the repository.

Conclusion

The cycle theft detection model combines the power of yolov5 architecture to identify suspicious events in video footage. By leveraging deep learning techniques, this model offers a reliable solution for enhancing security and preventing cycle theft incidents even in low light and poor image quality conditions.

The above image is the screenshot of test image which captures the detected person, and shows confidence rate on the frame as well.