Blurring Faces to Preserve Privacy with Computer Vision
Quote of the day:
“Keep calm and carry on.” -Winston Churchill
Computer vision applications can be used in a variety of settings and sometimes information captured in your dataset might not be information you want to be responsible for having such as personally identifiable information, banking information, or any other sensitive data.
In these instances, you can ensure the data is anonymized by blurring, pixelating, or fogging any specific data before it enters your database. This post will show you how to do this using computer vision.
What to expect from this blog post?
- How to train models to detect faces and license plates from a given image.
- Using the Roboflow API to run the trained model on your custom images.
- Automatically censor detected faces and license plates to anonymize data captured in computer vision projects.
What is Fogging or Blurring in Computer Vision?
Fogging, also known as blurring, is used for censorship or privacy in which a visual area of any image, video, or livestream is blurred to obscure the data captured.
Pixelization is also a form of fogging. This technique is used widely across industries from street mapping to news reporting to social media.
Example: Face Blurring Used in Google Maps
When Street View imagery is published to Google Maps, Google employs censoring faces to protect individuals’ privacy.
Steps Involved for Blurring Faces with Computer Vision
Just 3 simple steps:
- Step 1: Collect data
- Step 2: Train a model
- Step 3: Use the Roboflow API to deploy the model
Collect Data of Faces for Model Training
Luckily, we have Roboflow Universe which is home to the world's largest collection of annotated and ready to use datasets related to various industries such as self-driving cars and agriculture, to manufacturing and gaming that are open source and free to use. Tip: Search using the keyword 'faces' or 'license plates' and we are ready to go
In addition to downloading the datasets, you can also clone data from Roboflow Universe directly to a project in your Roboflow account.
If you need additional data beyond what is provided in Universe, you can upload Youtube videos as training data or upload your own data. Then you'll use Roboflow Annotate to label the data for model training.
Train a Facial Recognition Model
We then upload our downloaded image dataset to the Roboflow app to train our model to detect faces. This process can be done for any data you want to obfuscate and anonymize such as license plates and identification cards.
After uploading your dataset, properly labeling the data, adding augmentations, and generating the dataset, you can train a computer vision model with one-click using Roboflow Train.
Below are the results after training the model using the Accurate model in Roboflow.
Along with model performance data, we also have access to visualizations for the training and validation curves.
Using the Computer Vision Model to Censor the Region of Interest (ROI)
After successfully training the model, go to the Deploy page and use the API script provided to censor the images.
Using Roboflow API is straightforward, install using pip:
pip install roboflow
After successful installation,
- Import the Roboflow module,
- Enter your API key,
- Call your project name,
- Choose your model version.
Use predict function and choose the confidence and overlap threshold values suitable to your custom needs.
After the prediction, extract the region of interest (ROI):
Blur or Pixelate the ROI as below:
Blur:
Pixelate:
Start Your First Blurring Project with Computer Vision
Hopefully you can use parts of this application to build your own project. To get started, find a dataset in Roboflow Universe, consider the best method for deploying your model, and ship your first project.
If you end up building something, please share it in our forum!