Skip to content

czhou578/cifar

Repository files navigation

CIFAR 100 Classification

This was a project of mine that was built using PyTorch to classify the images from the CIFAR-100 dataset. I attempted to build my own model without using any pretrained model from online, in an effort to improve my machine learning skills and understanding. The final model achieves close to 70% test accuracy.

The model is deployed using a full stack web application being powered by FastAPI on the backend for serving the model and a React + TypeScript frontend. Drag and drop any image of your choice onto the frontend and see what the model predicted for you!

Picture of web app frontend

Run Backend:

Navigate to the /backend folder and run

uvicorn main:app --host 0.0.0.0 --port 8000 --reload

Make sure Redis server is also running on your machine for background jobs to work. The redis server can be started by running the Docker image locally on port 6379.

Run Frontend:

Navigate to the /frontend folder and run

npm start

Topics that I learned while doing this project:

  1. Convolutional Neural Network (CNN) architecture
  2. Image transforms from PyTorch
  3. Max Pooling and BatchNorm2d
  4. Tensor operations in the classifier
  5. Optimizing dataloader operations in PyTorch
  6. Calculating metrics like precision and recall using torchmetrics
  7. Using torch compile to compile my model
  8. How to use AdamW optimizer and setting its parameters
  9. Cosine learning rate schedulers and how to optimize it
  10. Using GradScalar for mixed precision training
  11. Using early stopping when model reaches plateau in training
  12. Validation using model.eval() every few epochs
  13. Saving my model and making sure state dictionaries don't have missing keys
  14. Fusing layers during evaluation
  15. Pruning models
  16. Optimizing CUDA
  17. How to serve a model and do inference in FastAPI.
  18. Using thread pool for backend serving
  19. Learned how to use psutil library
  20. Learned 5 new API security headers and why they are important.
  21. Using Kaiming init for initializing neural networks
  22. Test Time Augmentation for improving test time accuracy
  23. Trying to minimize the memory of a model by garbage collection and reduced precision
  24. Implementing OAuth 2.0 connection to GitHub, on frontend and backend
  25. Deploying a model on HuggingFace Spaces
  26. Learning how to log hyperparameters onto MLflow
  27. Use a HuggingFace pretrained model for image captioning
  28. Use WebSockets to stream tokens from backend to frontend for image captioning
  29. Use Redis to manage background jobs for image captioning
  30. Use Dataclasses in Python

About

A full stack web app to classify images based on my own custom trained CIFAR 100 ML model

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors