Skip to content

Commit

Permalink
Merge branch 'abhisheks008:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
aaradhyasinghgaur authored Jun 2, 2024
2 parents af4f5a6 + 0b534f9 commit cb355dd
Show file tree
Hide file tree
Showing 67 changed files with 6,809 additions and 0 deletions.
50 changes: 50 additions & 0 deletions Breast Cancer Detection using DL with WebApp/Dataset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Breast Cancer Ultrasound Images Dataset

Welcome to the Breast Cancer Ultrasound Images Dataset repository. This dataset contains a comprehensive collection of ultrasound images related to breast cancer. Due to the large size of the dataset, we are unable to upload it directly here. However, you can easily download the dataset from the following link:

[Download Breast Cancer Ultrasound Images Dataset](https://www.kaggle.com/datasets/aryashah2k/breast-ultrasound-images-dataset)

## Dataset Overview

- **Dataset Size**: Large
- **Format**: Images (Ultrasound)
- **Purpose**: Breast Cancer Detection using Deep Learning
- **Data Source**: Kaggle

## Instructions for Usage

1. **Download Dataset**: Click on the download link provided above to download the Breast Cancer Ultrasound Images Dataset from Kaggle.

2. **Dataset Structure**: Once downloaded, ensure the dataset is organized in the following structure within this directory:

```
Breast Cancer Detection App/
|- dataset/
|- benign
|- normal
|- malignant
|- Model/
|- best_breast_cancer_detection_model.h5
|- Breast_Cancer_Detection_Notebook.ipynb
|- webapp/
|- templates/
|- static/
|- webapp.py
|- Images/
|- [Image files]
|- requirements.txt
|- README.md
```

3. **Data Usage**: The dataset is ready for use in your Deep Learning projects for breast cancer detection using ultrasound images. You can use this dataset for model training, validation, and testing purposes.

4. **Note**: Please cite the dataset source (Kaggle) appropriately if you use this dataset in your research or projects.

## Contact Information

For any inquiries or issues related to the dataset, feel free to reach out to the dataset owner on Kaggle.

**Dataset Owner**: Arya Shah
**Kaggle Profile**: [Arya Shah](https://www.kaggle.com/aryashah2k)

Thank you for using the Breast Cancer Ultrasound Images Dataset. We hope it contributes significantly to your research and projects in the field of breast cancer detection using Deep Learning.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
858 changes: 858 additions & 0 deletions Breast Cancer Detection using DL with WebApp/Model/Model.ipynb

Large diffs are not rendered by default.

82 changes: 82 additions & 0 deletions Breast Cancer Detection using DL with WebApp/Model/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Breast Cancer Detection using Deep Learning

## Overview
This project aims to develop a Breast Cancer Detection system using deep learning models, specifically focusing on ultrasound images. We implemented and compared the performance of three models: Multi-Layer Perceptron (MLP), VGG16, and ResNet50.

## Dataset
The dataset used for this project is the Breast Ultrasound Images Dataset from Kaggle, which contains ultrasound images labeled as normal, benign, and malignant.

Link to the dataset: [Breast Ultrasound Images Dataset](https://www.kaggle.com/datasets/aryashah2k/breast-ultrasound-images-dataset)

## Models
We employed three different deep learning models to classify the ultrasound images:
1. **Multi-Layer Perceptron (MLP)**
2. **VGG16**
3. **ResNet50**

## Results
### Confusion Matrices
![Confusion Matrices](https://github.com/TheNaiveSamosa/DL-Simplified/blob/e80b165685e6968ff28b574720aafee891b33516/Breast%20Cancer%20Detection%20using%20DL%20with%20WebApp/Images/Confusion%20Matrices.png)

### Training and Validation Loss & Accuracy

#### MLP
![MLP Loss and Accuracy](https://github.com/TheNaiveSamosa/DL-Simplified/blob/e80b165685e6968ff28b574720aafee891b33516/Breast%20Cancer%20Detection%20using%20DL%20with%20WebApp/Images/MLP.png)

#### VGG16
![VGG16 Loss and Accuracy](https://github.com/TheNaiveSamosa/DL-Simplified/blob/e80b165685e6968ff28b574720aafee891b33516/Breast%20Cancer%20Detection%20using%20DL%20with%20WebApp/Images/VGG16.png)

#### ResNet50
![ResNet50 Loss and Accuracy](https://github.com/TheNaiveSamosa/DL-Simplified/blob/e80b165685e6968ff28b574720aafee891b33516/Breast%20Cancer%20Detection%20using%20DL%20with%20WebApp/Images/ResNet50.png)

### Classification Reports

#### MLP
```
precision recall f1-score support
0 0.60 1.00 0.75 175
1 0.00 0.00 0.00 82
2 1.00 0.42 0.60 59
accuracy 0.63 316
macro avg 0.53 0.47 0.45 316
weighted avg 0.52 0.63 0.53 316
```

#### VGG16
```
precision recall f1-score support
0 0.87 0.93 0.90 175
1 0.86 0.83 0.84 82
2 0.92 0.78 0.84 59
accuracy 0.88 316
macro avg 0.88 0.85 0.86 316
weighted avg 0.88 0.88 0.88 316
```

#### ResNet50
```
precision recall f1-score support
0 0.59 0.99 0.74 175
1 0.92 0.28 0.43 82
2 0.00 0.00 0.00 59
accuracy 0.62 316
macro avg 0.50 0.42 0.39 316
weighted avg 0.57 0.62 0.52 316
```

## Conclusion
Among the three models, VGG16 achieved the highest accuracy and performed the best in terms of precision, recall, and F1-score. Future work will involve further fine-tuning of the models and exploring additional data augmentation techniques to improve the classification performance.

## Author
TheNaiveSamosa

GitHub: [TheNaiveSamosa](https://github.com/TheNaiveSamosa)
Email: [[email protected]](mailto:[email protected])

---
95 changes: 95 additions & 0 deletions Breast Cancer Detection using DL with WebApp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Breast Cancer Detection using Deep Learning with Ultrasound Imaging

## 📝 Abstract

Breast cancer detection is critical for early diagnosis and effective treatment. This project employs Deep Learning techniques to automate breast cancer detection using ultrasound imaging, aiming to enhance accuracy and facilitate timely interventions.

## 🌐 Context

Ultrasound imaging offers a non-invasive and widely accessible method for breast cancer screening. Leveraging Deep Learning on ultrasound images can improve diagnostic accuracy and streamline healthcare workflows.

## 🔍 Methodology

1. **Importing Libraries:**
- Essential libraries for data handling, visualization, and deep learning model construction are imported.

2. **Loading and Visualizing Ultrasound Images:**
- Ultrasound images from the dataset are loaded and visualized to gain insights into the data distribution.

3. **Data Preprocessing:**
- Images are resized and prepared for model training, ensuring consistency and optimal input format.
- Data is split into training and testing sets for model evaluation.

4. **Model Creation:**
- Three Deep Learning models are designed using TensorFlow and Keras:
- Multilayer Perceptron (MLP)
- VGG16 (Transfer Learning)
- ResNet50 (Transfer Learning)

5. **Model Training:**
- Each model undergoes training on the training dataset with validation for performance assessment.

6. **Model Evaluation:**
- Performance metrics including accuracy, loss, confusion matrix, and classification report are computed for each model.

7. **Selecting the Best Model:**
- The model demonstrating the highest validation accuracy is identified as the best-performing model.
- The best model is saved for future use and deployment.

8. **README.md Creation:**
- A README.md file is generated to provide project details, methodology, and directory structure information.

**Note:** Adjust file paths and names as per your local directory setup.

## 📁 Project Directory Structure

```
Breast Cancer Detection App/
|- Model/
|- best_breast_cancer_detection_model.h5
|- Breast_Cancer_Detection_Notebook.ipynb
|- webapp/
|- templates/
|- static/
|- webapp.py
|- dataset/
|- README.md
|- pictures/
|- [Image files]
|- requirements.txt
|- README.md
```
## Demo Image
![Demo](https://github.com/TheNaiveSamosa/DL-Simplified/blob/cff14deb16166e5140d8b86435530f6b711cf60c/Breast%20Cancer%20Detection%20using%20DL%20with%20WebApp/Images/Demo%20webpage.png)

## 🙌 Acknowledgments

Gratitude to the open-source community and datasets contributing to the advancement of breast cancer detection using ultrasound imaging.

## How to Use

1. **Clone the Repository:**
- Clone this GitHub repository to your local machine.

2. **Install Dependencies:**
- Install required Python packages listed in `requirements.txt` via `pip install -r requirements.txt`.

3. **Dataset and Model:**
- Ensure the ultrasound image dataset is in the specified directory (`dataset/`) and the trained model (`best_breast_cancer_detection_model.h5`) is in the `Model/` folder.

4. **Run the Jupyter Notebook:**
- Open and execute the provided Jupyter Notebook (`Breast_Cancer_Detection_Notebook.ipynb`) for model training and evaluation.

5. **Web Application Deployment:**
- Navigate to the `webapp/` directory and run `webapp.py` to deploy the web application for breast cancer detection using ultrasound imaging.

6. **Analyze Results:**
- Analyze model performance metrics, classification reports, confusion matrices, and accuracy/loss curves to interpret and validate results.

For inquiries or assistance, reach out to the project contributors:
- GitHub: [github.com/TheNaiveSamosa](github.com/TheNaiveSamosa)
- Email: [email protected]

**Dataset Link:** [Breast Ultrasound Images Dataset](https://www.kaggle.com/datasets/aryashah2k/breast-ultrasound-images-dataset)

---
38 changes: 38 additions & 0 deletions Breast Cancer Detection using DL with WebApp/Webapp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
## Web Application for Breast Cancer Detection using Ultrasound Imaging

### Goal 🎯
The primary objective of this web application is to provide a user-friendly platform for detecting breast cancer using ultrasound imaging. The application aims to assist healthcare professionals in accurately diagnosing breast cancer cases based on ultrasound images.

### Models Employed in the Web App 🧮
The web application integrates the following models for breast cancer detection:

1. **VGG16 Transfer Learning Model**: Utilizes transfer learning from a pre-trained VGG16 model, leveraging its deep architecture to extract high-level features from ultrasound images. Transfer learning helps improve model accuracy and generalization by transferring knowledge from a model trained on a large dataset to a specific task.

2. **Custom Multilayer Perceptron (MLP)**: A custom-designed MLP architecture tailored for breast cancer detection using ultrasound images. MLPs are versatile and effective for image classification tasks, employing multiple layers of neurons for feature learning and classification. The custom design allows for fine-tuning model parameters to suit the specific characteristics of ultrasound images.

3. **ResNet50 Transfer Learning Model**: Incorporates transfer learning from a pre-trained ResNet50 model, renowned for its deep residual learning architecture. ResNet50 can effectively capture intricate features in ultrasound images, thanks to its skip connections and residual blocks, which enable the model to learn from both shallow and deep layers simultaneously.

### Web Application Code Features 🖥️
The provided code snippet showcases the key features of the web application for breast cancer detection using ultrasound images:

- **Flask Framework**: Utilizes Flask, a lightweight and versatile web framework, for building the web application.
- **Model Loading**: Loads the trained breast cancer detection model (`best_breast_cancer_detection_model.h5`) using TensorFlow/Keras for inference.
- **Image Preparation**: Implements a function (`prepare_image`) to preprocess input images, including converting to grayscale, resizing, and scaling to match the model input requirements.
- **Prediction Endpoint**: Defines endpoints (`/predict`) for receiving POST requests with images, processing them through the model, and returning the predicted class (Benign, Malignant, or Normal) to the user interface.
- **User Interface**: Renders an HTML template (`index.html`) for user interaction, allowing users to upload an ultrasound image for prediction and displaying the predicted class.

This code structure enables seamless integration of deep learning models into a user-friendly web interface for breast cancer detection using ultrasound imaging.

### Video Demonstration 🎥


https://github.com/TheNaiveSamosa/DL-Simplified/assets/112872086/8405b383-6a54-416f-a594-e29339151cbf



### Signature ✒️
Aditya Khamitkar (TheNaiveSamosa)
[![Twitter](https://img.shields.io/badge/Twitter-%40Couch_Potatoh_-blue?style=flat&logo=twitter)](https://twitter.com/Couch_Potatoh_)
[![LinkedIn](https://img.shields.io/badge/LinkedIn-Aditya_Khamitkar-blue?style=flat&logo=linkedin)](https://www.linkedin.com/in/adityakhamitkar/)
[![Instagram](https://img.shields.io/badge/Instagram-couch_potatoh_-blue?style=flat&logo=instagram)](https://www.instagram.com/couch_potatoh_/)
[![Reddit](https://img.shields.io/badge/Reddit-The_Cactus_Flower-blue?style=flat&logo=reddit)](https://www.reddit.com/user/The-Cactus-Flower/)
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
body {
font-family: Arial, sans-serif;
background-color: #f8f9fa;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}

.container {
text-align: center;
background-color: #ffffff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

h1 {
margin-bottom: 20px;
}

form {
margin-bottom: 20px;
}

input[type="file"] {
margin-bottom: 10px;
}

button {
background-color: #007bff;
color: #ffffff;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
}

button:hover {
background-color: #0056b3;
}

.result {
margin-top: 20px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Breast Cancer Detection</title>
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
</head>
<body>
<div class="container">
<h1>Breast Cancer Detection</h1>
<form method="post" action="/predict" enctype="multipart/form-data">
<input type="file" name="image" accept="image/*" required>
<button type="submit">Predict</button>
</form>
{% if prediction %}
<div class="result">
<h2>Prediction: {{ prediction }}</h2>
</div>
{% endif %}
</div>
</body>
</html>
Loading

0 comments on commit cb355dd

Please sign in to comment.