Advanced Python Technologies III

Face Recognition w/ Colab #PurePythonSeries — Episode #14

J3
Jungletronics
3 min readOct 23, 2022

--

Hi, this time let’s use Google Colaboratory.

Face recognition library works well here, but there’s a secret that I’ll tell you right away:

Go to Runtime > Change runtime type > Choose GPU and hit save and you are ready to go \o/

Here is the result for code below:

All faces were detected and blurred

Let’s get Started:

00#step — HARDWARE

Laptop: Dell Inc. G3 3590 8,0 GiB RAM
Processor : Intel® Core™ i7-9750H CPU @ 2.60GHz × 12
OS: Ubuntu 22.04.1 LTS (Jammy Jellyfish)
GPU: GeForce GTX 1660 Ti Mobile (NVIDIA TU1166M)

Note: Forget It All: Let's Use Google Resources \o/

01#step — Access Google colab and get a Jupyter Notebook to work with.

02#step — Importing face recognition right away !

pip install face-recognition

03#step — Import cmake

pip install cmake

04#step — Import OpenCV

pip install opencv-python

05#step — Testing face recognition

import face_recognition

If you pass, paradise is ahead!

06#step —First let’s detect all the faces. Please download to the Jupyter Notebook directory this image:

The code bellow will detect all the 16 faces in this photo
oficce.jpg

07#step — Paste this code in the next cell

It results:

16 faces detected \o/

08#step — Now Now the code show: blur all faces just in case of image rights’ claiming

Paste this code:

The code is all commented, if you want, check it out!
Here is the result again \o/ This technique can be used for filming children for example.

One single note, replace cv2.imshow() with this:

from google.colab.patches import cv2_imshow(...)cv2_imshow()

09#step — print(Thank you very much!”)

That’s it!

print("That's it! Thank you very much")That's it! Thank you very much

👉Github (PPY-14)

👉Google Colab Jupyter Notebook

Related Posts

00#Episode#PurePythonSeries — Lambda in Python — Python Lambda Desmistification

01#Episode#PurePythonSeries — Send Email in Python — Using Jupyter Notebook — How To Send Gmail In Python

02#Episode#PurePythonSeries — Automate Your Email With Python & Outlook — How To Create An Email Trigger System in Python

03#Episode#PurePythonSeries — Manipulating Files With Python — Manage Your Lovely Photos With Python!

04#Episode#PurePythonSeries — Pandas DataFrame Advanced — A Complete Notebook Review

05#Episode#PurePythonSeries — Is This Leap Year? Python Calendar — How To Calculate If The Year Is Leap Year and How Many Days Are In The Month

06#Episode#PurePythonSeries — List Comprehension In Python — Locked-in Secrets About List Comprehension

07#Episode#PurePythonSeries — Graphs — In Python — Extremely Simple Algorithms in Python

08#Episode#PurePythonSeries — Decorator in Python — How To Simplifying Your Code And Boost Your Function

12#Episode#PurePythonSeries — Advanced Python Technologies qrcode, Speech Recognition in Python, Google Speech Recognition #PurePythonSeries

13#Episode#PurePythonSeries — Advanced Python Technologies II— qFace Recognition w/ Jupyter Notebook & Ubuntu #PurePythonSeries

14#Episode#PurePythonSeries — Advanced Python Technologies III — Face Recognition w/ Colab #PurePythonSeries (this one)

Credits & References

HARVARD CS50— lecture 6 —Python — DAVID MALAN https://cs50.harvard.edu/x/2021/weeks/6/
https://you.com/search?q=libstdc%2B%2B.so.6%3A%20version%20%60glibcxx_3.4.29%27

face-recognition https://pypi.org/project/face-recognition/

--

--

J3
Jungletronics

Hi, Guys o/ I am J3! I am just a hobby-dev, playing around with Python, Django, Ruby, Rails, Lego, Arduino, Raspy, PIC, AI… Welcome! Join us!