Skip to content

Jakub-Bielawski/ImageClfProject

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Image classification of buildings in Poznan

This is a project for Advanced image processing course on PUT. It is an image classification using BoVW model ( Bag of Visual Words)

Table of contents

General info

If something is unclear just ask :)

The BoVW is implemented as a python class (DataDescriber) which is compatible witch sklearn Pipeline which make it super easy to use parameters searching.

The target is to make image classification for five classes which are building in Poznań city:

  1. Hotel Bałtyk
  2. Katedra on Ostrów Tumski
  3. Okrąglak
  4. Teatr Wielki
  5. Uniwerystet Adama Mickiwicza

If you need the dataset for training just contact me.

Algorithm summary:

  1. Creating image features using OpenCV SIFT detector and descriptor, but using only 500 best features for each photo.
  2. After all features are collected I'm making a clustering using sklearn MiniBatchKMeans algorithm (2000 clusters) to create a vocabulary model.
  3. Transform image features into a histogram of "words" occurring in each photo using trained vocabulary model.
  4. Final step is to train a classifier where X is a histogram of words appearing on an image and y are labels for image.

Based on

Train Images

  1. Hotel Bałtyk Example screenshot
  2. Katedra on Ostrów Tumski Example screenshot
  3. Okrąglak Example screenshot
  4. Teatr Wielki Example screenshot
  5. Uniwerystet Adama Mickiwicza Example screenshot

Setup

Best way is just to run your IDE and let it install requirements.txt

but if you want to do it manually you need:

pip3 install -Iv opencv-contrib-python==4.4.0.46
pip3 install -Iv numpy==1.19.4
pip3 install -Iv colorama==0.4.4
pip3 install -Iv scikit-learn==0.23.2
pip3 install -Iv tqdm==4.54.1
pip3 install -Iv scipy==1.5.4
pip3 install -Iv pandas==1.1.5
pip3 install -Iv sklearn==0.0

Code Examples

make_classification is the function where all magic does. As I said earlier the BoVW is in python class called DataDescriber you can use it in your project as an image transformer.

To train your classifier you need to specify path to directory with images in calsses

data_path = Path('train/')  # You can change the path here

Features

List of features ready and TODOs for future development

  • Can do classification with accuracy about 90%
  • Training do not take a while

To-do list:

  • Cut down size of classifier (probably with enter exit statement)
  • Add prediction function to DataDescriber

Status

  • TODO: as in Features To Do. Feel free to ask and pull requests.
  • Finished: General concept

Inspiration

Project is inspired by Dominik Pieczyński, the course leader:)