# Project Title Optimizing architecture of convolutional neural networks utilizing a particle swarm optimization for Diabetic Retinopathy Classification ## Description This project demonstrates the use of Particle Swarm Optimization (PSO) to optimize hyperparameters for pretrained CNN models (VGG16, DenseNet121, and MobileNetV2) in diabetic retinopathy classification. The models were trained and evaluated on the APTOS 2019 dataset, leveraging critical parameters such as the number of filters, dropout rate, and learning rate to achieve optimal performance. ## Prerequisites - Python 3.8 or higher - TensorFlow (2.x) - Keras - NumPy - Pandas - Matplotlib - Scikit-learn - Imbalanced-learn ## How to Run 1. **Setup the Environment**: - Install the required libraries using the following command: ```bash pip install tensorflow keras pandas numpy matplotlib scikit-learn imbalanced-learn ``` 2. **Prepare the Data**: - Run the following preparation notebooks before training the models: - 'Dataset_Preparing.ipynb': This notebook prepares the dataset for training by splitting it into training, validation, and testing sets and applying data augmentation. 3. **Download the Dataset**: - Download the APTOS 2019 dataset from Kaggle: [APTOS 2019 Dataset](https://www.kaggle.com/competitions/aptos2019-blindness-detection). 4. **Computing Infrastructure**: - Operating System: Windows 10 - Hardwar: Resources provided by Google Colab, including NVIDIA Tesla P100 GPU (when enabled), 16 GB VRAM, 64 GB RAM, and Intel Xeon CPU. - Development Environment: Google Colaboratory (Colab) and local development setup for computational efficiency and scalability. 5. **Run the Code**: - Open the relevant Jupyter Notebook file for model optimization: - 'PSO_VGG16.ipynb': Optimizes hyperparameters for the VGG16 model. - 'PSO_DenseNet121.ipynb': Optimizes hyperparameters for the DenseNet121 model. - 'PSO_MobileNetV2.ipynb': Optimizes hyperparameters for the MobileNetV2 model. - Execute the notebooks step-by-step to train the models and evaluate performance. 6. **Project Structure **: - **Preparation Notebooks (Pretrained models):** - 'Up_Per VGG16 Final Version.ipynb': Notebook for preparing and training the VGG16 model. - 'Up_Per Densenet121 Final Version.ipynb': Notebook for preparing and training the DenseNet121 model. - 'Up_Per Mobilenetv2 Final Version.ipynb': Notebook for preparing and training the MobileNetV2 model. 7. **PSO Optimization Notebooks**: - 'PSO_VGG16.ipynb': Notebook for optimizing VGG16 hyperparameters using PSO. - 'PSO_DenseNet121.ipynb': Notebook for optimizing DenseNet121 hyperparameters using PSO. - 'PSO_MobileNetV2.ipynb': Notebook for optimizing MobileNetV2 hyperparameters using PSO. 8. **Justification for Models**: - VGG16: Known for its simplicity and reliable performance, making it a solid baseline model for medical image classification. - DenseNet121: Features dense connections that promote efficient gradient flow and reuse of features, reducing overfitting and improving performance with fewer parameters. - MobileNetV2: Optimized for mobile and resource-constrained environments, utilizing depthwise separable convolutions to achieve high accuracy with minimal computational cost. 9. ** Limitations**: - **Data Imbalance**: The APTOS 2019 dataset has an imbalanced distribution of classes, which impacts model performance for minority classes. - **Computational Resources**: Training models with PSO is computationally intensive and requires substantial resources for convergence. 10. **Results Summary**: - The proposed PSO-based optimization significantly improved the classification accuracy of the pretrained CNN models: PSO-MobileNetV2 achieved the highest accuracy of 97.4%. PSO-DenseNet121 achieved an accuracy of 96.34%. PSO-VGG16 achieved an accuracy of 76.62%, showing improvements but lagging behind the other models. This project demonstrates the potential of PSO in optimizing CNN hyperparameters, improving the reliability of automated diabetic retinopathy detection systems.