Upload folder using huggingface_hub
Browse files- .gitattributes +5 -0
- README.md +94 -0
- best_validation_reconstruction.png +3 -0
- config.json +16 -0
- dice_curves.png +3 -0
- iou_curves.png +3 -0
- mcc_curves.png +3 -0
- model.safetensors +3 -0
- training_loss.png +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,8 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
best_validation_reconstruction.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
dice_curves.png filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
iou_curves.png filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
mcc_curves.png filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
training_loss.png filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
tags:
|
| 4 |
+
- image-segmentation
|
| 5 |
+
- multilabel
|
| 6 |
+
- unet
|
| 7 |
+
- pytorch
|
| 8 |
+
- medical-imaging
|
| 9 |
+
library_name: transformers
|
| 10 |
+
pipeline_tag: image-segmentation
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# LN_segmentation
|
| 14 |
+
|
| 15 |
+
A unet model for multilabel image segmentation trained with sliding window approach.
|
| 16 |
+
|
| 17 |
+
## Model Description
|
| 18 |
+
|
| 19 |
+
- **Architecture:** unet
|
| 20 |
+
- **Input Channels:** 3
|
| 21 |
+
- **Output Classes:** 4
|
| 22 |
+
- **Base Filters:** 32
|
| 23 |
+
- **Window Size:** 256
|
| 24 |
+
|
| 25 |
+
### Model-Specific Parameters
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
## Training Configuration
|
| 29 |
+
|
| 30 |
+
| Parameter | Value |
|
| 31 |
+
|-----------|-------|
|
| 32 |
+
| Batch Size | 64 |
|
| 33 |
+
| Learning Rate | 0.0003 |
|
| 34 |
+
| Weight Decay | 0.01 |
|
| 35 |
+
| Epochs | 100 |
|
| 36 |
+
| Patience | 10 |
|
| 37 |
+
| Dataset | GleghornLab/Semi-Automated_LN_Segmentation_10_11_2025 |
|
| 38 |
+
|
| 39 |
+
## Performance Metrics
|
| 40 |
+
|
| 41 |
+
| Metric | Mean | Class 0 | Class 1 | Class 2 | Class 3 |
|
| 42 |
+
|--------|------|--------|--------|--------|--------|
|
| 43 |
+
| Dice | 0.5196 | 0.1800 | 0.2978 | 0.7189 | 0.8819 |
|
| 44 |
+
| IoU | 0.4059 | 0.0989 | 0.1749 | 0.5612 | 0.7887 |
|
| 45 |
+
| F1 | 0.5196 | 0.1800 | 0.2978 | 0.7189 | 0.8819 |
|
| 46 |
+
| MCC | 0.5044 | 0.1730 | 0.2861 | 0.7032 | 0.8554 |
|
| 47 |
+
| ROC AUC | 0.8338 | 0.6482 | 0.7772 | 0.9252 | 0.9847 |
|
| 48 |
+
| PR AUC | 0.4846 | 0.0767 | 0.1807 | 0.7583 | 0.9227 |
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
## Usage
|
| 52 |
+
|
| 53 |
+
```python
|
| 54 |
+
import numpy as np
|
| 55 |
+
from model import MODEL_REGISTRY, SegmentationConfig
|
| 56 |
+
|
| 57 |
+
# Load model
|
| 58 |
+
config = SegmentationConfig.from_pretrained("aholk/LN_segmentation")
|
| 59 |
+
model = MODEL_REGISTRY["unet"].from_pretrained("aholk/LN_segmentation")
|
| 60 |
+
model.eval()
|
| 61 |
+
|
| 62 |
+
# Run inference on a full image with sliding window
|
| 63 |
+
image = np.random.rand(2048, 2048, 3).astype(np.float32) # Your image here
|
| 64 |
+
probs = model.predict_full_image(
|
| 65 |
+
image,
|
| 66 |
+
dim=256,
|
| 67 |
+
batch_size=16,
|
| 68 |
+
device="cuda" # or "cpu"
|
| 69 |
+
)
|
| 70 |
+
# probs shape: (num_classes, H, W) with values in [0, 1]
|
| 71 |
+
|
| 72 |
+
# Threshold to get binary masks
|
| 73 |
+
masks = (probs > 0.5).astype(np.uint8)
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
## Training Plots
|
| 77 |
+
|
| 78 |
+

|
| 79 |
+

|
| 80 |
+

|
| 81 |
+

|
| 82 |
+
|
| 83 |
+
## Citation
|
| 84 |
+
|
| 85 |
+
If you use this model, please cite:
|
| 86 |
+
|
| 87 |
+
```bibtex
|
| 88 |
+
@software{windowz_segmentation,
|
| 89 |
+
title={Multilabel Image Segmentation with Sliding Window U-Net},
|
| 90 |
+
author={Gleghorn Lab},
|
| 91 |
+
year={2025},
|
| 92 |
+
url={https://github.com/GleghornLab/ComputerVision2}
|
| 93 |
+
}
|
| 94 |
+
```
|
best_validation_reconstruction.png
ADDED
|
Git LFS Details
|
config.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"UNetForSegmentation"
|
| 4 |
+
],
|
| 5 |
+
"dtype": "float32",
|
| 6 |
+
"img_size": 256,
|
| 7 |
+
"k": 2,
|
| 8 |
+
"model_arch": "unet",
|
| 9 |
+
"model_type": "segmentation",
|
| 10 |
+
"n_filts": 32,
|
| 11 |
+
"norm": false,
|
| 12 |
+
"num_channels": 3,
|
| 13 |
+
"num_classes": 4,
|
| 14 |
+
"t": 2,
|
| 15 |
+
"transformers_version": "5.2.0"
|
| 16 |
+
}
|
dice_curves.png
ADDED
|
Git LFS Details
|
iou_curves.png
ADDED
|
Git LFS Details
|
mcc_curves.png
ADDED
|
Git LFS Details
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:64c71e8d3366598ff068086fbb8713da702767a21bfe424b94e2096ba7fd3432
|
| 3 |
+
size 138178416
|
training_loss.png
ADDED
|
Git LFS Details
|