This repository contains multiple implementations of Convolutional Neural Networks (CNNs) for image classification tasks. The models range from custom-built CNN architectures to transfer learning using pre-trained networks like ResNet50. This repository is structured for flexibility, enabling experimentation with different architectures and datasets.
-
Custom CNN Models:
- Designed from scratch for specific datasets.
- Includes feature extraction using multiple convolutional and pooling layers.
- Augmentation and regularization to prevent overfitting.
-
Small CNN Model:
- A simplified CNN architecture suitable for small datasets or quick experiments.
- Focuses on achieving a balance between performance and computational efficiency.
-
Transfer Learning:
- Uses ResNet50 as the base model for robust feature extraction.
- Custom dense layers added for classification tasks.
- Includes fine-tuning for improved performance.
-
Data Augmentation:
- Rotation, zoom, and flip augmentations implemented to enhance dataset variability.
- Real-time augmentation during training using
ImageDataGenerator
.
-
Evaluation:
- Supports metrics like accuracy, confusion matrices, and loss/accuracy plots.
- Clear separation of train, validation, and test datasets to prevent data leakage.
-
Callbacks:
- Early stopping to prevent overfitting.
- Learning rate reduction on plateau.
- Python 3.8 or higher
- TensorFlow 2.x
- NumPy
- Matplotlib
- scikit-learn
Install the required dependencies with:
pip install -r requirements.txt
.
βββ data
β βββ train
β βββ validation
β βββ test
βββ models
β βββ custom_cnn.py
β βββ small_cnn.py
β βββ transfer_learning_resnet50.py
βββ notebooks
β βββ training_visualization.ipynb
βββ requirements.txt
βββ README.md
βββ utils
βββ data_preprocessing.py
βββ plot_metrics.py
Organize the dataset into the following structure:
.
βββ train
β βββ class_1
β βββ class_2
β βββ ...
βββ validation
β βββ class_1
β βββ class_2
β βββ ...
βββ test
βββ class_1
βββ class_2
βββ ...
Run any of the scripts in the models/
directory. For example, to train the custom CNN model:
python models/custom_cnn.py
Visualize metrics and evaluate model performance using the provided utilities. For example:
python utils/plot_metrics.py
A robust architecture with multiple convolutional layers, batch normalization, and dropout for regularization.
A lightweight architecture ideal for quick experimentation and smaller datasets.
A state-of-the-art approach leveraging pre-trained weights of ResNet50 for feature extraction and fine-tuning.
Include details about the performance of different models, such as:
- Accuracy
- Precision, Recall, F1-Score
- Confusion Matrices
Feel free to fork this repository and submit pull requests. Contributions in the form of bug fixes, feature additions, or performance enhancements are welcome.