Welcome to my image classification project to learn ML better Deep learning can be very CPU intensive and memory intensive so a PC with a GPU and/or with a good amount of memory is strongly recommended for the running of this projects main code It also has a version that uses the CUDA Deep Learning Network libraries which will need to be installed for optimal training speed of the model. Another option in situations where a good PC may not be available is the use of cloud computing
Session Log:
-
20/12/2024: -Research on convolutional neural networks: Layed out design of CNN and how it can be used to create an image classifyer -Installed libraries and selected a big cat database from Kaggle
Worked Part-Time job between these dates
-
23/12/2024: -Ran into library issues and corruption with pytorch (Corrupted version and file path too long to be recognisable by terminal). Debugged the problem by doing as such: -Attempted to create a virtual environment (VE) from windows capabilities. VSCode failed to locate interpreter in virtual environment. -Installed Anaconda and used a conda VE. Installed python and pytorch onto the VE -Committed code to convert image to tensor -Created this file
-
24/12/2024 (Christmas Eve):
- Huge progress: Custom Dataset and CNN Model creation. Learned a lot today
- Added example code using simple greyscale matrix for convolution and pooling
- CNN model class:
- Formed the structure of the CNN in the init function with 3 rounds of convolution, activation functions, and max pooling (along with additional functions that I am still learning the functions of but know they are necessary)
- Created the forward passing function in action to use that structure
- Custom Dataset:
- Used pandas library for CSV parsing. Initially formatted the images and opened/converted them into RGB values using PIL library.
- Used os library for joining of file paths to access images and establish a root directory.
- Filtered access of the data in the csv dependant on their purpose (train/test/validate)
- Instantiates column values in the CSV as variables to access
- Combined the model and the dataset together to iterate through epochs of training data through the model to train it including backpropogation techniques (with cross entropy loss)
-
28/12/2024:
- Debugging code, replaced the labels with unique numeric labelling as is compatible with pytorch
- Finding solutions for quicker training methods such as GPU use using NVIDIA CUDA and cuDLNN. Both were unsuccessful. Searching for better option however in the meantime just using the CPU on my higher performance PC instead of my work laptop
- Script officially runnable but havent saved the created model
-
30/12/2024:
- Researched cloud computing solutions for training DL models quicker. Found google colab but was unsuccessful in integrating it due to compatability issues. If I wanted to use this as a solution, I should have started with google colab. Continued with slower unparalleled CPU training
- Saved state dictionary of the model (saved the model) as a .pth file and uploaded it to github using Git LFS
- Created testing script using the created model
- Testing script integration (with tweaking so that the model can process a single image instead of a batch of images) is without errors. Reverted the numeric label to the actual big cat representation and added matplotlib to display the current image being processed.
CURRENT ISSUE --> Overfitting: Model predicts every big cat to be a snow leopard. Find a way to stop this overfitting and make the model accurate.
References used: - https://machinelearningmastery.com/building-a-convolutional-neural-network-in-pytorch/ - https://www.geeksforgeeks.org/cnn-introduction-to-pooling-layer/ - https://www.kaggle.com/datasets/gpiosenka/cats-in-the-wild-image-classification/code - https://pytorch.org/tutorials/beginner/data_loading_tutorial.html - https://deeplizard.com/learn/video/Zi-0rlM4RDs#:~:text=The%20training%20set%20is%20what%20it%20sounds%20like. - https://docs.github.com/en/repositories/working-with-files/managing-large-files - https://stackoverflow.com/questions/59097657/in-pytorch-how-to-test-simple-image-with-my-loaded-model - https://stackoverflow.com/questions/58779759/how-can-i-display-an-image-on-vs-code-and-pycharm
NOTE: ChatGPT was used in aiding in the understanding of concepts for CNNs and understanding the function of sections of code used in referenced resources
Libraries required for running (copy and paste into terminal):
pip install torch pip install torchvision pip install pillow pip install pandas
(If you want to use cuda to speed up the training process, run this then install cuda and cnDLNN from the internet) pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 pip install torch pip install torchvision pip install pillow pip install pandas