This repository contains a Python script for performing object detection using the YOLOv5 model. It captures video frames from a webcam and overlays bounding boxes on detected objects, counting the number of detections for a specific class and displaying an alert message if a threshold is met.
Before running the code, ensure you have the following dependencies installed:
- Python 3.x
- OpenCV (
opencv-python
) - PyTorch (
torch
) - NumPy (
numpy
)
- Clone or download this repository to your local machine.
git clone https://github.com/PattasuBalu/yolo_object_detection.git
- Navigate to the cloned repository folder:
cd yolo_object_detection
- Install the required packages by running:
pip install -r requirements.txt
-
Open the Python script
alerting_and_count.py
and make the following adjustments:- Update the
weights_path
variable to point to the location of your custom YOLOv5 model weights.(mostly a .pt file) - Ensure your webcam is accessible via camera index
0
, or change the index if needed.
- Update the
-
Save the script and run it using:
python alerting_and_count.py