Students will build a Convolutional Neural Network (CNN) model to classify images from a given dataset into predefined categories/classes.
- The dataset for this task is the CIFAR-10 dataset, which consists of 60,000 32x32 color images in 10 classes, with 6,000 images per class. You can download the dataset from here.
- The second dataset contains about 28,000 medium quality animal images belonging to 10 categories: dog, cat, horse, spyder, butterfly, chicken, sheep, cow, squirrel, elephant. The link is here.
-
Data Preprocessing
- Data loading and preprocessing (e.g., normalization, resizing, augmentation).
- Create visualizations of some images, and labels.
-
Model Architecture
- Design a CNN architecture suitable for image classification.
- Include convolutional layers, pooling layers, and fully connected layers.
-
Model Training
- Train the CNN model using appropriate optimization techniques (e.g., stochastic gradient descent, Adam).
- Utilize techniques such as early stopping to prevent overfitting.
-
Model Evaluation
- Evaluate the trained model on a separate validation set.
- Compute and report metrics such as accuracy, precision, recall, and F1-score.
- Visualize the confusion matrix to understand model performance across different classes.
-
Transfer Learning
- Evaluate the accuracy of your model on a pre-trained models like ImagNet, VGG16, Inception... (pick one an justify your choice)
- Perform transfer learning with your chosen pre-trained models i.e., you will probably try a few and choose the best one.
-
Code Quality
- Well-structured and commented code.
- Proper documentation of functions and processes.
- Efficient use of libraries and resources.
-
Report
- Write a concise report detailing the approach taken, including:
- Description of the chosen CNN architecture.
- Explanation of preprocessing steps.
- Details of the training process (e.g., learning rate, batch size, number of epochs).
- Results and analysis of models performance.
- What is your best model. Why?
- Insights gained from the experimentation process.
- Include visualizations and diagrams where necessary.
- Write a concise report detailing the approach taken, including:
-
Model deployment
- Pick the best model
- Build an app using Flask - Can you host somewhere other than your laptop? +5 Bonus points if you use Tensorflow Serving
- User should be able to upload one or multiples images get predictions including probabilities for each prediction
- Accuracy of the trained models on the validation set. 30 points
- Clarity and completeness of the report. 20 points
- Quality of code implementation. 5 points
- Proper handling of data preprocessing and models training. 30 points
- Demonstration of understanding key concepts of deep learning. 5 points
- Model deployment. 10 points
Passing Score is 70 points.
- Deadline for submission: end of the week or as communicated by your teaching team.
- Submit the following:
- Python code files (
*.py
,ipynb
) containing the model implementation and training process. - A data folder with 5-10 images to test the deployed model/app if hosted somewhere else other than your laptop (strongly recommended! Not a must have)
- A PDF report documenting the approach, results, and analysis.
- Any additional files necessary for reproducing the results (e.g., requirements.txt, README.md).
- PPT presentation
- Python code files (
- Students are encourage to experiment with different architectures, hyper-parameters, and optimization techniques.
- Provide guidance and resources for troubleshooting common issues during model training and evaluation.
- Students will discuss their approaches and findings in class during assessment evaluation sessions.
This repository now includes a minimal Flask inference API (app.py
) serving predictions for CIFAR-10 using best_model_cifar10.pth
.
File | Purpose |
---|---|
app.py |
Flask server with /health and /predict |
requirements.txt |
Runtime dependencies |
Procfile |
Process definition (web) |
railway.toml |
Railway deploy config |
.gitignore |
Ignore notebooks, data, venv |
python3 -m venv .venv
source .venv/bin/activate # macOS/Linux
pip install --upgrade pip
pip install -r requirements.txt
python app.py
# Test
curl http://localhost:8000/health
curl -X POST -F "file=@some_image.png" http://localhost:8000/predict
If your checkpoint is only a state_dict:
torch.save({'state_dict': model.state_dict()}, 'best_model_cifar10.pth')
The loader also accepts a full model object (saved via torch.save(model, path)
).
- Push repo to GitHub (include model file if small; if large, store externally + download in a build step).
- In Railway: New Project -> Deploy from GitHub.
- Railway installs
requirements.txt
and runspython app.py
(fromProcfile
). - Open the generated URL:
/health
returns{ "status": "ok" }
./predict
expects multipart form-data with keyfile
.
Example request after deploy:
curl -X POST -F "file=@some_image.png" https://YOUR-SUBDOMAIN.up.railway.app/predict
Set MODEL_PATH
if the model filename/location changes.
- Add authentication (API key header)
- Add Swagger UI docs
- Batch prediction endpoint
- Caching repeated images (hash + Redis)
- Transfer learning endpoints (load different models via query)
Deployment scaffold included to satisfy the Model Deployment assessment component.