Skip to content

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

License

Notifications You must be signed in to change notification settings

RizwanMunawar/yolov5-object-tracking

Repository files navigation

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

1 - Clone the repository

git clone https://github.com/RizwanMunawar/yolov5-object-tracking.git

2 - Goto the cloned folder.

cd yolov5-object-tracking

3 - 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 ..

4 - Upgrade pip with mentioned command below.

pip install --upgrade pip

5 - Install requirements with mentioned command below.

pip install -r requirements.txt

6 - 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

7 - 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

  1. YOLOv7 Training on Custom Data – Guide to training YOLOv7 on custom datasets.
  2. Roadmap for Computer Vision Engineer – A step-by-step career guide for aspiring computer vision engineers.
  3. YOLOR or YOLOv5: Which One is Better? – Comparative analysis of YOLOR vs. YOLOv5 for model selection.
  4. Train YOLOR on Custom Data – Instructions for customizing YOLOR on unique datasets.
  5. Develop an Analytics Dashboard Using Streamlit – Tutorial on building data dashboards with Streamlit.
  6. Jetson Nano in Computer Vision Solutions – Insight on Jetson Nano's role in embedded AI projects.
  7. How Computer Vision Products Help in Warehouses – Overview of computer vision applications in warehouse efficiency.

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

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published