Atayaz/bsds500_transfer_learning
0
๐ง BSDS500 Image Segmentation with CNN and Transfer Learning
This project implements two deep learning approaches to perform image segmentation on the Berkeley Segmentation Dataset (BSDS500):
- `bsds500_segmentation_cnn.py` โ A U-Net-based Convolutional Neural Network (CNN) built from scratch
- `bsds500_transfer_learning.py` โ A Transfer Learning model using ResNet50 as encoder with a custom decoder
Both models are deployed using Streamlit, enabling interactive training visualizations and real-time segmentation predictions.
๐ Dataset
Dataset Used: BSDS500 - Berkeley Segmentation Dataset
The dataset must be structured as follows:
archive/images/train/โ input images (.jpgor.png)archive/ground_truth/train/โ corresponding ground truth masks (.matfiles withgroundTruthsegmentation data)
Each .jpg or .png file must have a .mat file with the same base name.
โ๏ธ How to Run
Install dependencies:
pip install -r requirements.txtRun CNN model:
streamlit run bsds500_segmentation_cnn.pyRun Transfer Learning model:
streamlit run bsds500_transfer_learning.py๐ง Model 1: CNN (bsds500_segmentation_cnn.py)
Key Features:
- Custom U-Net with 5+ convolutional layers
- 3+ max pooling layers
- Dropout regularization
- Binary mask prediction via sigmoid output
- Training and validation accuracy/loss plots
- Real-time segmentation of uploaded images
- Model saved as
bsds500_cnn_model.h5
๐ง Model 2: Transfer Learning (bsds500_transfer_learning.py)
Key Features:
- Encoder: Pretrained ResNet50 (
imagenetweights) - Decoder: Custom CNN-based U-Net-like layers
- Skip connections for semantic segmentation
- Binary mask prediction via sigmoid output
- Training and validation metric visualization
- Real-time mask prediction for uploaded images
- Model saved as
bsds500_resnet50_transfer.h5
๐ผ๏ธ Streamlit Interface Includes:
- Training graphs (Accuracy & Loss)
- File uploader to select image
- Predicted segmentation mask display
