Image Classification with Scikit-Learn and Feature Extraction
In this project, I trained an image classifier using Scikit-Learn’s Random Forest Classifier to categorize images from the Intel Image Classification Dataset. The dataset comprises six categories: buildings, forests, glaciers, mountains, seas, and streets. This diversity provided an excellent test bed for applying machine learning techniques to real-world visual data.
To extract meaningful features from the images, I utilized the Img2Vec library. This library allowed me to leverage pre-trained neural networks to convert raw images into compact feature vectors, effectively summarizing the visual information into a format suitable for machine learning models. These extracted features were then used as input for the Random Forest Classifier, which is known for its robustness and interpretability in classification tasks.
The overall process involved data preprocessing, feature extraction, and model training. The trained model achieved an accuracy score of 90.77% on the validation set, demonstrating its effectiveness in recognizing the different categories in the dataset.
GitHub: https://github.com/BrandtBrandtBrandt/image-classifier-scikit.git
Advantages of This Approach
Efficient Feature Extraction:
Using a pre-trained ResNet18 model avoids the need for computationally expensive training of a deep learning model.
It simplifies the process by transforming high-dimensional image data into a manageable, meaningful numerical format.
Scikit-learn for Simplicity and Robustness:
Random Forest is straightforward to implement and often performs well out of the box.
It is robust against overfitting, especially when properly tuned.
Why This Pipeline?
Scalability: Pre-trained models like ResNet18 make it easy to scale feature extraction across different datasets without significant changes.
Efficiency: The combination of feature extraction and a Random Forest Classifier is computationally efficient, avoiding the need for end-to-end deep learning training.
This project employed several technologies, including Python for scripting, PIL (Python Imaging Library) for image handling, and Scikit-Learn for machine learning. The Img2Vec library served as the backbone for feature extraction, enabling the use of pre-trained deep learning models without the need to build one from scratch.
As a follow-up, I plan to experiment with other libraries, such as YOLO, to compare their performance on the same dataset and explore their potential in real-time classification tasks.