A Python-based tool for object detection and selective blurring using YOLOv7. This repository allows you to blur specific classes of objects in videos or images. It’s an ideal solution for anonymizing data in videos, protecting privacy, or focusing on certain objects.
- Python 3.6+ installed on your system.
- pip upgraded to the latest version.
Start by cloning this repository to your local machine:
git clone https://github.com/RizwanMunawar/yolov7-object-blurring.git
cd yolov7-object-blurring
Create a virtual environment to isolate dependencies and prevent conflicts with existing Python packages.
For Linux Users:
python3 -m venv yolov7objblurring
source yolov7objblurring/bin/activate
For Windows Users:
python3 -m venv yolov7objblurring
yolov7objblurring\Scripts\activate
Upgrade pip and install the required packages by running:
pip install --upgrade pip
pip install -r requirements.txt
Download the YOLOv7 pretrained weights and move them to the yolov7-object-blurring
folder.
Use the following commands to detect and blur objects in your video:
-
Basic Command (change
source
to the path of your video):python detect_and_blur.py --weights yolov7.pt --source "your_video.mp4" --blurratio 20
-
Blurring Specific Classes (e.g.,
person
class):python detect_and_blur.py --weights yolov7.pt --source "your_video.mp4" --classes 0 --blurratio 50
-
Hiding Detection Boxes (hides the bounding box for blurred areas):
python detect_and_blur.py --weights yolov7.pt --source "your_video.mp4" --classes 0 --blurratio 50 --hidedetarea
The output video will be saved in the directory: runs/detect/exp
. Each new run creates a new exp
folder with the results.
Objects Blurred A | Objects Blurred B | Hidden Detection Area |
---|---|---|
- YOLOv7 Project: https://github.com/WongKinYiu/yolov7
- OpenCV Documentation: https://opencv.org/
Some of my articles/research papers | computer vision awesome resources for learning | How do I appear to the world? 🚀
Ultralytics YOLO11: Object Detection and Instance Segmentation🤯
Parking Management using Ultralytics YOLO11
My 🖐️Computer Vision Hobby Projects that Yielded Earnings
Best Resources to Learn Computer Vision
Roadmap for Computer Vision Engineer
How did I spend 2022 in the Computer Vision Field
Domain Feature Mapping with YOLOv7 for Automated Edge-Based Pallet Racking Inspections
Exudate Regeneration for Automated Exudate Detection in Retinal Fundus Images
Feature Mapping for Rice Leaf Defect Detection Based on a Custom Convolutional Architecture
Yolov5, Yolo-x, Yolo-r, Yolov7 Performance Comparison: A Survey
Explainable AI in Drug Sensitivity Prediction on Cancer Cell Lines
More Information
For more details, you can reach out to me on Medium or can connect with me on LinkedIn