RizwanMunawar / yolov5-object-tracking

YOLOv5 Object Tracking + Detection + Object Blurring + Streamlit Dashboard Using OpenCV, PyTorch and Streamlit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

yolov5-object-tracking

New Features

  • YOLOv5 Object Tracking Using Sort Tracker
  • Added Object blurring Option
  • Added Support of Streamlit Dashboard
  • Code can run on Both (CPU & GPU)
  • Video/WebCam/External Camera/IP Stream Supported

Coming Soon

  • Option to crop and save detected objects
  • Dashboard design enhancement

Pre-Requsities

  • Python 3.9 (Python 3.7/3.8 can work in some cases)

Steps to run Code

  • Clone the repository
git clone https://github.com/RizwanMunawar/yolov5-object-tracking.git
  • Goto the cloned folder.
cd yolov5-object-tracking
  • Create a virtual envirnoment (Recommended, If you dont want to disturb python packages)
### For Linux Users
python3 -m venv yolov5objtracking
source yolov5objtracking/bin/activate

### For Window Users
python3 -m venv yolov5objtracking
cd yolov5objtracking
cd Scripts
activate
cd ..
cd ..
  • Upgrade pip with mentioned command below.
pip install --upgrade pip
  • Install requirements with mentioned command below.
pip install -r requirements.txt
  • Run the code with mentioned command below.
#for detection only
python ob_detect.py --weights yolov5s.pt --source "your video.mp4"

#for detection of specific class (person)
python ob_detect.py --weights yolov5s.pt --source "your video.mp4" --classes 0

#for object detection + object tracking
python obj_det_and_trk.py --weights yolov5s.pt --source "your video.mp4"

#for object detection + object tracking + object blurring
python obj_det_and_trk.py --weights yolov5s.pt --source "your video.mp4" --blur-obj

#for object detection + object tracking + object blurring + different color for every bounding box
python obj_det_and_trk.py --weights yolov5s.pt --source "your video.mp4" --blur-obj --color-box

#for object detection + object tracking of specific class (person)
python obj_det_and_trk.py --weights yolov5s.pt --source "your video.mp4" --classes 0
  • Output file will be created in the working-dir/runs/detect/exp with original filename

Streamlit Dashboard

  • If you want to run detection on streamlit app (Dashboard), you can use mentioned command below.

Note: Make sure, to add video in the yolov5-object-tracking folder, that you want to run on streamlit dashboard. Otherwise streamlit server will through an error.

python -m streamlit run app.py
YOLOv5 Object Detection YOLOv5 Object Tracking YOLOv5 Object Tracking + Object Blurring YOLOv5 Streamlit Dashboard

References

My Medium Articles

For more details, you can reach out to me on Medium or can connect with me on LinkedIn

About

YOLOv5 Object Tracking + Detection + Object Blurring + Streamlit Dashboard Using OpenCV, PyTorch and Streamlit

License:GNU Affero General Public License v3.0


Languages

Language:Python 99.1%Language:Shell 0.9%