https://github.com/hk151109/image-classification-using-svm
This repository contains the implementation of an image classification system using a Support Vector Machine (SVM). The goal of the project is to classify images of cats and dogs stored in two folders (train and test1). The classifier is trained on a labeled dataset and used to predict the category of unseen images from the test folder.
https://github.com/hk151109/image-classification-using-svm
imageclassification internship machine-learning svm
Last synced: 4 months ago
JSON representation
This repository contains the implementation of an image classification system using a Support Vector Machine (SVM). The goal of the project is to classify images of cats and dogs stored in two folders (train and test1). The classifier is trained on a labeled dataset and used to predict the category of unseen images from the test folder.
- Host: GitHub
- URL: https://github.com/hk151109/image-classification-using-svm
- Owner: hk151109
- Created: 2024-11-24T09:26:02.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-17T18:20:19.000Z (about 1 year ago)
- Last Synced: 2025-07-17T12:15:53.307Z (7 months ago)
- Topics: imageclassification, internship, machine-learning, svm
- Language: Python
- Homepage:
- Size: 25.2 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Image Classification Using SVM
## Project Overview
This repository contains the implementation of an image classification system using a Support Vector Machine (SVM). The goal of the project is to classify images of cats and dogs stored in two folders (`train` and `test1`). The classifier is trained on a labeled dataset and used to predict the category of unseen images from the test folder.
## Index
- [Project Overview](#project-overview)
- [Features](#features)
- [File Structure](#file-structure)
- [Steps to Run](#steps-to-run)
- [Dependencies](#dependencies)
- [Results](#results)
- [Dataset](#dataset)
- [License](#license)
## Features
### Data Preprocessing
- Image resizing to a consistent size (64x64 pixels)
- Flattening images to 1D arrays for model input
- Scaling the pixel values using StandardScaler
- Dimensionality reduction using PCA to improve classifier performance
### Classification
- Support Vector Machine (SVM) classifier with a linear kernel
- Binary classification: "cat" or "dog"
### Predictions
- Classify all images in the `test1` folder
- Store results in a CSV file with image number and predicted category
- Option to predict a specific image from the test folder
## File Structure
```
project_root/
│ image_classifications.csv
│ cats&dogs.py
│
├───test1
│ ├── 1.jpg
│ ├── 2.jpg
│ └── ...
└───train
├───cat
│ ├── cat.0.jpg
│ ├── cat.1.jpg
│ └── ...
└───dog
├── dog.0.jpg
├── dog.1.jpg
└── ...
```
## Prerequisites
### System Requirements
- Python 3.7+
- Minimum 4GB RAM
- Sufficient disk space for dataset
### Dependencies
Install the required libraries using pip:
```bash
pip install opencv-python numpy scikit-learn pandas
```
## Installation
1. Clone the repository:
```bash
git clone https://github.com/hk151109/Image-Classification-Using-SVM.git
```
2. Download the dataset from [Kaggle Dogs vs Cats Competition](https://www.kaggle.com/competitions/dogs-vs-cats/data)
3. Organize your dataset:
- Place training images in the `train/` directory
- Place test images in the `test1/` directory
## Usage
### Training the Model
```bash
python cats&dogs.py
```
This script will:
- Preprocess images
- Train the SVM classifier
- Save the trained model
- Classify images in the test folder
- Generate `image_classifications.csv`
### Predicting a Specific Image
After running the script, you can predict a specific image by entering its number when prompted.
## Results
The `image_classifications.csv` will contain:
- `image`: Image number
- `category`: Predicted category ("cat" or "dog")
## License
MIT License - see LICENSE file for details