Skip to content

DATDSG/SF_Project

Repository files navigation

🖼️ CIFAR-10 Image Classification System

An advanced Image Recognition System using Convolutional Neural Networks (CNN) with Python, Flask, and TensorFlow - Optimized for CPU Performance.

Python TensorFlow Flask License

🌟 Features

  • CPU-Optimized - Runs efficiently on standard hardware without GPU
  • Modern UI - Beautiful, responsive interface with drag-and-drop support
  • Real-time Classification - Instant predictions with confidence scores
  • Batch Processing - Upload and classify multiple images simultaneously
  • 10 Object Classes - Airplane, Automobile, Bird, Cat, Deer, Dog, Frog, Horse, Ship, Truck
  • Performance Metrics - View throughput, latency, and processing time

🚀 Quick Start

Prerequisites

  • Python 3.8 or higher
  • pip package manager

Installation

  1. Clone the repository
git clone https://github.com/DATDSG/SF_Project.git
cd SF_Project
  1. Install dependencies
pip install -r requirements.txt
  1. Run the application
python app.py
  1. Open your browser Navigate to http://localhost:5000 (development mode)

📊 Model Training

To train the model from scratch:

  1. Open the Jupyter notebook:
jupyter notebook cifar10_model_training.ipynb
  1. Run all cells sequentially to:
    • Load and preprocess CIFAR-10 dataset
    • Build and train the advanced CNN model with batch normalization
    • Evaluate performance on test set
    • Generate confusion matrix and classification metrics
    • Save the trained model with metadata

Model Performance Metrics

The advanced CNN model achieves strong performance on CIFAR-10:

  • Architecture: 3 Convolutional Blocks + 2 Dense Layers

  • Key Features:

    • Batch Normalization for faster convergence
    • L2 Regularization (1e-4) to prevent overfitting
    • Dropout (0.25-0.5) for improved generalization
    • Data Augmentation (rotation, zoom, shift, flip)
  • Training Configuration:

    • Epochs: 50 with early stopping (patience=5)
    • Batch Size: 128
    • Optimizer: Adam (learning rate 0.001)
    • Learning Rate Reduction: On plateau
    • Train/Validation Split: 80/20
  • Results (Available in notebook kernel):

    • Test Accuracy: Available from kernel variables
    • Test Loss: Available from kernel variables
    • Per-Class Accuracy: Computed via confusion matrix
    • Training Time: Logged during training

🎨 User Interface

Main Page

  • Drag-and-drop file upload with visual feedback
  • Multiple image selection with preview
  • Modern gradient header with "Advanced CNN" badge
  • Enhanced info box with classification details
  • Supported formats: PNG, JPG, JPEG, GIF, BMP, WEBP

Results Page

  • Performance Metrics Dashboard:

    • Images Processed count
    • Throughput (images/second)
    • Average Latency (milliseconds)
    • Total Processing Time
  • Classification Results Cards:

    • Individual image preview with overlay effect
    • Predicted class with semantic icon
    • Confidence score with animated progress bar
    • Color-coded confidence levels (High/Medium/Low)
    • Responsive card-based layout with animations
  • Action Buttons:

    • Classify More Images button
    • Print Results button for documentation

🏗️ Architecture

Advanced CNN Model

Input (32x32x3 RGB Images)
    ↓
Block 1:
├─ Conv2D (32 filters, 3x3) + BatchNorm + ReLU
├─ Conv2D (32 filters, 3x3) + BatchNorm + ReLU + MaxPool2D
    ↓
Block 2:
├─ Conv2D (64 filters, 3x3) + BatchNorm + ReLU
├─ Conv2D (64 filters, 3x3) + BatchNorm + ReLU + MaxPool2D
    ↓
Block 3:
├─ Conv2D (128 filters, 3x3) + BatchNorm + ReLU
├─ Conv2D (128 filters, 3x3) + BatchNorm + ReLU + MaxPool2D
    ↓
Dropout (0.5)
    ↓
Flatten
    ↓
Dense (256 units) + BatchNorm + ReLU + Dropout (0.5)
    ↓
Dense (128 units) + BatchNorm + ReLU + Dropout (0.25)
    ↓
Dense (10 units) + Softmax

Project Structure

SF_Project/
├── app.py                               # Flask application (enhanced)
├── essentials.py                        # Image processing & prediction
├── config.py                            # Centralized configuration
├── requirements.txt                     # Dependencies (optimized)
├── .gitignore                          # Version control exclusions
├── README.md                           # This file
├── setup.bat                           # Windows setup script
├── run.bat                             # Windows launch script
│
├── model/
│   ├── cifar10_advanced_cnn.h5        # Trained Advanced CNN model
│   └── model_metadata.json             # Model info & metrics
│
├── static/
│   ├── css/
│   │   └── style.css                  # Main stylesheet (modern design)
│   ├── js/
│   │   └── main.js                    # Client-side functionality
│   └── uploads/                       # Temporary upload storage
│
├── templates/
│   ├── main.html                      # Home page (modern UI)
│   └── testingoutput.html             # Results page (enhanced)
│
└── docs/
    ├── DEPLOYMENT.md                  # Deployment guide
    └── STRUCTURE.md                   # Detailed architecture

⚡ Performance

  • Training: 50 epochs with early stopping, batch size 128
  • Inference: Batch processing supported
  • CPU Optimization: Vectorized operations for CPU compatibility
  • Latency: Sub-second inference on CPU
  • Throughput: Multiple images/second in batch mode
  • Accuracy: ~70-75% on CIFAR-10 test set

📝 API Endpoints

  • GET / - Home page
  • POST /predict - Upload and classify images
  • GET /goback - Clean up and return to home

🛡️ Security Features

  • File extension whitelist
  • Secure filename handling
  • Basic error handling

🤝 Contributing

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

📄 License

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

👨‍💻 Author

DATDSG

🙏 Acknowledgments

  • CIFAR-10 dataset by Alex Krizhevsky
  • TensorFlow and Keras teams
  • Flask framework
  • Bootstrap and Font Awesome for UI components

📧 Contact

For questions or support, please open an issue on GitHub.


⭐ Star this repository if you find it helpful!

About

Image Recognition ML Project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •