Hi there, I am Thanh Minh Truong - A student studying Deep Learning/AI/Computer Vision.
This is my project about classify 10 types of animal ( introduced in Categories)
Here I used Pytorch framework for this project, this includes:
- Preprocessing and validating input images and labels
- Build CNN architecture
- Model training
- Model evaluation
- Testing
I will demo the results in two formats: a list of images and a video containing images of different types of pets
In this project, I have 10 classes and each class contains about 2000 images of animals ( cat, dog, elephant,...)
Directory structure of this folder, like this :
Dataset
|__ train
|_ butterfly
|__ pic1.jpg
|__ pic2.jpg
|__ ....
|__ cat
|__ pic1.jpg
|__ pic2.jpg
|__ ....
|__.....
|__test
|__ butterfly
|__ pic1.jpg
|__ pic2.jpg
|__ ....
|__ cat
|__ pic1.jpg
|__ pic2.jpg
|__ ....
|__ .....
The input (images) for training be changed to Tensor Pytorch [Batch, Channel, Height, Width] where Height = Width = 224 and Channel = 3. Values should be between 0 and 1
butterfly | cat |
chicken | cow |
dog | elephant |
horse | sheep |
spider | squirrel |
With this topic, I will build model based on VGG16 architecture, like this:
However, I have changed some parameters, especially the top layer ( Fully connected, Dropout, ....) to match my dataset.
We will see the model configuration in src/model.py
I will run this script on the terminal
:
python train.py -b 32 -e 50 -o Adam -l 0.001
I save the checkpoint to the checkpoint/best.pt folder folder after the training process
After training process, We were have a checkpoint save model parameters, I will test with some images I downloaded in Google and use matplotlib
to show results:
Besides testing with images, I also tried to test with animal videos I downloaded on YouTube
This is my results:
- python 3.10
- torch 2.1.1
- opencv-python 4.8.1
- matplotlib 3.8.2
- tqdm 4.66.1
- numpy 1.26.2
- scikit-learn 1.3.2
- tensorboard 2.15.1
- torchvision 0.16.1
- Pillow 10.1.0