--- license: mit tags: - image-segmentation - multilabel - unet - pytorch - medical-imaging library_name: transformers pipeline_tag: image-segmentation --- # LN_segmentation_sweep A unet model for multilabel image segmentation trained with sliding window approach. ## Model Description - **Architecture:** unet - **Input Channels:** 3 - **Output Classes:** 4 - **Base Filters:** 128 - **Window Size:** 128 - **Downsample Factor:** 1.0 ### Model-Specific Parameters ## Training Configuration | Parameter | Value | |-----------|-------| | Batch Size | 8 | | Learning Rate | 7.77451918775676e-06 | | Weight Decay | 0.00164040349077736 | | Epochs | 100 | | Patience | 10 | | Dataset | GleghornLab/Semi-Automated_LN_Segmentation_10_11_2025 | ## Validation Performance Metrics (Pooled Pixel-Level) | Metric | Mean | Class 0 | Class 1 | Class 2 | Class 3 | | ------------ | -----: | ------: | ------: | ------: | ------: | | Dice | 0.8697 | 0.7635 | 0.8607 | 0.9085 | 0.9461 | | IoU | 0.7757 | 0.6174 | 0.7554 | 0.8323 | 0.8977 | | F1 | 0.8697 | 0.7635 | 0.8607 | 0.9085 | 0.9461 | | MCC | 0.8649 | 0.7636 | 0.8588 | 0.9032 | 0.9340 | | ROC AUC | 0.9971 | 0.9946 | 0.9983 | 0.9978 | 0.9978 | | PR AUC | 0.9412 | 0.8527 | 0.9494 | 0.9720 | 0.9908 | ## Test Performance Metrics (Pooled Pixel-Level) | Metric | Mean | Class 0 | Class 1 | Class 2 | Class 3 | | ------------ | -----: | ------: | ------: | ------: | ------: | | Dice | 0.7960 | 0.7578 | 0.7830 | 0.7344 | 0.9087 | | IoU | 0.6666 | 0.6101 | 0.6433 | 0.5803 | 0.8328 | | F1 | 0.7960 | 0.7578 | 0.7830 | 0.7344 | 0.9087 | | MCC | 0.7959 | 0.7609 | 0.7891 | 0.7436 | 0.8900 | | ROC AUC | 0.9942 | 0.9949 | 0.9975 | 0.9903 | 0.9941 | | PR AUC | 0.9117 | 0.8628 | 0.9133 | 0.8985 | 0.9720 | ## Usage ```python import numpy as np from model import MODEL_REGISTRY, SegmentationConfig # Load model config = SegmentationConfig.from_pretrained("aholk/LN_segmentation_sweep") model = MODEL_REGISTRY["unet"].from_pretrained("aholk/LN_segmentation_sweep") model.eval() # Run inference on a full image with sliding window image = np.random.rand(2048, 2048, 3).astype(np.float32) # Your image here probs = model.predict_full_image( image, dim=128, batch_size=16, device="cuda" # or "cpu" ) # probs shape: (num_classes, H, W) with values in [0, 1] # Threshold to get binary masks masks = (probs > 0.5).astype(np.uint8) ``` ## Citation If you use this model, please cite: ```bibtex @software{windowz_segmentation, title={Multilabel Image Segmentation with Sliding Window U-Net}, author={Gleghorn Lab}, year={2025}, url={https://github.com/GleghornLab/ComputerVision2} } ```