HomeThursday: Image Classification Project
cover image

Thursday: Image Classification Project

Image embedding, classification, comparison of trees and logistic regression

We have designed this course for prospective STEM teachers. These working notes include Orange workflows and visualizations we will construct during the lectures. Throughout our training, you will see how to accomplish various data mining tasks through visual programming and use Orange to build visual data mining workflows. Many similar data mining environments exist, but the lecturers prefer Orange for one simple reason—they are its authors.

These course notes were prepared by Blaž Zupan and Janez Demšar. Special thanks to Ajda Pretnar Žagar for the earlier version of the material. Thanks to Alana Newel, Nancy Moreno, and Gad Shaulsky for all the help with organization and the venue of the course. We would like to acknowledge all the help from the members of the Bioinformatics Lab at University of Ljubljana, Slovenia.

The material is offered under Create Commons CC BY-NC-ND licence.

Image Classification Project

Data Collection

  1. Start with folders: create a new folder and name it "train-data". Within this folder, create two to four subfolders and name them (e.g., if your data set contains beaches, create subdirectories named trashy, beautiful, city)
  2. Training set data: collect at least 8 images for each category and put them in the corresponding subfolder.
  3. Test set data: create another folder (outside the image folder, name it "new-data" and put some images there). These are the images we want to classify.
  4. Load the data into Orange: check if everything is all right by using Load Images widget in Orange. Use two widgets, one for training and one for test data, and show the images in Image Viewer.

Evaluation and Comparison of Classifiers

  1. Evaluation: Use the images from "train-data", embed the in the vector space (Image Embedding) and feed the resulting vector data into Test and Score. Use Test and Score widget to assess the accuracy of the Tree learner. What is the 10-fold cross-validated classification accuracy? Which images are misclassified? Use Confusion Matrix for this task. Are the results good, ok, or terrible?

  2. Logistic Regression: Do the same for logistic regression. Which of the two classification algorithms works better? Why, what are the differences?

  3. Think: :). Why one of these classifiers so outperforms another one? What could be the reason? This question is not easy, but is related to what we have learned about neural networks. Think which types of classifiers are in the neural network, and which types of classifiers are at the very end of the neural network that were used when the neural network was trained on millions of images.

Classification

  1. Classification: load the images from "new-data" (use another Import Images), build a classifier from embeddings of "train-data" and use Predictions to classify new images. Do not forget to embed test images in the vector space, they need to be represented with numbers as well. Check the results; are the classifications as expected? Did classification it work?

  2. Experiment: add a few more images to the training set and see what happens. You can also experiment with test images that may be on the class boundary, or images that just do not fit (like an image of a mountain when in your training images are cats; check the class probabilities in the Predictions widget).

Finding Similar Images

  1. Finding similar images: use the Neighbors widget to find images from the training set (images from train-data) that are most similar to a selected new image (an image from new-data).