Artificial intelligence came about in the 50s-60s. The idea of a machine built like a human-triggered something within us. And because of its complexity, its black box appearance, and odd familiarity, it wasn’t a coincidence that the public saw this as a threat.
And today, although the fear hasn’t disappeared, the field of AI underwent a massive revamp. Back in the 1990s-2000s the AI community took a big step forward. You see in the pursuit of re-creating anything close to a human, we first need to mimic the most basic abilities: and that’s perception. How do you teach computers to see?
Why’s It So Difficult?
This is a camera, it helps computers see and each frame of video has a resolution of 1920x 1080 meaning there are 2 million pixels in each frame, each pixel represents a color and together the mosaic of pixels forms a picture.o us this could mean an apple or a tree but to a computer, it’s just a map of numbers essentially.
What if you take a picture of the same object but with different light? The computer sees it as two different objects, but in reality, it’s the same. How do you get the computer to understand the true relationship between images and its classification?
Introducing The Convolutional Neural Network.
Data scientists realized that we need to first simplify the computer’s job and we do so by extracting the valuable information from pictures. When detecting images a super important feature are edges. Edges define the shape of objects, and we detect edges through a filter. This filter would be applied to a snippet of the image to outputs all the useful information. The filter runs across the entire picture detecting the edges. The detection would filter through the entire image leaving behind an empty image with only its vertical lines “highlighted”.
In technical terms, a filter is a 3x3 matrix that is multiplied with a snippet of the original image. The output is then stitched together forming a fully filtered image.
After the crucial data is extracted, the image can be compressed to half its original size while retaining all the key info with a function called max pooling. Max pooling takes the largest value out of the snippets, ignoring the excess data.
This process is called convolution and it helps decrease the complexity of the task at hand.
In most cases, a layer of convolution is applied multiple times. Then, the image is flattened and each pixel is feed into a fully connected neural network. All you need to know about a fully connected artificial neural network (ANN) is that the neural network is a series of nodes connecting to other nodes with different weights that activate specific areas of the model depending on the input. The neural net replicates a brain where different ideas spark activation in different areas of the brain. The fully connected layer crunches the numbers and spits out a classification. The model is then trained with backpropagation allowing the model to develop and mature the more training you run on the model.
Building A CNN In Code
Here are all the packages and libraries I need to import for the project pretty simple. Then I load my data and converted Image to a matrix/ array of pixel values. Then I label my dataset used to train my data set. I also reshuffle the data so the computer doesn’t cheat.
Here I set up by Convolutional Neural Network (CNN). First I had a convolutional layer with 32 filters, and a stride of 3 and activation after it. Followed by one more convolutional layer before I flatten the image to a vector and feeding it into my fully connected layer which is my softmax. Backpropagation is applied to minimize loss referred to as “model.compile”. Then we run and train the model.
Finally, we get the computer code to output the images we wish to classify. For example sakes, I loaded the image “rider-20.jpg” and it outputs the correct classification!
This is the line of code helps us visualize what the computer sees with each filter applied. Notice the vertical edges detected. Since in the first layer we applied 32 filters here are the 32 results! The blacked out areas of the picture would be ignored by the model and thus the model focuses on what's really important. Check out my GitHub code here! Also, check out my Youtube video where I talk all about CNN’s!
So what does all of this really mean to us? Currently, computer vision serves as the basis of a lot of self-driving cars. Other implications are cancer detection through medical imaging. This is really just the first step, as the more we progress through the field of AI the more profound the discoveries are. No matter the innovation, computer vision serves as the foundation to build upon.
- Computers can’t understand the things they “see”
- CNN’s help computers classify images and understand what they are looking at
- A series of layers help simplify the task
Before You Go
Connect with me on LinkedIn
Feel free to reach out to e-mail me with any questions: email@example.com
And clap the article if you enjoyed 😊