This project demonstrates the use of a Convolutional Neural Network (CNN) to classify ultrasound images of breast tumors as benign or malignant. The project utilizes PyTorch for model training and Gradio for creating a user-friendly interface for predictions.
- Installation
- Dataset
- Model Architecture
- Data Preparation
- Training the Model
- Evaluation
- Creating a Gradio Interface
- Running the Application
- License
-
Clone the repository:
git clone https://github.com/your-username/Breast-Cancer-Detection-with-CNN-and-Gradio.git cd Breast-Cancer-Detection-with-CNN-and-Gradio -
Install the required dependencies:
pip install -r requirements.txt
The dataset used for this project is the Ultrasound Breast Images for Breast Cancer dataset from Kaggle.
-
Download the dataset from Kaggle and extract it into a directory named
data.kaggle datasets download -d vuppalaadithyasairam/ultrasound-breast-images-for-breast-cancer unzip ultrasound-breast-images-for-breast-cancer.zip -d data
The model used in this project is a Convolutional Neural Network (CNN) with the following architecture:
- 4 Convolutional layers with batch normalization and max pooling
- 2 Fully connected layers
- Dropout for regularization
Data preparation includes transforming the images and splitting the dataset into training, validation, and test sets.
Training the model involves several epochs of forward and backward propagation using a defined loss function and optimizer.
Evaluation includes checking the model's performance on the validation set and using metrics such as accuracy, confusion matrix, and classification report.
We use Gradio to create an interface for users to upload images and get predictions.
Run the following command to start the Gradio interface:
python main.py