- 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
-
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:
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
skimage
opencv-python
numpy
matplotlib
sklearn
python train.py --inputcountry path_to_countrydata/ --inputmetro path_to_metropolitiandata/
python predict.py --model path_to_model/ --image path_to_image/