CoolFace
Apppublic

Atayaz/bsds500_transfer_learning

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
App README

๐Ÿง  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):

  1. 1.`bsds500_segmentation_cnn.py` โ€“ A U-Net-based Convolutional Neural Network (CNN) built from scratch
  2. 2.`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 (.jpg or .png)
  • โ€”archive/ground_truth/train/ โ†’ corresponding ground truth masks (.mat files with groundTruth segmentation data)

Each .jpg or .png file must have a .mat file with the same base name.


โš™๏ธ How to Run

Install dependencies:

bash
pip install -r requirements.txt

Run CNN model:

bash
streamlit run bsds500_segmentation_cnn.py

Run Transfer Learning model:

bash
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 (imagenet weights)
  • โ€”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

๐Ÿ’พ Model Output Files

ModelFile NameDescription
CNNbsds500_cnn_model.h5Scratch-built U-Net segmentation
Transfer Learningbsds500_resnet50_transfer.h5ResNet50-based transfer segmentation