CoolFace
Apppublic

swint-trans-unet/trans-unet

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

Welcome to Streamlit!

Edit /src/streamlit_app.py to customize this app to your heart's desire. :heart:

If you have any questions, checkout our documentation and community forums.

Swin-Unet ISIC Segmentation

This is a Streamlit application for testing the Swin-Unet model on ISIC dataset for skin lesion segmentation.

Setup

  1. 1.Install dependencies:
bash
pip install -r requirements.txt
  1. 1.Run the application:
bash
streamlit run src/streamlit_app.py

Usage

  1. 1.Select the image size and batch size from the sidebar
  2. 2.Choose the ISIC dataset version (2018/2019/2020)
  3. 3.Click "Start Testing" to run the model on the test set
  4. 4.View the results including:
  5. 5.Dice Score
  6. 6.Accuracy
  7. 7.IoU
  8. 8.Sample predictions with visualizations

Model

The application uses a pre-trained Swin-Unet model from Hugging Face (K0ZUME/best_model.pth).

Dataset

The application uses the ISIC dataset from Hugging Face, which can be selected from:

  • —ISIC 2018
  • —ISIC 2019
  • —ISIC 2020

TransUNet with ISIC Dataset Training

This repository contains a Streamlit-based implementation of TransUNet for training on the ISIC dataset. The implementation is based on the Swin-Unet architecture and includes a user-friendly interface for training and monitoring the model's progress.

Features

  • —Streamlit-based training interface
  • —Real-time training progress monitoring
  • —Support for ISIC dataset
  • —Configurable training parameters
  • —Model checkpointing
  • —TensorBoard integration for visualization

Installation

  1. 1.Clone the repository:
bash
git clone https://huggingface.co/spaces/your-username/trans-unet
cd trans-unet
  1. 1.Install the required dependencies:
bash
pip install -r requirements.txt

Data Preparation

  1. 1.Download the ISIC dataset and prepare it in the following format:
  2. 2.Each image and its corresponding mask should be saved as a .npz file
  3. 3.The .npz file should contain two arrays: 'image' and 'label'
  4. 4.Create train.txt, val.txt, and test.txt files listing the filenames (without .npz extension)
  1. 1.Place the data in the following structure:
data/
  ISIC/
    train_npz/
      image1.npz
      image2.npz
      ...
lists/
  lists_ISIC/
    train.txt
    val.txt
    test.txt

Usage

  1. 1.Start the Streamlit app:
bash
streamlit run src/streamlit_app.py
  1. 1.Configure the training parameters in the sidebar:
  2. 2.Image Size: Size of input images (default: 224)
  3. 3.Batch Size: Number of images per batch (default: 24)
  4. 4.Max Epochs: Maximum number of training epochs (default: 150)
  5. 5.Learning Rate: Initial learning rate (default: 0.01)
  6. 6.Data Root Path: Path to the ISIC dataset
  7. 7.List Directory: Path to the directory containing train.txt, val.txt, and test.txt
  8. 8.Output Directory: Directory to save model checkpoints and logs
  9. 9.Config Path: Path to the model configuration file
  1. 1.Click "Start Training" to begin the training process
  1. 1.Monitor the training progress:
  2. 2.Progress bar shows overall training progress
  3. 3.Training and validation losses are displayed in real-time
  4. 4.Best model checkpoints are saved automatically

Model Architecture

The model is based on the Swin Transformer architecture with the following key components:

  • —Patch Embedding Layer
  • —Swin Transformer Blocks
  • —Skip Connections
  • —Final Classification Head

Configuration

The model configuration can be modified in configs/swin_tiny_patch4_window7_224_lite.yaml. Key parameters include:

  • —Model architecture (embedding dimension, number of layers, etc.)
  • —Training parameters (batch size, learning rate, etc.)
  • —Data augmentation settings
  • —Loss function configuration

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • —The implementation is based on the Swin-Unet architecture
  • —ISIC dataset for providing the medical image segmentation data