Dnq2025 commited on
Commit
9fc3bc2
·
verified ·
1 Parent(s): f29267a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +123 -8
README.md CHANGED
@@ -1,16 +1,131 @@
1
  ---
2
  license: cc-by-nc-sa-4.0
3
  datasets:
4
- - Dnq2025/Mask2former_Finetune
5
  base_model:
6
- - facebook/mask2former-swin-large-ade-semantic
7
- - Dnq2025/swin-large-mask2former-finetuned-ER-Mito-LD8
8
  language:
9
- - en
10
  pipeline_tag: image-segmentation
11
  library_name: transformers
12
  tags:
13
- - Electron-Microscopy
14
- - Ultrastructure-Segmentation
15
- - Semantic-Segmentation
16
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: cc-by-nc-sa-4.0
3
  datasets:
4
+ - Dnq2025/Mask2former_Finetune
5
  base_model:
6
+ - facebook/mask2former-swin-large-ade-semantic
7
+ - Dnq2025/swin-large-mask2former-finetuned-ER-Mito-LD8
8
  language:
9
+ - en
10
  pipeline_tag: image-segmentation
11
  library_name: transformers
12
  tags:
13
+ - Electron-Microscopy
14
+ - Ultrastructure-Segmentation
15
+ - Semantic-Segmentation
16
+ ---
17
+
18
+ # MicroStructFormer (Swin-Large)
19
+
20
+ MicroStructFormer is a high-capacity Mask2Former model built on a Swin-Large backbone, designed for the semantic segmentation of ultrastructures in Electron Microscopy (EM) images.
21
+
22
+ ## Model Description
23
+
24
+ This model has been trained to accurately segment the following critical ultrastructural elements:
25
+ - Abnormalities
26
+ - Mitochondria (and mitochondria-like organelles)
27
+ - Periaxonal Space
28
+
29
+ *Note: While the model architecture theoretically supports axon and myelin segmentation, this specific release is optimized and calibrated for the classes listed below due to dataset annotations.*
30
+
31
+ ## Usage
32
+
33
+ You can use this model easily via the `transformers` library.
34
+
35
+ ### 1. Using Pipeline (Recommended)
36
+
37
+ ```python
38
+ from transformers import pipeline
39
+ from PIL import Image
40
+
41
+ # Initialize the segmentation pipeline
42
+ pipe = pipeline("image-segmentation", model="Dnq2025/MicroStructFormer")
43
+
44
+ # Load your EM image
45
+ image = Image.open("examples/example_tem.png").convert("RGB")
46
+
47
+ # Run inference
48
+ results = pipe(image)
49
+ print(results)
50
+ ```
51
+
52
+ ### 2. Manual Inference with AutoImageProcessor
53
+
54
+ ```python
55
+ import torch
56
+ import numpy as np
57
+ from PIL import Image
58
+ from transformers import AutoImageProcessor, Mask2FormerForUniversalSegmentation
59
+
60
+ repo_id = "Dnq2025/MicroStructFormer"
61
+
62
+ # Load processor and model
63
+ processor = AutoImageProcessor.from_pretrained(repo_id)
64
+ model = Mask2FormerForUniversalSegmentation.from_pretrained(repo_id)
65
+ model.eval()
66
+
67
+ # Load image
68
+ image = Image.open("examples/example_tem.png").convert("RGB")
69
+ inputs = processor(images=image, return_tensors="pt")
70
+
71
+ with torch.no_grad():
72
+ outputs = model(**inputs)
73
+
74
+ # Post-process to get the semantic segmentation map
75
+ pred = processor.post_process_semantic_segmentation(
76
+ outputs,
77
+ target_sizes=[image.size[::-1]]
78
+ )[0].cpu().numpy().astype(np.uint8)
79
+
80
+ print(f"Prediction shape: {pred.shape}")
81
+ print(f"Unique classes found: {np.unique(pred)}")
82
+ ```
83
+
84
+ ## Label Map
85
+
86
+ | ID | Class |
87
+ |---:|---|
88
+ | 0 | background |
89
+ | 1 | abnormality |
90
+ | 2 | mitochondria-like organelles |
91
+ | 3 | mitochondria |
92
+ | 4 | mitochondria outside axon |
93
+ | 5 | periaxonal space |
94
+
95
+ ## Example
96
+
97
+ **Input EM image:**
98
+
99
+ ![Example input](examples/example_tem.png)
100
+
101
+ **Predicted segmentation overlay:**
102
+
103
+ ![Example prediction](examples/example_overlay.png)
104
+
105
+ ## Model Use, License, and Citation
106
+
107
+ This Hugging Face model repository is associated with the following bioRxiv preprint:
108
+
109
+ > Deng N, Miao G, Khadra A, Peterson AC, Bagheri H. Deep learning-based decoding of axonal ultrastructure in gene-edited mice using electron microscopy imaging. bioRxiv. 2026. DOI: 10.64898/2026.05.26.727755.
110
+
111
+ These model weights and associated architectures are provided for non-commercial academic and research use under the **CC-BY-NC-SA 4.0** license selected for this Hugging Face repository. Users must provide appropriate attribution to the original authors and cite the associated preprint when using these weights, architectures, derived representations, or any models fine-tuned from this project in publications, preprints, theses, presentations, software repositories, benchmarks, or derivative analyses.
112
+
113
+ Use of this model for commercial purposes is not permitted without prior written permission from the authors. Any redistributed or modified version of these weights or derived model variants must preserve attribution to the original authors and must be shared under the same or a compatible non-commercial share-alike license, unless separate written permission is obtained from the authors.
114
+
115
+ Users must not claim ownership of the original architectures, pretrained weights, Hugging Face model versions, or associated derived resources.
116
+
117
+ **Please cite:**
118
+
119
+ ```bibtex
120
+ @article {Deng2026.05.26.727755,
121
+ author = {Deng, Nianqi and Miao, Guillaume and Khadra, Anmar and Peterson, Alan C and Bagheri, Hooman},
122
+ title = {Deep learning-based decoding of axonal ultrastructure in gene-edited mice using electron microscopy imaging},
123
+ elocation-id = {2026.05.26.727755},
124
+ year = {2026},
125
+ doi = {10.64898/2026.05.26.727755},
126
+ publisher = {Cold Spring Harbor Laboratory},
127
+ URL = {https://www.biorxiv.org/content/early/2026/05/26/2026.05.26.727755},
128
+ eprint = {https://www.biorxiv.org/content/early/2026/05/26/2026.05.26.727755.full.pdf},
129
+ journal = {bioRxiv}
130
+ }
131
+ ```