A production-ready image classification system for the Fashion MNIST dataset, featuring a CNN model with ~92% accuracy, REST API, and interactive web interface.
You can deploy this application directly to Streamlit Cloud to see it in action:
Note: After deploying, update the link above to your specific app URL.
# Clone repository
git clone https://github.com/millenniumsingha/StyleNet.git
cd StyleNet
# Train model and start services
docker-compose --profile training up train
docker-compose up -d api streamlit
# Access:
# - API Docs: http://localhost:8000/docs
# - Web App: http://localhost:8501# Install dependencies
pip install -r requirements.txt
# Train model
python -m src.train --model cnn --epochs 15
# Start API
uvicorn api.main:app --reload
# Start Web App (new terminal)
streamlit run app/streamlit_app.py| Model | Test Accuracy | Parameters |
|---|---|---|
| Simple (Original) | ~88% | ~101K |
| CNN (Current) | ~92% | ~400K |
Input (28x28x1)
β
βΌ
βββββββββββββββββββ
β Conv Block 1 β 32 filters, BatchNorm, MaxPool, Dropout
ββββββββββ¬βββββββββ
β
ββββββββββΌβββββββββ
β Conv Block 2 β 64 filters, BatchNorm, MaxPool, Dropout
ββββββββββ¬βββββββββ
β
ββββββββββΌβββββββββ
β Conv Block 3 β 128 filters, BatchNorm, MaxPool, Dropout
ββββββββββ¬βββββββββ
β
ββββββββββΌβββββββββ
β Dense (256) β BatchNorm, Dropout
ββββββββββ¬βββββββββ
β
ββββββββββΌβββββββββ
β Output (10) β Softmax
βββββββββββββββββββ
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
API information |
| GET | /health |
Health check |
| GET | /classes |
List class names |
| POST | /predict |
Classify single image |
| POST | /predict/batch |
Classify multiple images |
curl -X POST "http://localhost:8000/predict" \
-H "Content-Type: multipart/form-data" \
-F "file=@your_image.png"{
"success": true,
"predicted_class": "Ankle boot",
"predicted_index": 9,
"confidence": 0.97,
"top_predictions": [
{"class_name": "Ankle boot", "class_index": 9, "confidence": 0.97},
{"class_name": "Sneaker", "class_index": 7, "confidence": 0.02},
{"class_name": "Sandal", "class_index": 5, "confidence": 0.01}
]
}βββ src/ # Core ML code
β βββ model.py # CNN architecture
β βββ train.py # Training script
β βββ predict.py # Inference utilities
βββ api/ # FastAPI backend
β βββ main.py # REST API endpoints
βββ app/ # Streamlit frontend
β βββ streamlit_app.py # Web interface
βββ tests/ # Unit tests
βββ models/ # Saved models
βββ notebooks/ # Jupyter notebooks
βββ legacy/ # Original project files
# Run all tests
pytest tests/ -v
# With coverage
pytest tests/ --cov=src --cov=api# CNN model (recommended)
python -m src.train --model cnn --epochs 15
# Simple model (for comparison)
python -m src.train --model simple --epochs 10| Index | Class |
|---|---|
| 0 | T-shirt/top |
| 1 | Trouser |
| 2 | Pullover |
| 3 | Dress |
| 4 | Coat |
| 5 | Sandal |
| 6 | Shirt |
| 7 | Sneaker |
| 8 | Bag |
| 9 | Ankle boot |
- Model versioning with MLflow
- CI/CD pipeline with GitHub Actions
- Kubernetes deployment configs
- Model monitoring and drift detection
- A/B testing framework
The project uses GitHub Actions for Continuous Integration and Deployment:
- Build & Test: runs on every push to verify code quality.
- Docker Build: pushes new images to GitHub Container Registry (GHCR) on release.
Experiments are tracked using MLflow.
# Start MLflow server
docker-compose up -d mlflow
# View dashboard at http://localhost:5000Data drift is monitored comparing production traffic against training data.
- Drift Logic: Implemented in
src/monitoring.py. - Logs: Predictions are logged to
monitoring/current_data.csv.
Deploy to a cluster using the manifests in k8s/:
kubectl apply -f k8s/Includes:
- API: 2 Replicas, Health Checks.
- Streamlit: LoadBalancer Service.
Traffic is routed between stable and canary models based on environment variables:
- Set
AB_TEST_RATIO=0.2to send 20% of traffic to the canary model.
- Fashion MNIST Dataset by Zalando Research
- TensorFlow and Keras teams
- FastAPI and Streamlit communities
Originally created as a learning project, upgraded to production-ready status.
