This repository contains the implementation of an early breast cancer detection model using Liquid Neural Networks (LNNs) with Neural Circuit Policies (NCPs). The model processes ultrasound breast images from the BreastMNIST dataset to classify them as benign or malignant. The objective of this model is not just to detect cancer but also to achieve this with great computational efficiency, reducing parameter count by leveraging the concept of LNNs.
- A_LNN_BreastMNIST.ipynb: Jupyter Notebook for training the LNN model on the BreastMNIST dataset.
- B_DNN_BreastMNIST.ipynb: Jupyter Notebook for training the DNN model on the BreastMNIST dataset.
- C_CNN_BreastMNIST.ipynb: Jupyter Notebook for training the CNN model on the BreastMNIST dataset.
- D_Experimentation_pneumonia.ipynb: Jupyter Notebook for experimenting with the LNN model on the PneumoniaMNIST dataset.
- LNN_model.py: Python module containing the implementation of the LNN model.
- CNN_model.py: Python module containing the implementation of the CNN model.
- DNN_model.py: Python module containing the implementation of the DNN model.
-
BreastMNIST: Based on a dataset of 780 breast ultrasound images, categorized into 3 classes: normal, benign, and malignant. We simplify the task into binary classification by combining normal and benign as positive and classifying them against malignant as negative. The source images of 1 × 500 × 500 are resized into 1 × 28 × 28. BreastMNIST Dataset
-
PneumoniaMNIST: A subset of the MedMNIST dataset used for pneumonia detection, consisting of chest X-ray images labeled as normal or pneumonia. The dataset is formatted for binary classification. PneumoniaMNIST Dataset 'This is for just experimentation purpose only'
Here is the list of all the packages you need to install to run the program:
torch: PyTorch is used for building and training the neural network models.torchvision: This package provides datasets, model architectures, and image transformations for computer vision tasks.tqdm: Used for displaying progress bars during training and data loading, helping to monitor the progress of the model training process.medmnist: Provides easy access to the MedMNIST datasets, including BreastMNIST and PneumoniaMNIST.matplotlib: Essential for plotting graphs and visualizing the training and validation results.seaborn: Enhances data visualization and aesthetics in plots, making them easier to interpret.scikit-learn: Provides additional machine learning utilities and metrics, such as evaluation metrics and data preprocessing tools.opencv-python: Used for image processing tasks, such as reading and transforming images.ncps: Implements Neural Circuit Policies (NCPs) used in the Liquid Neural Networks, which are crucial for the dynamic synaptic behavior in the model.
You can install these libraries using pip:
pip install torch torchvision tqdm medmnist matplotlib seaborn scikit-learn opencv-python ncps- Activate conda environment:
source <your-virtual-environment>/bin/activate
- Clone the repository:
git clone https://github.com/2ai-lab/LLNs-for-Early-Breast-Cancer-Detection
- Change directory to LLNs-for-Early-Breast-Cancer-Detection
cd LLNs-for-Early-Breast-Cancer-Detection- Install the required packages:
pip install torch torchvision tqdm medmnist matplotlib seaborn scikit-learn opencv-python ncps
- Install the jupyterlab:
pip install jupyterlab
- Create the folders to save traned models:
mkdir saved_models experimented_models
- Now start the Notebook :
jupyter lab
- Open the Jupyter Notebooks A_LNN_BreastMNIST.ipynb, B_DNN_BreastMNIST.ipynb, or C_CNN_BreastMNIST.ipynb to train the respective models on the BreastMNIST dataset.
- For experimenting with the PneumoniaMNIST dataset, open and run D_Experimentation_pneumonia.ipynb.
- Make sure that the corresponding model files (e.g., LNN_model.py, DNN_model.py, CNN_model.py) are in the same directory as the notebooks.