An advanced Image Recognition System using Convolutional Neural Networks (CNN) with Python, Flask, and TensorFlow - Optimized for CPU Performance.
- ✅ 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
- Python 3.8 or higher
- pip package manager
- Clone the repository
git clone https://github.com/DATDSG/SF_Project.git
cd SF_Project- Install dependencies
pip install -r requirements.txt- Run the application
python app.py- Open your browser
Navigate to
http://localhost:5000(development mode)
To train the model from scratch:
- Open the Jupyter notebook:
jupyter notebook cifar10_model_training.ipynb- 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
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
- 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
-
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
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
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
- 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
GET /- Home pagePOST /predict- Upload and classify imagesGET /goback- Clean up and return to home
- File extension whitelist
- Secure filename handling
- Basic error handling
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
DATDSG
- GitHub: @DATDSG
- CIFAR-10 dataset by Alex Krizhevsky
- TensorFlow and Keras teams
- Flask framework
- Bootstrap and Font Awesome for UI components
For questions or support, please open an issue on GitHub.
⭐ Star this repository if you find it helpful!