Skip to content

RizwanMunawar/yolov7-object-blurring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YOLOv7 Object Blurring

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.

Prerequisites

  • Python 3.6+ installed on your system.
  • pip upgraded to the latest version.

Quick Start Guide

1. Clone the Repository

Start by cloning this repository to your local machine:

git clone https://github.com/RizwanMunawar/yolov7-object-blurring.git
cd yolov7-object-blurring

2. Set Up a Virtual Environment (Recommended)

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

3. Install Dependencies

Upgrade pip and install the required packages by running:

pip install --upgrade pip
pip install -r requirements.txt

4. Download YOLOv7 Model Weights

Download the YOLOv7 pretrained weights and move them to the yolov7-object-blurring folder.

5. Running the Code

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

6. Accessing Results

The output video will be saved in the directory: runs/detect/exp. Each new run creates a new exp folder with the results.


Example Results

Objects Blurred A Objects Blurred B Hidden Detection Area
Image A Image B Image C

Resources and Further Reading

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🤯 Published Date

Parking Management using Ultralytics YOLO11 Published Date

My 🖐️Computer Vision Hobby Projects that Yielded Earnings Published Date

Best Resources to Learn Computer Vision Published Date

Roadmap for Computer Vision Engineer Published Date

How did I spend 2022 in the Computer Vision Field Published Date

Domain Feature Mapping with YOLOv7 for Automated Edge-Based Pallet Racking Inspections Published Date

Exudate Regeneration for Automated Exudate Detection in Retinal Fundus Images Published Date

Feature Mapping for Rice Leaf Defect Detection Based on a Custom Convolutional Architecture Published Date

Yolov5, Yolo-x, Yolo-r, Yolov7 Performance Comparison: A Survey Published Date

Explainable AI in Drug Sensitivity Prediction on Cancer Cell Lines Published Date

Train YOLOv8 on Custom Data Published Date

More Information

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

About

YOLOv7 Object Blurring Using PyTorch and OpenCV

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages