Skip to content

defi0x1/Build-Classifier-LogisticRegression

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Classification-With-HOG-K-mean-Logistic

Intuition

  • Build a Classifier to classify metropolitian & countryside
  • Using:
    • K-Means clustering, histogram (HOG) for prerocess data and extract features
    • LogisticsRegression for classify metropolitian and countryside
  • Data: metropolitian & countryside

Architecture

  • Preprocess Images : Using opencv for imread data with function load_image and resize output image (350,350)

  • K-Means Clustering : We will extract dominant colors with k = 5 centroid with function setUPKmean

  • HOG (Histogram Oriented Gradients) : Construct the features vector for each image using 5 clustered RGB colors, sorted by color frequency.

  • LogisticRegression : We use Logistic Regression model to classify the feature vectors built from the HOG. Implement the Gradient Descent method to optimize the model.

     batch_size = 32 epochs = 10 threshold = 0.5 learning_rate = 0.001 
  • Accuracy: 73.8 % with 1206 samples ( validation set = 20% , training set = 80%)

  • Output K-means Clustering with centroid = 5:

  • Vector Histogram:

  • Ouput HOG:

Tree Project

 Classification/ model/ model.sav # model results after training resources_data/ countryside # contains data of countryside ( have some image for intuition) metropolitian # contains data of metropilitian ( have some image for intuition) image_predict # contains image for test predict output_image_test # some results of k-mean and hog predict.py # predict some image from resources_data/image_predict with args pathto model preprocess_image.py # contains imread data, fit k-mean and hog setup_model.py # Build LogisicRegression from scatch train.py # start training with args path data train 

USAGE:

Requirements

 skimage opencv-python numpy matplotlib sklearn 

Training

python train.py --inputcountry path_to_countrydata/ --inputmetro path_to_metropolitiandata/

prediction

python predict.py --model path_to_model/ --image path_to_image/

Releases

No releases published

Packages

No packages published

Languages