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!