Use numpy to classify an image as being pizza or not pizza

Tracyrenee
5 min readNov 26, 2023

Computer vision is a field of computer science that focuses on enabling computers to identify and understand objects and people in images and videos. Like other types of AI, computer vision seeks to perform and automate tasks that replicate human capabilities. In this case, computer vision seeks to replicate both the way humans see, and the way humans make sense of what they see.

Modern computer vision applications are increasingly relying on deep learning algorithms. With deep learning, a computer vision application runs on a type of algorithm called a neural network, which allows it to deliver even more accurate analyses of images. In addition, deep learning allows a computer vision program to retain the information from each image it analyses — so it gets more and more accurate the more it is used.

In my last blog post I compared images of dogs and cats, and that blog post can be seen here:- https://medium.com/@tracyrenee61/classify-dog-and-cat-images-with-an-easy-numpy-neural-network-04681646e0f7

In the dog and cat blog post, I used a very small dataset to make it quicker to train the data and evaluate the model. There were only 20 images of dogs and cats, meaning there was not a great deal of data to train.

In this blog post, therefore, I intend to use more data, and have therefore selected the pizza or not pizza dataset, which can be found here:- https://www.kaggle.com/datasets/carlosrunner/pizza-not-pizza/data

I have used a neural network created from Python’s numpy library. This neural network utilises three layers, being an input layer, a hidden layer, and an output layer:-

I have written the program in Python using Kaggle’s free online Jupyter Notebook, and stored it in my Kaggle account.

Once the Jupyter Notebook was created, I imported the libraries that I would need to execute the program, being:-

  1. Numpy to create the neural network and perform numeric computations,
  2. Pandas to create dataframes and process the data,
  3. Random to create random numbers,
  4. PIL to process the images,
  5. Cv2 to process images,

--

--

Tracyrenee

I have close to five decades experience in the world of work, being in fast food, the military, business, non-profits, and the healthcare sector.