Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/piragashparam36/image-classification
https://github.com/piragashparam36/image-classification
classification numpy pickle sklearn supervised-learning svm
Last synced: 7 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/piragashparam36/image-classification
- Owner: piragashparam36
- Created: 2024-09-08T06:32:17.000Z (25 days ago)
- Default Branch: main
- Last Pushed: 2024-09-12T03:18:45.000Z (21 days ago)
- Last Synced: 2024-09-26T04:22:16.658Z (7 days ago)
- Topics: classification, numpy, pickle, sklearn, supervised-learning, svm
- Language: Python
- Homepage:
- Size: 554 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
**Image Classification using Support Vector Machine (SVM)**
This repository contains code for classifying images into two categories: `empty` and `not_empty`. It uses a Support Vector Machine (SVM) with a grid search to find the best hyperparameters for the model. The main features of this project include loading image data, preprocessing, splitting data into training and test sets, and training the model using Scikit-learn.
How it Works:
1. Data Loading:
- The images are loaded from the specified directory (`clf-data`), which contains subfolders named `empty` and `not_empty`.
- Only valid image file formats (e.g., `.jpg`, `.png`, etc.) are processed.2. Preprocessing:
- Each image is resized to 15x15 pixels to reduce dimensionality.
- The images are then flattened into 1D arrays for model training.3. Train/Test Split:
- The data is split into training and testing sets (80/20), using stratified sampling to maintain label distribution.4. Model Training:
- A Support Vector Machine (SVC) model is trained using GridSearchCV to tune the hyperparameters (`gamma` and `C`).
- Cross-validation (5-fold) is performed to find the optimal parameters.5. Model Evaluation:
- The trained model is evaluated on the test set, and the accuracy score is printed.6. Saving the Model:
- The trained and optimized model is saved using `pickle` for future use.Dependencies:
- Python 3
- Scikit-learn
- Scikit-image
- NumPyUsage:
1. Clone the repository and navigate to the project directory.
2. Place your image data in the `clf-data` folder, with subdirectories for each category (`empty`, `not_empty`).
3. Run the script to train the classifier.
4. The trained model will be saved as `modelIC.p`.