The AI Comic: Z.A.I.N – Issue #1: Automating Attendance using Computer Vision

Prerit Rathi 24 Jun, 2019
4 min read

Sound does not travel in a vaccum.

The above concept might just be a simple fact for you – but I had a tough time learning this in the manner it was taught in one of my classes. I actually learnt it when this was implemented in a comic and one of the Super Heroes I followed used this to solve an otherwise difficult challenge.

I have been in awe with the power of comics to help us understand concepts in a simple and visual manner. The ebb and flow of stories, the build up and the climax usually hold up people like me for hours.

Now, think of a technical article. Do you remember a blog you read about a specific technique from a few months back? I’d guess you don’t. I certainly don’t!

That’s why we at Analytics Vidhya came up with the idea of the world’s first Artificial Intelligence (AI) comic! We believe comics are an awesome way of learning a concept through interactive storytelling. Simply put, it’s a brilliant way to learn complex data science topics.

Welcome to Issue #1 of Analytics Vidhya’s A.I. Comic!

AI Comic

With this AI comic series, I aim to bring out my imagination for the benefit of millions of kids and friends. I aim to help them understand how AI & ML will change our world. And I hope, a few years down the line, they remember Z.A.I.N as the super hero who helped them understand the super power of machines!

We will combine advanced blog content and code on machine learning and AI with the storytelling style of a comic. Are you ready to dive into the world of AI comics? Let’s begin – and welcome to issue #1!

 Issue #2 of AI-COMIC: Z.A.I.N (Keep Calm and Optimise) is out now!check it out here


About Z.A.I.N.

Z.A.I.N. is the first issue of Analytics Vidhya’s Artificial Intelligence (AI) comic series that successfully merges technical and complex Artificial Intelligence implementations with the fun of reading comic books.

The comic book series combines both of these elements:

  1. An intriguing storyline along with a daily life implementation of AI
  2. Technical AI content, including fully functional code implementation in Python and a whole lot more!

Here’s Kunal Jain, Analytics Vidhya’s Founder and CEO, along with me, to give you a glimpse into this AI comic series:


Indulge in the World of Comics through Z.A.I.N

Here is all you need to know about the chief character of this comic book series:

AI Comic

AI Comic

Note: Use the right and left arrow keys to navigate through the below slider.

previous arrow
next arrow
You can download the full comic here!


Python Code and Explanation

Had fun reading the A.I. comic? Now, let’s understand the code behind the attendance system. That’s right – we are going to implement the Python code we just saw!

We’ll be using the below libraries in this section:

  • OpenCV: For detecting faces and eyes by the inbuilt eye and face cascade classifiers.
  • Matplotlib: For reading and plotting both the images.
  • NumPy:  “Complementary” – an all-time classic library!

Next, we read the .jpg file and plot it with the matplotlib library. In this case, we are using a photo of a single face (Tony Stark) which is saved in here as ‘ TS3.jpg ‘:

After reading and plotting the image, we come to the main code block:

Here, we use Face and Eye cascade Classifiers to get the coordinates of top and bottom corners of both the face and eyes respectively. Those coordinates/points are stored in variables:

  • x‘, ‘y‘, ‘w‘, ‘h‘ (for face cascade)
  • ew‘, ‘ey‘, ‘ex‘, ‘eh‘ (for eye cascade)

Then, we use these coordinates to plot rectangles around the face and eyes. The basic thought process is to count the number of rectangles around the faces, thus counting the number of faces:

Let’s implement the same code-block on a picture of the classroom. Our aim, remember, was to count the number of faces in the class. That’s exactly how Z.A.I.N saved the day! And now it’s our turn.

The image of the classroom is saved as ‘face-detection.jpg’. You can download the image from here and follow along with the code we’ll soon see. You can even play around with an image of your choice. I strongly believe the best way to learn a concept is by experimenting!

Let’s get back to our classroom. The below code makes rectangles around most of the faces in the classroom:

Awesome! We have successfully built the automated attendance system using computer vision! The adventures of Z.A.I.N have only just begun.


End Notes

This first issue of AV’s AI comic, Z.A.I.N, was the story about how computer vision can change our day-to-day lives for the better. And guess what? There are many such adventures that await him and all of us.

Issue #2 is coming soon. Grab your popcorn and get ready to partake in another awesome AI adventure because the next issue is going to take our learning to a whole new level.

Thank you for reading. Feel free to leave your thoughts, your experience, and precious feedback in the comments section below!

Prerit Rathi 24 Jun, 2019

Frequently Asked Questions

Lorem ipsum dolor sit amet, consectetur adipiscing elit,

Responses From Readers


Teja 04 Jun, 2019

I cannot see any eyes detected in the classroom's picture?

harish nagpal
harish nagpal 05 Jun, 2019

Good one Prerit. I learnt a new thing today. Keep it up. Waiting for your next one.

Harish Nagpal
Harish Nagpal 05 Jun, 2019

Good one. I learnt a new thing today. Keep it up.

Rishi Sharma
Rishi Sharma 06 Jun, 2019

I want to ask that for taking attendance i.e. how we will confirm that a particular person was present there or not, with this we are only able to count the number of students. I think for that we need facial recognition?

Prerit Rathi
Prerit Rathi 06 Jun, 2019

Hi Rishi! I really appreciate the fact that you read the comic with this enthusiasm that you raised this point. (Assuming that you have seen both Infinity War and Avengers Endgame) I could actually relate you to a friend of mine who asked that why didn’t Thor went for the head in infinity war only in the first place? But if he did so, then what was the point of Endgame. It was all a matter of plot, and this thing holds true for the AI-COMIC itself. Yes, Attendance system uses face recognition instead of detection, And who knows that the mistake was intentional or not…so, WAIT_FOR_IT

Hemant 07 Jun, 2019

Well done Prerit. Keep it up

Bonzadog 17 Jun, 2019

Why on earth does one need a comic book for AI? If one needs a comic to learn the play with LEGO and leave AI to adults. What a waste of space - let us have a more mature aspect to learn AI.

Alistair Walsh
Alistair Walsh 17 Jun, 2019

What a fantastic initiative! Congratulations on a great contribution to the data science tutorial space, I enjoyed it immensely and even learned something too :-) Edutainment is the future.

Vk_Dinesh 19 Jun, 2019

Hi, As I was doing detecting the faces and counting the no.of student in the class, i am not getting any result it shows only the picture with a grayscale format. ✔Link of my picture: