swint-trans-unet/trans-unet
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
- Install dependencies:
pip install -r requirements.txt- Run the application:
streamlit run src/streamlit_app.pyUsage
- Select the image size and batch size from the sidebar
- Choose the ISIC dataset version (2018/2019/2020)
- Click "Start Testing" to run the model on the test set
- View the results including:
- Dice Score
- Accuracy
- IoU
- 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
- Clone the repository:
git clone https://huggingface.co/spaces/your-username/trans-unet
cd trans-unet- Install the required dependencies:
pip install -r requirements.txtData Preparation
- Download the ISIC dataset and prepare it in the following format:
- Each image and its corresponding mask should be saved as a .npz file
- The .npz file should contain two arrays: 'image' and 'label'
- Create train.txt, val.txt, and test.txt files listing the filenames (without .npz extension)
- Place the data in the following structure:
data/
ISIC/
train_npz/
image1.npz
image2.npz
...
lists/
lists_ISIC/
train.txt
val.txt
test.txtUsage
- Start the Streamlit app:
streamlit run src/streamlit_app.py- Configure the training parameters in the sidebar:
- Image Size: Size of input images (default: 224)
- Batch Size: Number of images per batch (default: 24)
- Max Epochs: Maximum number of training epochs (default: 150)
- Learning Rate: Initial learning rate (default: 0.01)
- Data Root Path: Path to the ISIC dataset
- List Directory: Path to the directory containing train.txt, val.txt, and test.txt
- Output Directory: Directory to save model checkpoints and logs
- Config Path: Path to the model configuration file
- Click "Start Training" to begin the training process
- Monitor the training progress:
- Progress bar shows overall training progress
- Training and validation losses are displayed in real-time
- 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
