This repository contains code and documentation for the Fish Classification project, focusing on fish classification using a deep learning approach. The project involves training models to classify fish images into 9 different classes and different experiments.
All files contain proper documantation, overview:
- CNN_Fish - model for fish classification
- FishDataset - dataset class to retrieve images
- train - train the model using K-Fold cross validation
- utils - functionf for reading and train/test splitting of data
- model_architectures_main - main for using pretrained models as classifiers of images
- model_architectures_train_test - train,test,validate pretrained models
- model_architectures_utils.py - getters for different models and classifiers
- feature_extractor_main - main for using pretrained models as feature extractor
The dataset comprises 9 labels of fish:
50 images for each fish (except one class with 30 images)
RGB images with varying sizes
We initially used original images with k-fold Cross Validation (k=5). For each fold: 80/20 train-validation/test split. The best-performing fold achieved the following results:
- Train Accuracy: 95.3%
- Validation Accuracy: 66.7%
- Test Accuracy: 54.7%
Examples of correctly/incorrectly/uncertain classified images:
To enhance model performance, we implemented the following changes:
- Used augmented images (7 new roated images for each image)
- Hyperparameter tuning (learning rate, batch size, epochs)
- Data preprocessing (image normalization) Results for the best fold after improvements:
- Train Accuracy: 97.9%
- Validation Accuracy: 83.8%
- Test Accuracy: 84.9%
Examples of correctly/incorrectly/uncertain classified images:
We experimented with ITA, achieving improved results but not surpassing the model without ITA:
- Train Accuracy: 99.9%
- Validation Accuracy: 81.2%
- Test Accuracy: 80.2%
Examples of correctly/incorrectly classified images:
A new class, "Janitor Fish," was added:
Results were slightly worse but still good performance:
- Train Accuracy: 93.5%
- Validation Accuracy: 80.5%
- Test Accuracy: 79.2%
We compared the performance of different deep learning models:
- Validation Accuracy: 26.09%
- Test Accuracy: 26.74%
- Validation Accuracy: 98.55%
- Test Accuracy: 100%
- Validation Accuracy: 98.55%
- Test Accuracy: 100%
- Validation Accuracy: 98.55%
- Test Accuracy: 100%
We used ResNet18 as a feature extractor model and applied Random Forest, SVM, and KNN classifiers:
- Validation Accuracy: 97.1%
- Test Accuracy: 100%
- Validation Accuracy: 98.55%
- Test Accuracy: 100%
- Validation Accuracy: 98.55%
- Test Accuracy: 100%
We conducted experiments to assess how quickly models learn the dataset. ResNet18 demonstrated the best performance in terms of fast learning.