Skip to content

omerugi/Preprocessing_Techniques_Image_Classification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Preprocessing Techniques for Image Classification

cat_and_dog_logo

Introduction

In this project we tried to solve a classification problem using only ML models and preprocessing techniques. The idea is not to foucuse on the models but on the preprocessing of the data to achive better results.

Models: SVM, KNN, Random Forest, Logistic Regression.

Preprocessing Techniques: Edge detection, MeanRGB, and feature-extraction - Bag of Visual Words (SIFT, k-means, histograms).

Dataset

image

Link: https://www.kaggle.com/tongpython/cat-and-dog

This dataset contains difficult data cats and dogs - different sizes and dirty imgs. The training contains 8k imgs and test 1k, with even numbers of images from each label. Because the dataset is of raw images first we need to read each one, resize, and then reffer to the pixels as featuers. The featuers for each sample is big meaning the demention is big, while also they have no "sence" behind them only the pixel value, this makes the classification problem all the more difficult.

Bssic Ground Truth

To have a basic result to compare with, we did simple preprocessing and tested the models.

  1. Resize - set all the images to the same size.
  2. Gray Scale - reduce the demention from 3 (RGB) to 1 (Gray)
  3. Flatteren
  4. Test Models - SVM, KNN, Random Forest, Logistic Regression

Data Preprocessing

Gray Scale

Reduce the demention from 3 (RGB) to 1 (Gray), each pixel value will be 0-255.

Mean RGB

Reduce the demention from 3 (RGB) to 1, but each pixel value will be the mean value from each on of the dementions - Red Green Blue.

Edge detection

Finding the eadges of the images and use the result. At first we wanted to use Canny but wanted to use a more modern model.

Using Structured Forests / Structured Edge detector - For more details: https://debuggercafe.com/edge-detection-using-structured-forests-with-opencv/

BoVW - Bag of visual words (Feature extraction)

How to:

  1. Read each sample as RGB and resize 90x90
  2. Extraction of 50 key points, that would be the new features, using SIFT. (each key point is represented as a vector of size 128)
  3. Using K-Means clustering on the new features we extracted, this in order to cluster togther similar feature groups.
  4. For each smaple create a histogram - the size of the hist is the amount of centers from the K-Means. And for each smaple we count the fetuers it contains.
  5. Normalizing
  6. Run the models on the hist that represent each smaple.

Parameters Optimization

Grid Search

Receving many parametes and try to find the best combination.

Random Grid Search

Receving many parametes, but is randomly picking parameters to find a good combination that give good results. The idea is to optimize the parametes search and not try all combinations.

Results

Models with Parameters Optimization

image

image

Models with Data Preprocessing

image

BoVW

image

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published