https://github.com/defi0x1/build-classifier-logisticregression
Classification countryside and metropilitian
https://github.com/defi0x1/build-classifier-logisticregression
binary-classification classification histogram-of-oriented-gradients hog-features kmeans-clustering logisticsregression opencv
Last synced: about 2 months ago
JSON representation
Classification countryside and metropilitian
- Host: GitHub
- URL: https://github.com/defi0x1/build-classifier-logisticregression
- Owner: defi0x1
- Created: 2019-05-28T04:44:55.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-06-01T15:55:28.000Z (about 7 years ago)
- Last Synced: 2025-06-26T06:46:00.322Z (12 months ago)
- Topics: binary-classification, classification, histogram-of-oriented-gradients, hog-features, kmeans-clustering, logisticsregression, opencv
- Language: Python
- Homepage:
- Size: 9.89 MB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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](https://drive.google.com/open?id=1xjVkboqPbmeEnXPyN7D2tpNRxAOhdhEa) & [countryside](https://drive.google.com/open?id=1kJjjszN0nv5y2xfn3TWqVMJSu6aAa5K5)
## Architecture
- Preprocess Images : Using opencv for imread data with function [load_image](https://github.com/minhhaui/Classification-With-HOG-K-mean-Logistic/blob/master/preprocess_image.py#L8) and resize output image (350,350)
- K-Means Clustering : We will extract dominant colors with k = 5 centroid with function [setUPKmean](https://github.com/minhhaui/Classification-With-HOG-K-mean-Logistic/blob/master/preprocess_image.py#L35)
- 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](https://github.com/minhhaui/Classification-With-HOG-K-mean-Logistic/blob/master/setup_model.py#L6) 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/`