-
-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #690 from tanuj437/codespace-redesigned-adventure-…
…4xjqgjx64wwfj954 AirBus Ship Detection
- Loading branch information
Showing
24 changed files
with
232,027 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
**Dataset Description** | ||
|
||
In this dataset, we are required to locate ships in images and place an aligned bounding box segment around the ships we locate. Many images do not contain ships, and those that do may contain multiple ships. Ships within and across images may differ in size (sometimes significantly) and be located in open sea, at docks, marinas, etc. | ||
|
||
**Key Features:** | ||
|
||
Non-overlapping Segments: For this metric, object segments cannot overlap. There were a small percentage of images in both the Train and Test sets that had slight overlap of object segments when ships were directly next to each other. Any segment overlaps were removed by setting them to background (i.e., non-ship) encoding. Therefore, some images have ground truth that may be an aligned bounding box with some pixels removed from an edge of the segment. These small adjustments will have a minimal impact on scoring, as the scoring evaluates over increasing overlap thresholds. | ||
|
||
**About This File** | ||
|
||
train_ship_segmentations.csv: This file provides the ground truth (in run-length encoding format) for the training images. | ||
sample_submission.csv: This file contains the images in the test set. | ||
|
||
**Sample Images:** | ||
![00113a75c](https://github.com/tanuj437/ML-Crate/assets/128210429/b41182e5-7d70-4ee3-ad8a-23b22754f87d) | ||
![00021ddc3](https://github.com/tanuj437/ML-Crate/assets/128210429/72a4683b-f8e3-44ea-adff-79b1c35c840e) | ||
![008f038d3](https://github.com/tanuj437/ML-Crate/assets/128210429/a2f39df5-55a2-42da-8632-2ed0f32d8848) | ||
![00aa79c47](https://github.com/tanuj437/ML-Crate/assets/128210429/5bf13a59-06e8-4b9e-a52e-9443d2814b41) | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
For more details and to access the dataset, visit the [Kaggle page](https://www.kaggle.com/competitions/airbus-ship-detection/data). |
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.
231,724 changes: 231,724 additions & 0 deletions
231,724
AirBus Ship Detection/Dataset/train_ship_segmentations_v2.csv
Large diffs are not rendered by default.
Oops, something went wrong.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# AirBus Ship Detection - Model | ||
|
||
## 📝 Description | ||
This folder contains the pre-trained machine learning models and scripts used for detecting ships in satellite images. The aim is to accurately identify and segment ships in images, enhancing maritime monitoring and analysis. | ||
|
||
## 📂 Contents | ||
**AirBus.ipynb:** Jupyter Notebook containing the complete process of data preprocessing, model training, evaluation, and visualization. | ||
|
||
**README.md:** This document. | ||
|
||
**RSN.pkl:** Pre-trained model used for ship detection. | ||
|
||
## 🎯 Goal | ||
The goal of this AirBus Ship detection project is to accurately identify and segment ships from satellite images using various machine learning models. By automatically detecting these ships, the project aims to aid maritime monitoring and analysis, providing valuable insights for various applications. | ||
|
||
## 🧮 What I Did | ||
In this AirBus Ship detection project, various models were evaluated to find the most effective one for segmenting and detecting ships in satellite images. The models evaluated include: | ||
|
||
## Models Used | ||
**UNet** | ||
A deep learning model designed for biomedical image segmentation, here adapted for ship segmentation tasks. | ||
|
||
**Basic CNN** | ||
A simple convolutional neural network for detecting ships in satellite images. | ||
|
||
**ResNet Segmentation** | ||
A powerful deep learning model that combines residual networks with segmentation capabilities, providing accurate ship detection. | ||
|
||
## Data Preprocessing and Augmentation | ||
|
||
**Image Resizing and Normalization:** Images were resized to 256x256 pixels and normalized to ensure consistency. | ||
|
||
**Feature Engineering:** Applied transformations to the images and masks to prepare them for model training. | ||
|
||
**Data Splitting:** Divided data into training, validation, and test sets for robust model evaluation. | ||
|
||
## 🚀 Models Implemented | ||
**UNet** | ||
Performance: Achieved high accuracy in ship segmentation due to its architecture designed for precise localization. | ||
|
||
**Basic CNN** | ||
Performance: Successfully detected ships with reasonable accuracy, serving as a baseline model. | ||
|
||
**ResNet Segmentation** | ||
Performance: Achieved high accuracy in ship detection and segmentation, benefiting from its deep architecture. | ||
|
||
## 📈 Performance of the Models | ||
The models achieved high accuracy in detecting and segmenting ships, demonstrating the effectiveness of deep learning approaches in this task. | ||
|
||
**UNET accuracy**:98.5% | ||
|
||
**ResNet Segmentation**:98.3% | ||
|
||
## 📢 Conclusion | ||
The AirBus Ship detection project demonstrates that various machine learning models can accurately detect and segment ships in satellite images. These models help automate maritime monitoring, providing valuable assistance to researchers and maritime authorities. | ||
|
||
## ✒️ Connect with Me | ||
Tanuj Saxena [LinkedIn](https://www.linkedin.com/in/tanuj-saxena-970271252/) |
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# AirBus Ship Detection | ||
|
||
Explore the detection and segmentation of ships in satellite images using advanced machine learning techniques. This project leverages models such as UNet, basic CNN, and ResNet for accurate ship detection and segmentation. | ||
![Screenshot (150)](https://github.com/tanuj437/ML-Crate/assets/128210429/404ca0e4-b087-480c-8b58-4d8983c100c8) | ||
|
||
## 📝 Description | ||
This repository contains the code, pre-trained models, and scripts for detecting and segmenting ships in satellite images using deep learning models. The project aims to improve maritime monitoring and analysis by providing accurate ship detection capabilities. | ||
|
||
## 📂 Contents | ||
### Main Directory | ||
- **app.py:** Streamlit application script for ship detection. | ||
- **requirements.txt:** List of required libraries and dependencies. | ||
- **README.md:** This document. | ||
|
||
### Notebooks | ||
- **AirBus.ipynb:** Jupyter Notebook containing the complete process of data preprocessing, model training, evaluation, and visualization. | ||
|
||
|
||
### Images | ||
- **CNN_model_output.png:** Training loss and validation accuracy plot for the CNN model. | ||
- **unet_model_output.png:** Training loss and validation accuracy plot for the UNet model. | ||
- **RNS_output.png:** Training loss and validation accuracy plot for the ResNet Segmentation model. | ||
|
||
## 🎯 Goal | ||
The goal of this AirBus Ship detection project is to accurately identify and segment ships from satellite images using various machine learning models. By automatically detecting these ships, the project aims to aid maritime monitoring and analysis, providing valuable insights for various applications. | ||
|
||
## 🧠 Methodology | ||
**1. Importing Libraries** | ||
- Libraries such as NumPy, Pandas, Sklearn, PyTorch, Torchvision, and others are imported for data manipulation, visualization, and model building. | ||
|
||
**2. Loading the Dataset** | ||
- The dataset consists of satellite images with annotations for ship locations, which are preprocessed for model training. | ||
|
||
**3. Data Preprocessing** | ||
- Data preprocessing involves tasks such as resizing images to 256x256 pixels, normalizing pixel values, and augmenting data to enhance model performance and robustness. | ||
|
||
**4. Training the Models** | ||
- Multiple models are trained, including UNet, basic CNN, and ResNet segmentation models, to detect and segment ships in satellite images. | ||
|
||
**5. Model Performance Analysis** | ||
- Performance metrics such as accuracy, precision, and recall are computed to evaluate and compare the effectiveness of each model. | ||
|
||
**6. Model Prediction** | ||
- The trained models are used to predict ship locations in unseen images, showcasing their segmentation capabilities. | ||
|
||
**7. Deployment** | ||
- Streamlit is utilized to deploy a web application for real-time ship detection, enabling users to upload images and receive instant segmentation results. | ||
|
||
## 🚀 How to Run the App | ||
1. **Install the required libraries:** | ||
```sh | ||
pip install -r requirement.txt | ||
``` | ||
|
||
2. **Run the Streamlit app:** | ||
```sh | ||
streamlit run app.py | ||
``` | ||
|
||
3. **Open the provided local URL in your web browser to access the app.** | ||
|
||
## 📈 Visualizations | ||
The `Images` folder contains visualizations showing the training loss and validation accuracy for the CNN and UNet models over multiple epochs. These visualizations help in understanding the model performance during the training process. | ||
|
||
### CNN Model Output | ||
<img width="588" alt="CNN_model_output" src="https://github.com/tanuj437/ML-Crate/assets/128210429/6d148519-a2f0-4833-8486-6214faf3b3c0"> | ||
|
||
- **Training Loss:** The left plot shows the training loss decreasing over epochs. | ||
- **Validation Accuracy:** The right plot shows the validation accuracy improving over epochs. | ||
|
||
### UNet Model Output | ||
<img width="598" alt="unet_model_output" src="https://github.com/tanuj437/ML-Crate/assets/128210429/414aad57-71b9-49fc-96ac-76cf41de7a7f"> | ||
|
||
- **Training Loss:** The left plot shows the training loss decreasing over epochs. | ||
- **Validation Accuracy:** The right plot shows the validation accuracy improving over epochs. | ||
|
||
### ResNet Segmentation Model Output | ||
<img width="584" alt="resnetsegmention_model_output" src="https://github.com/tanuj437/ML-Crate/assets/128210429/7ed26e3d-bc79-482f-8776-1acf06ae2e29"> | ||
|
||
- **Training Loss:** The left plot shows the training loss decreasing over epochs. | ||
- **Validation Accuracy:** The right plot shows the validation accuracy improving over epochs. | ||
|
||
## 📢 Conclusion | ||
The AirBus Ship detection project demonstrates that various machine learning models can accurately detect and segment ships in satellite images. These models help automate maritime monitoring, providing valuable assistance to researchers and maritime authorities. | ||
|
||
## ✒️ Connect with Me | ||
Tanuj Saxena [LinkedIn](https://www.linkedin.com/in/tanuj-saxena-970271252/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# AirBus Ship Detection Web App | ||
|
||
## 📝 Description | ||
This folder contains the Streamlit web application for detecting ships in satellite images using a pre-trained UNet segmentation model. The app allows users to upload an image, and it performs ship segmentation, displaying the results. | ||
|
||
|
||
https://github.com/tanuj437/ML-Crate/assets/128210429/3a1b2d6a-9bb6-40b9-a858-c089a1248b0f | ||
|
||
|
||
## 📂 Contents | ||
**app.py:** Streamlit application script for ship detection. | ||
**README.md:** This document. | ||
**RNS_model.pkl:** Pre-trained UNet segmentation model used in the application. | ||
|
||
## 🎯 Goal | ||
The goal of this AirBus Ship detection web app is to provide an interactive platform for users to upload satellite images and obtain ship segmentation results using a deep learning model. | ||
|
||
## 🚀 How to Run the App | ||
1. Install the required libraries: | ||
```sh | ||
pip install streamlit torch torchvision pillow numpy | ||
``` | ||
|
||
2. Run the Streamlit app: | ||
```sh | ||
streamlit run app.py | ||
``` | ||
|
||
3. Open the provided local URL in your web browser to access the app. | ||
|
||
## 🧠 How It Works | ||
The app performs the following steps: | ||
1. Loads the pre-trained UNet model using PyTorch. | ||
2. Accepts image uploads from the user through the web interface. | ||
3. Preprocesses the uploaded image (resizes and converts to tensor). | ||
4. Performs inference using the model to generate a segmentation mask. | ||
5. Displays the uploaded image and the corresponding segmentation mask. | ||
|
||
## ✒️ Connect with Me | ||
Tanuj Saxena [LinkedIn](https://www.linkedin.com/in/tanuj-saxena-970271252/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Save this script as 'app.py' | ||
|
||
import streamlit as st | ||
import torch | ||
import torchvision.transforms as transforms | ||
from PIL import Image | ||
import numpy as np | ||
|
||
# Function to load the pre-trained model | ||
@st.cache(allow_output_mutation=True) | ||
def load_model(): | ||
model = torch.load(r'Model\RNS_model.pkl', map_location=torch.device('cuda')) | ||
model.eval() | ||
return model | ||
|
||
# Streamlit app | ||
def main(): | ||
st.title("AirBus Ship detection with UNet Segmentation Model") | ||
st.text("Upload an image for segmentation") | ||
|
||
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "png", "jpeg"]) | ||
|
||
if uploaded_file is not None: | ||
image = Image.open(uploaded_file).convert("L") | ||
st.image(image, caption='Uploaded Image.', use_column_width=True) | ||
|
||
# Perform inference | ||
transform = transforms.Compose([ | ||
transforms.Resize((256, 256)), | ||
transforms.ToTensor(), | ||
]) | ||
image_tensor = transform(image).unsqueeze(0).to('cuda' if torch.cuda.is_available() else 'cpu') | ||
|
||
model = load_model() | ||
with torch.no_grad(): | ||
output = model(image_tensor) | ||
|
||
# Display segmentation result (assuming binary output) | ||
mask = output.squeeze().cpu().numpy() | ||
mask = (mask > 0.5).astype(np.uint8) # Threshold to create binary mask | ||
|
||
st.image(mask * 255, caption='Segmentation Mask', use_column_width=True) | ||
|
||
if __name__ == '__main__': | ||
main() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# AirBus Ship Detection - Model Outputs | ||
|
||
|
||
![Screenshot (150)](https://github.com/tanuj437/ML-Crate/assets/128210429/81e797a6-5180-406e-a21d-49693fc1426e) | ||
![Screenshot (151)](https://github.com/tanuj437/ML-Crate/assets/128210429/e4427c1a-fb26-4c08-82ca-9b4c4d483fc4) | ||
|
||
## 📂 Contents | ||
**CNN_model_output.png:** Training loss and validation accuracy plot for the CNN model. | ||
**unet_model_output.png:** Training loss and validation accuracy plot for the UNet model. | ||
**README.md:** This document. | ||
|
||
## 📈 Visualizations | ||
The images in this folder show the training loss and validation accuracy for the CNN and UNet models over multiple epochs. These visualizations help in understanding the model performance during the training process. | ||
|
||
### CNN Model Output | ||
<img width="588" alt="CNN_model_output" src="https://github.com/tanuj437/ML-Crate/assets/128210429/e2107c36-1475-49c3-9067-b517f788a177"> | ||
|
||
- **Training Loss:** The left plot shows the training loss decreasing over epochs. | ||
- **Validation Accuracy:** The right plot shows the validation accuracy improving over epochs. | ||
|
||
### UNet Model Output | ||
<img width="598" alt="unet_model_output" src="https://github.com/tanuj437/ML-Crate/assets/128210429/905fa084-0b50-48a6-bb59-a3e1b773e54d"> | ||
|
||
- **Training Loss:** The left plot shows the training loss decreasing over epochs. | ||
- **Validation Accuracy:** The right plot shows the validation accuracy improving over epochs. | ||
|
||
### ResNet Segmentation Model Output | ||
<img width="584" alt="resnetsegmention_model_output" src="https://github.com/tanuj437/ML-Crate/assets/128210429/b4139344-89a6-4ca7-aff6-1252b8acf9b9"> | ||
|
||
- **Training Loss:** The left plot shows the training loss decreasing over epochs. | ||
- **Validation Accuracy:** The right plot shows the validation accuracy improving over epochs. | ||
|
||
## 📢 Conclusion | ||
These visualizations indicate the performance of the CNN and UNet models in terms of training loss and validation accuracy. Monitoring these metrics helps in fine-tuning the models and understanding their learning patterns. | ||
|
||
## ✒️ Connect with Me | ||
Tanuj Saxena [LinkedIn](https://www.linkedin.com/in/tanuj-saxena-970271252/) |
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.
Binary file not shown.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
scikit-learn==0.24.2 | ||
opencv-python==4.5.3.56 | ||
matplotlib==3.4.3 | ||
pandas==1.3.3 | ||
streamlit==1.18.1 | ||
torch==2.0.1 | ||
torchvision==0.15.2 | ||
pillow==9.5.0 | ||
numpy==1.24.2 |