kiselyovd commited on
Commit
4cb1fba
·
verified ·
1 Parent(s): 9f7fb9f

Upload artifacts

Browse files
README.md CHANGED
@@ -1,56 +1,97 @@
1
  ---
2
  license: mit
 
 
 
 
 
3
  tags:
4
- - semantic-segmentation
5
- - medical-imaging
6
  - brain-mri
7
- - pytorch-lightning
 
 
8
  - segformer
9
- library_name: pytorch
 
10
  datasets:
11
  - mateuszbuda/lgg-mri-segmentation
12
- pipeline_tag: image-segmentation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  ---
14
 
15
  # brain-mri-segmentation
16
 
17
  Production-grade binary brain-tumor MRI segmentation (LGG / TCGA).
18
 
19
- Binary semantic segmentation of brain-tumor regions (low-grade glioma) from FLAIR MRI slices. Main model: SegFormer-B2 fine-tuned on the Mateusz Buda LGG MRI dataset (TCGA, 110 patients, 3 929 paired slices) with a patient-level 80/10/10 split. Baseline: hand-rolled U-Net (4 levels, 32→256 ch, ~1.9 M params).
20
-
21
- Output is a binary mask at 256 × 256 resolution (1 = tumor, 0 = background).
22
-
23
  ## Metrics
24
 
25
  | Metric | Value |
26
  |---|---|
27
- | Main model | SegFormer-B2 |
28
- | Main Dice | 65.5% |
29
- | Main IoU | 66.2% |
30
- | Main Pixel accuracy | 99.73% |
31
- | Baseline model | U-Net (small) |
32
- | Baseline Dice | 51.9% |
33
- | Baseline IoU | 57.7% |
34
- | Baseline Pixel accuracy | 99.66% |
35
- | Test size (slices) | 387 |
36
 
37
  ## Usage
38
 
 
39
  ```python
40
- from huggingface_hub import snapshot_download
 
 
41
 
42
- from brain_mri_segmentation.inference.predict import load_model, predict
 
43
 
44
- ckpt_dir = snapshot_download("kiselyovd/brain-mri-segmentation")
45
- model = load_model(f"{ckpt_dir}/best.ckpt")
46
- result = predict(model, "path/to/slice.png")
47
- # {"mask": [[0, 0, 1, ...], ...], "shape": [256, 256]}
 
48
  ```
49
 
50
- ## Intended use
51
 
52
- Research and educational purposes only. **This is not a medical device.** Do not use for clinical decision-making. The model was trained on a single publicly available dataset and has not been validated against clinical ground truth, population diversity, acquisition-device variation, or downstream clinical workflows.
 
 
 
 
 
 
 
 
 
53
 
54
- ## Source
55
 
56
- https://github.com/kiselyovd/brain-mri-segmentation
 
1
  ---
2
  license: mit
3
+ library_name: transformers
4
+
5
+ pipeline_tag: image-segmentation
6
+
7
+ base_model: nvidia/segformer-b2-finetuned-ade-512-512
8
  tags:
 
 
9
  - brain-mri
10
+ - medical
11
+ - medical-imaging
12
+ - pytorch
13
  - segformer
14
+ - semantic-segmentation
15
+ - transformers
16
  datasets:
17
  - mateuszbuda/lgg-mri-segmentation
18
+
19
+ metrics:
20
+ - dice
21
+ - iou
22
+
23
+ widget:
24
+ - src: https://huggingface.co/kiselyovd/brain-mri-segmentation/resolve/main/samples/TCGA_DU_6408_19860521_43.png
25
+ title: TCGA_DU_6408_19860521_43
26
+ - src: https://huggingface.co/kiselyovd/brain-mri-segmentation/resolve/main/samples/TCGA_HT_7616_19940813_24.png
27
+ title: TCGA_HT_7616_19940813_24
28
+ - src: https://huggingface.co/kiselyovd/brain-mri-segmentation/resolve/main/samples/TCGA_HT_A5RC_19990831_27.png
29
+ title: TCGA_HT_A5RC_19990831_27
30
+
31
+
32
+ model-index:
33
+ - name: kiselyovd/brain-mri-segmentation
34
+ results:
35
+ - task:
36
+ type: image-segmentation
37
+ dataset:
38
+ type: mateuszbuda/lgg-mri-segmentation
39
+ name: LGG MRI Segmentation (TCGA)
40
+ metrics:
41
+ - type: dice
42
+ value: 0.6549053192138672
43
+ - type: iou
44
+ value: 0.6620140075683594
45
+ - type: pixel_accuracy
46
+ value: 0.997348964214325
47
+ - type: test_size
48
+ value: 387
49
+
50
  ---
51
 
52
  # brain-mri-segmentation
53
 
54
  Production-grade binary brain-tumor MRI segmentation (LGG / TCGA).
55
 
 
 
 
 
56
  ## Metrics
57
 
58
  | Metric | Value |
59
  |---|---|
60
+ | dice | 0.6549053192138672 |
61
+ | iou | 0.6620140075683594 |
62
+ | pixel_accuracy | 0.997348964214325 |
63
+ | test_size | 387 |
 
 
 
 
 
64
 
65
  ## Usage
66
 
67
+
68
  ```python
69
+ from transformers import AutoImageProcessor, AutoModelForSemanticSegmentation
70
+ import torch
71
+ from PIL import Image
72
 
73
+ processor = AutoImageProcessor.from_pretrained("kiselyovd/brain-mri-segmentation")
74
+ model = AutoModelForSemanticSegmentation.from_pretrained("kiselyovd/brain-mri-segmentation")
75
 
76
+ image = Image.open("your_image.png")
77
+ inputs = processor(images=image, return_tensors="pt")
78
+ with torch.no_grad():
79
+ outputs = model(**inputs)
80
+ logits = outputs.logits # shape (batch_size, num_labels, height, width)
81
  ```
82
 
 
83
 
84
+ ## Training Data
85
+
86
+ Trained on [LGG MRI Segmentation (TCGA)](https://huggingface.co/datasets/mateuszbuda/lgg-mri-segmentation).
87
+
88
+
89
+ ## Source Code
90
+
91
+ [GitHub Repository](https://github.com/kiselyovd/brain-mri-segmentation)
92
+
93
+ ## Intended Use
94
 
95
+ This model is provided for research and educational purposes. The authors make no warranties about its suitability for any particular application. Users are responsible for evaluating the model's fitness for their use case, including fairness, safety, and compliance with applicable regulations.
96
 
97
+ > **Note:** This model card was generated from the [ml-project-template](https://github.com/kiselyovd/ml-project-template) scaffold.
config.json ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "SegformerForSemanticSegmentation"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.0,
6
+ "classifier_dropout_prob": 0.1,
7
+ "decoder_hidden_size": 768,
8
+ "depths": [
9
+ 3,
10
+ 4,
11
+ 6,
12
+ 3
13
+ ],
14
+ "downsampling_rates": [
15
+ 1,
16
+ 4,
17
+ 8,
18
+ 16
19
+ ],
20
+ "drop_path_rate": 0.1,
21
+ "dtype": "float32",
22
+ "hidden_act": "gelu",
23
+ "hidden_dropout_prob": 0.0,
24
+ "hidden_sizes": [
25
+ 64,
26
+ 128,
27
+ 320,
28
+ 512
29
+ ],
30
+ "image_size": 224,
31
+ "initializer_range": 0.02,
32
+ "layer_norm_eps": 1e-06,
33
+ "mlp_ratios": [
34
+ 4,
35
+ 4,
36
+ 4,
37
+ 4
38
+ ],
39
+ "model_type": "segformer",
40
+ "num_attention_heads": [
41
+ 1,
42
+ 2,
43
+ 5,
44
+ 8
45
+ ],
46
+ "num_channels": 3,
47
+ "num_encoder_blocks": 4,
48
+ "patch_sizes": [
49
+ 7,
50
+ 3,
51
+ 3,
52
+ 3
53
+ ],
54
+ "reshape_last_stage": true,
55
+ "semantic_loss_ignore_index": 255,
56
+ "sr_ratios": [
57
+ 8,
58
+ 4,
59
+ 2,
60
+ 1
61
+ ],
62
+ "strides": [
63
+ 4,
64
+ 2,
65
+ 2,
66
+ 2
67
+ ],
68
+ "transformers_version": "5.5.4"
69
+ }
hf_export/config.json ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "SegformerForSemanticSegmentation"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.0,
6
+ "classifier_dropout_prob": 0.1,
7
+ "decoder_hidden_size": 768,
8
+ "depths": [
9
+ 3,
10
+ 4,
11
+ 6,
12
+ 3
13
+ ],
14
+ "downsampling_rates": [
15
+ 1,
16
+ 4,
17
+ 8,
18
+ 16
19
+ ],
20
+ "drop_path_rate": 0.1,
21
+ "dtype": "float32",
22
+ "hidden_act": "gelu",
23
+ "hidden_dropout_prob": 0.0,
24
+ "hidden_sizes": [
25
+ 64,
26
+ 128,
27
+ 320,
28
+ 512
29
+ ],
30
+ "image_size": 224,
31
+ "initializer_range": 0.02,
32
+ "layer_norm_eps": 1e-06,
33
+ "mlp_ratios": [
34
+ 4,
35
+ 4,
36
+ 4,
37
+ 4
38
+ ],
39
+ "model_type": "segformer",
40
+ "num_attention_heads": [
41
+ 1,
42
+ 2,
43
+ 5,
44
+ 8
45
+ ],
46
+ "num_channels": 3,
47
+ "num_encoder_blocks": 4,
48
+ "patch_sizes": [
49
+ 7,
50
+ 3,
51
+ 3,
52
+ 3
53
+ ],
54
+ "reshape_last_stage": true,
55
+ "semantic_loss_ignore_index": 255,
56
+ "sr_ratios": [
57
+ 8,
58
+ 4,
59
+ 2,
60
+ 1
61
+ ],
62
+ "strides": [
63
+ 4,
64
+ 2,
65
+ 2,
66
+ 2
67
+ ],
68
+ "transformers_version": "5.5.4"
69
+ }
hf_export/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b8e0816e76ee1f849ad37b119fc42647beba5072e842db958b848b0673dedfa4
3
+ size 109444016
hf_export/preprocessor_config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_normalize": true,
3
+ "do_reduce_labels": false,
4
+ "do_rescale": true,
5
+ "do_resize": true,
6
+ "image_mean": [
7
+ 0.485,
8
+ 0.456,
9
+ 0.406
10
+ ],
11
+ "image_processor_type": "SegformerImageProcessor",
12
+ "image_std": [
13
+ 0.229,
14
+ 0.224,
15
+ 0.225
16
+ ],
17
+ "reduce_labels": true,
18
+ "resample": 2,
19
+ "rescale_factor": 0.00392156862745098,
20
+ "size": {
21
+ "height": 512,
22
+ "width": 512
23
+ }
24
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b8e0816e76ee1f849ad37b119fc42647beba5072e842db958b848b0673dedfa4
3
+ size 109444016
preprocessor_config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_normalize": true,
3
+ "do_reduce_labels": false,
4
+ "do_rescale": true,
5
+ "do_resize": true,
6
+ "image_mean": [
7
+ 0.485,
8
+ 0.456,
9
+ 0.406
10
+ ],
11
+ "image_processor_type": "SegformerImageProcessor",
12
+ "image_std": [
13
+ 0.229,
14
+ 0.224,
15
+ 0.225
16
+ ],
17
+ "reduce_labels": true,
18
+ "resample": 2,
19
+ "rescale_factor": 0.00392156862745098,
20
+ "size": {
21
+ "height": 512,
22
+ "width": 512
23
+ }
24
+ }
samples/TCGA_DU_6408_19860521_43.png ADDED
samples/TCGA_HT_7616_19940813_24.png ADDED
samples/TCGA_HT_A5RC_19990831_27.png ADDED