A modern, full-stack image classification system with a beautiful web dashboard for training, monitoring, and deploying CIFAR-10 models. Built with Astro, TensorFlow, and Flask, optimized for deployment on Vercel.
- Dataset Explorer - Visualize CIFAR-10 training and test samples
- Model Training - Train CNN models with customizable hyperparameters
- Real-time Monitoring - Track training progress with interactive charts
- Model Management - Download and manage trained models
- Predictions - Test models with custom image uploads
- Premium Dark Theme with glassmorphism effects
- Smooth Animations and micro-interactions
- Responsive Design for all devices
- Real-time Updates with WebSocket-like polling
- Interactive Charts using Chart.js
- Modular Architecture with clean separation of concerns
- Improved CNN with BatchNormalization layers
- Data Augmentation for better model generalization
- Automatic Callbacks (EarlyStopping, ReduceLROnPlateau, ModelCheckpoint)
- Progress Logging for web dashboard integration
- Vercel Deployment ready with serverless functions
ImageClasifier/
├── frontend/ # Astro frontend application
│ ├── src/
│ │ ├── components/ # Astro components
│ │ │ ├── DatasetExplorer.astro
│ │ │ ├── TrainingPanel.astro
│ │ │ ├── ProgressMonitor.astro
│ │ │ ├── ModelsManager.astro
│ │ │ └── PredictionPanel.astro
│ │ ├── layouts/ # Page layouts
│ │ │ └── Layout.astro
│ │ ├── pages/ # Routes
│ │ │ └── index.astro
│ │ └── scripts/ # Client-side JavaScript
│ │ └── main.js
│ ├── astro.config.mjs # Astro configuration
│ └── package.json
│
├── backend/ # Python backend
│ ├── api/ # Flask API
│ │ └── app.py # Main API server
│ ├── model.py # CNN model architecture
│ ├── data_loader.py # Dataset loading & preprocessing
│ ├── trainer.py # Training utilities
│ ├── train.py # Training script
│ └── test.py # Testing & evaluation
│
├── api/ # Vercel serverless functions
│ └── index.py # API entry point
│
├── results/ # Trained models & logs
├── logs/ # TensorBoard logs
├── vercel.json # Vercel deployment config
├── requirements.txt # Python dependencies
└── README.md
- Python 3.10-3.12 (3.10 recommended for Vercel)
- Node.js 18+
- npm or yarn
git clone <your-repo-url>
cd ImageClasifierpip install -r requirements.txtcd frontend
npm install
cd ..cd frontend
cp .env.example .env
# Edit .env if needed for custom API URL
cd ..Terminal 1 - Start Backend API:
cd backend/api
python app.pyThe API will run on http://localhost:5000
Terminal 2 - Start Frontend Dev Server:
cd frontend
npm run devThe frontend will run on http://localhost:4321
cd backend
python train.pycd backend
python test.pynpm install -g vercelvercelFollow the prompts to deploy. Vercel will automatically:
- Build the Astro frontend
- Deploy Python API as serverless functions
- Configure routing between frontend and API
In Vercel dashboard, add:
PUBLIC_API_URL- Your API endpoint (auto-configured)
Input (32x32x3)
↓
[Conv2D(32) → BatchNorm → ReLU → Conv2D(32) → BatchNorm → ReLU → MaxPool → Dropout(0.25)]
↓
[Conv2D(64) → BatchNorm → ReLU → Conv2D(64) → BatchNorm → ReLU → MaxPool → Dropout(0.25)]
↓
[Conv2D(128) → BatchNorm → ReLU → Conv2D(128) → BatchNorm → ReLU → MaxPool → Dropout(0.25)]
↓
[Flatten → Dense(1024) → BatchNorm → ReLU → Dropout(0.5)]
↓
Dense(10, softmax)
- Optimizer: Adam with configurable learning rate
- Data Augmentation: Random flips, brightness, contrast
- Callbacks:
- ModelCheckpoint (save best model)
- EarlyStopping (prevent overfitting)
- ReduceLROnPlateau (adaptive learning rate)
- TensorBoard logging
- Custom progress tracking for web UI
- View dataset statistics
- Browse 10 CIFAR-10 categories
- Visualize random samples from train/test sets
- Interactive sample grid with hover effects
- Configure epochs, batch size, learning rate
- Start training with one click
- Real-time status updates
- Auto-redirect to progress monitor
- Live training/validation accuracy charts
- Live training/validation loss charts
- Learning rate schedule visualization
- Training summary with key metrics
- List all trained models
- View model size and modification date
- One-click model download
- Automatic model selection for predictions
- Drag & drop image upload
- Select model for inference
- View prediction with confidence score
- See probability distribution for all classes
Edit in backend/train.py:
config = {
"batch_size": 64, # Batch size for training
"epochs": 30, # Number of training epochs
"learning_rate": 0.001, # Initial learning rate
"use_augmentation": True, # Enable data augmentation
"model_name": "cifar10-cnn-v2",
"log_dir": "logs",
"model_dir": "results"
}Edit in backend/api/app.py:
RESULTS_DIR = "results" # Model storage directory
LOGS_DIR = "logs" # TensorBoard logs directoryEdit in frontend/.env:
PUBLIC_API_URL=http://localhost:5000/api # API endpoint- Training Accuracy: ~85-90%
- Validation Accuracy: ~75-80%
- Training Time: ~15-20 minutes (30 epochs, GPU)
- Model Size: ~50-60 MB
- Use GPU: Install
tensorflow-gpufor faster training - Increase Batch Size: If you have enough memory
- Data Augmentation: Already enabled for better generalization
- Learning Rate: Use ReduceLROnPlateau callback (already configured)
1. TensorFlow Installation Issues
# For M1/M2 Macs
pip install tensorflow-macos tensorflow-metal
# For other systems
pip install tensorflow==2.15.02. Port Already in Use
# Change port in backend/api/app.py
app.run(debug=True, host='0.0.0.0', port=5001) # Use different port3. CORS Errors
- Ensure Flask-CORS is installed
- Check API_BASE_URL in frontend configuration
4. Model Not Found
- Train a model first using
python backend/train.py - Check
results/directory for.h5files
GET /api/health- Health checkGET /api/dataset/info- Dataset informationGET /api/dataset/samples- Get sample images
POST /api/training/start- Start trainingGET /api/training/status- Get training statusGET /api/training/progress- Get training progressGET /api/training/summary- Get training summary
GET /api/models/list- List trained modelsGET /api/models/download/<filename>- Download model
POST /api/predict- Make prediction on uploaded image
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source and available under the MIT License.
- CIFAR-10 Dataset: Alex Krizhevsky, Vinod Nair, and Geoffrey Hinton
- TensorFlow: Google Brain Team
- Astro: The Astro Technology Company
- Chart.js: Chart.js Contributors
For questions or support, please open an issue on GitHub.