Skip to content

About

No description, website, or topics provided.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

STL-10 Image Classifier

Deep learning image classification model trained on the STL-10 dataset, achieving 91.96% test accuracy using transfer learning with ResNet50.

Overview

This project implements a state-of-the-art image classifier capable of recognizing 10 different object categories:

  • Airplane
  • Bird
  • Car
  • Cat
  • Deer
  • Dog
  • Horse
  • Monkey
  • Ship
  • Truck

Performance

  • Test Accuracy: 91.96%
  • Training Accuracy: 99.08%
  • Model Architecture: ResNet50 (pretrained on ImageNet)
  • Dataset: STL-10 (5,000 training images, 8,000 test images)
  • Training Time: ~2.5 hours on GPU (100 epochs)

Features

  • GUI Application: Easy-to-use graphical interface for image classification
  • Command-line Tools: Quick prediction scripts for batch processing
  • Pre-trained Model: Ready-to-use model with 91.96% accuracy
  • Google Colab Support: Complete training pipeline for cloud training

Installation

Requirements

  • Python 3.8+
  • PyTorch 1.9+
  • torchvision
  • Pillow
  • tqdm
  • matplotlib

Setup

  1. Clone the repository:
git clone https://github.com/freeknowledge2/Object-Recognition.git
cd Object-Recognition
  1. Create virtual environment:
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Download the pre-trained model:
    • The model file best_model_STL10.pt should be placed in the project root
    • Size: ~283 MB

Usage

GUI Application

Launch the graphical interface for interactive image classification:

python gui_classifier.py

Features:

  • Drag-and-drop image selection
  • Real-time predictions with confidence scores
  • Top-3 results display
  • Support for PNG, JPG, JPEG, BMP, GIF formats

Command-line Prediction

Quick Single Image Prediction

python quick_predict.py path/to/image.jpg

Batch Processing

python use_model.py

Interactive menu options:

  1. Classify single image
  2. Process all images in test_images folder
  3. Process all images in train_images folder
  4. Specify custom folder path

Training from Scratch

Local Training

The project includes pre-configured training scripts. However, for full training, Google Colab is recommended due to GPU requirements.

Google Colab Training

  1. Open the training notebook in Google Colab
  2. Upload colab_training.py
  3. Run the cells in order
  4. Model checkpoints will be automatically saved to Google Drive

See TRAINING.md for detailed training instructions.

Model Architecture

SmartModel (ResNet50-based)
├── ResNet50 Backbone (pretrained on ImageNet)
└── Custom Classifier Head
    ├── Dropout(0.4)
    ├── Linear(2048 → 512)
    ├── ReLU + BatchNorm
    ├── Dropout(0.3)
    ├── Linear(512 → 256)
    ├── ReLU + BatchNorm
    ├── Dropout(0.2)
    └── Linear(256 → 10)

Training Configuration

  • Optimizer: AdamW (lr=0.0003, weight_decay=0.01)
  • Scheduler: CosineAnnealingLR (T_max=100, eta_min=1e-6)
  • Loss Function: CrossEntropyLoss with label smoothing (0.1)
  • Batch Size: 64
  • Epochs: 100
  • Data Augmentation:
    • RandomCrop(96, padding=12)
    • RandomHorizontalFlip(p=0.5)
    • RandomRotation(15°)
    • ColorJitter(brightness=0.3, contrast=0.3, saturation=0.3, hue=0.1)
    • RandomGrayscale(p=0.1)

Project Structure

Object-Recognition/
├── gui_classifier.py          # GUI application
├── quick_predict.py           # Quick CLI prediction
├── use_model.py              # Full-featured CLI tool
├── colab_training.py         # Google Colab training script
├── best_model_STL10.pt       # Pre-trained model weights
├── training_results.png      # Training curves visualization
├── requirements.txt          # Python dependencies
├── .gitignore               # Git ignore rules
├── README.md                # This file
└── docs/
    ├── TRAINING.md          # Training guide
    ├── API.md               # API documentation
    └── BENCHMARKS.md        # Performance benchmarks

Results

Training Curves

Training Results

Confusion Matrix

The model shows excellent performance across all categories with minimal confusion between similar classes (e.g., dog/cat, car/truck).

Performance by Class

Class Precision Recall F1-Score
Airplane 0.94 0.93 0.93
Bird 0.89 0.91 0.90
Car 0.95 0.94 0.94
Cat 0.88 0.87 0.87
Deer 0.91 0.92 0.91
Dog 0.90 0.89 0.89
Horse 0.93 0.95 0.94
Monkey 0.92 0.91 0.91
Ship 0.95 0.96 0.95
Truck 0.93 0.92 0.92

Benchmarks

Comparison with published STL-10 results:

Method Test Accuracy
This Implementation 91.96%
Literature Average 80-85%
ResNet50 (baseline) 78.3%
VGG-16 74.2%

Documentation

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • STL-10 dataset creators
  • PyTorch team for the deep learning framework
  • ResNet architecture by He et al.
  • Google Colab for providing free GPU resources

Author

freeknowledge2

Citation

If you use this code in your research, please cite:

@software{stl10_classifier,
  author = {freeknowledge2},
  title = {STL-10 Image Classifier with 91.96% Accuracy},
  year = {2025},
  url = {https://github.com/freeknowledge2/Object-Recognition}
}

Contact

For questions or issues, please open an issue on GitHub or contact through the repository.


Built with PyTorch and passion for computer vision.

About

No description, website, or topics provided.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages