Aakash-Tripathi commited on
Commit
36dc26d
·
verified ·
1 Parent(s): 4608ffb

Upload 6 files

Browse files
.gitattributes CHANGED
@@ -1,35 +1,10 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
 
3
  *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
  *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
  *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
  *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz 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
 
1
+ *.pt filter=lfs diff=lfs merge=lfs -text
2
+ *.pth filter=lfs diff=lfs merge=lfs -text
3
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
4
  *.bin filter=lfs diff=lfs merge=lfs -text
 
5
  *.ckpt filter=lfs diff=lfs merge=lfs -text
 
 
6
  *.h5 filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
7
  *.pkl filter=lfs diff=lfs merge=lfs -text
8
+ *.pb filter=lfs diff=lfs merge=lfs -text
9
+ *.onnx filter=lfs diff=lfs merge=lfs -text
10
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
README.md CHANGED
@@ -1,3 +1,191 @@
1
- ---
2
- license: gpl-3.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Deep Tissue Detector - DenseNet121
2
+
3
+ A deep learning model for detecting tissue regions in Whole Slide Images (WSI) of histopathology slides.
4
+
5
+ ## Model Description
6
+
7
+ This is a DenseNet121-based tissue detector trained to classify image patches into three categories for histopathology analysis. The model is specifically designed to identify tissue-containing regions in H&E (Hematoxylin and Eosin) stained whole slide images, enabling efficient processing of large pathology datasets.
8
+
9
+ ### Model Details
10
+
11
+ - **Architecture**: DenseNet121
12
+ - **Input Size**: 224x224 RGB images
13
+ - **Number of Classes**: 3
14
+ - Class 0: Background/Non-tissue
15
+ - Class 1: Artifact/Low-quality
16
+ - Class 2: Tissue (high quality)
17
+ - **Parameters**: ~7M
18
+ - **Model Size**: 28MB
19
+ - **Framework**: PyTorch
20
+ - **License**: GPL-3.0
21
+
22
+ ### Intended Use
23
+
24
+ This model is designed for:
25
+ - Filtering tissue-containing patches from whole slide images
26
+ - Quality control in computational pathology pipelines
27
+ - Preprocessing for downstream cancer analysis tasks
28
+ - Reducing computational burden by identifying regions of interest
29
+
30
+ **Recommended Usage**: Accept patches where class 2 (tissue) probability ≥ 0.8
31
+
32
+ ## Usage
33
+
34
+ ### Installation
35
+
36
+ ```bash
37
+ pip install torch torchvision huggingface_hub pillow
38
+ ```
39
+
40
+ ### Basic Usage
41
+
42
+ ```python
43
+ from tissue_detector import TissueDetector
44
+ from PIL import Image
45
+
46
+ # Initialize detector (automatically downloads weights from HuggingFace)
47
+ detector = TissueDetector(device='cuda')
48
+
49
+ # Load and process an image
50
+ image = Image.open('patch.png')
51
+ patch_transformed = detector.transforms(image)
52
+ patch_batch = patch_transformed.unsqueeze(0).to(detector.device)
53
+
54
+ # Get predictions
55
+ import torch
56
+ with torch.no_grad():
57
+ prediction = detector.model(patch_batch)
58
+ probabilities = torch.nn.functional.softmax(prediction, dim=1).cpu().numpy()[0]
59
+ tissue_class = probabilities.argmax()
60
+
61
+ # Check if patch contains tissue (class 2 with threshold 0.8)
62
+ is_tissue = tissue_class == 2 and probabilities[2] >= 0.8
63
+ print(f"Tissue detected: {is_tissue} (confidence: {probabilities[2]:.3f})")
64
+ ```
65
+
66
+ ### Integration with HoneyBee Framework
67
+
68
+ ```python
69
+ from honeybee.models import TissueDetector
70
+ from honeybee.processors.wsi import SimpleSlide
71
+
72
+ # Initialize tissue detector
73
+ detector = TissueDetector(device='cuda')
74
+
75
+ # Load whole slide image
76
+ slide = SimpleSlide(
77
+ slide_path='path/to/slide.svs',
78
+ tile_size=512,
79
+ max_patches=100,
80
+ tissue_detector=detector
81
+ )
82
+
83
+ # Extract tissue patches (automatically filtered)
84
+ patches = slide.load_patches_concurrently(target_patch_size=224)
85
+ ```
86
+
87
+ ### Manual Download
88
+
89
+ ```python
90
+ from huggingface_hub import hf_hub_download
91
+
92
+ # Download PyTorch weights
93
+ model_path = hf_hub_download(
94
+ repo_id="Lab-Rasool/tissue-detector",
95
+ filename="deep-tissue-detector_densenet_state-dict.pt"
96
+ )
97
+
98
+ # Or download SafeTensors format (recommended)
99
+ model_path = hf_hub_download(
100
+ repo_id="Lab-Rasool/tissue-detector",
101
+ filename="model.safetensors"
102
+ )
103
+ ```
104
+
105
+ ## Model Performance
106
+
107
+ The model has been extensively used in cancer classification, survival analysis, and multimodal integration tasks within the HoneyBee framework. It effectively filters:
108
+
109
+ - **Background regions**: Glass slide backgrounds, whitespace
110
+ - **Artifacts**: Pen marks, dust, blur, fold artifacts
111
+ - **Tissue regions**: High-quality H&E stained tissue for analysis
112
+
113
+ **Recommended threshold**: 0.8 probability for class 2 provides a good balance between recall and precision for tissue detection.
114
+
115
+ ## Training Data
116
+
117
+ The model was originally trained as part of the [SliDL](https://github.com/markowetzlab/slidl) project for tissue detection in histopathology whole slide images. Training details include H&E stained tissue sections with annotations for tissue/non-tissue regions.
118
+
119
+ ## Preprocessing
120
+
121
+ The model expects images preprocessed with standard ImageNet normalization:
122
+
123
+ ```python
124
+ from torchvision import transforms
125
+
126
+ preprocessing = transforms.Compose([
127
+ transforms.Resize(224),
128
+ transforms.ToTensor(),
129
+ transforms.Normalize(
130
+ mean=[0.485, 0.456, 0.406],
131
+ std=[0.229, 0.224, 0.225]
132
+ )
133
+ ])
134
+ ```
135
+
136
+ ## Limitations and Biases
137
+
138
+ - **Stain Variation**: Performance may vary with different staining protocols or scanners
139
+ - **Tissue Types**: Primarily validated on H&E stained tissue; may not generalize to other stains
140
+ - **Resolution**: Designed for patches at standard WSI resolution (~0.5 µm/pixel)
141
+ - **Artifacts**: May misclassify unusual artifacts not seen during training
142
+ - **Medical Use**: This model is for research purposes only and not intended for clinical diagnosis
143
+
144
+ ## Applications in Research
145
+
146
+ This tissue detector has been used in:
147
+ - **Cancer Classification**: TCGA multi-cancer type classification (BRCA, BLCA, KIRC, LIHC, etc.)
148
+ - **Survival Analysis**: Cox proportional hazards and deep survival models
149
+ - **Stain Normalization Studies**: Evaluating impact of Macenko/Reinhard normalization
150
+ - **Multimodal Integration**: Combining pathology with clinical, radiology, and molecular data
151
+ - **Foundation Model Evaluation**: Preprocessing for UNI, UNI2, Virchow2 embeddings
152
+
153
+ ## Citation
154
+
155
+ If you use this model, please cite the HoneyBee framework and the original SliDL project:
156
+
157
+ ```bibtex
158
+ @software{honeybee2024,
159
+ title={HoneyBee: A Scalable Modular Framework for Multimodal AI in Oncology},
160
+ author={Lab-Rasool},
161
+ year={2024},
162
+ url={https://github.com/lab-rasool/HoneyBee}
163
+ }
164
+
165
+ @software{slidl,
166
+ title={SliDL: A Python library for deep learning on whole-slide images},
167
+ author={Markowetz Lab},
168
+ url={https://github.com/markowetzlab/slidl}
169
+ }
170
+ ```
171
+
172
+ ## Model Card Authors
173
+
174
+ Lab-Rasool
175
+
176
+ ## Model Card Contact
177
+
178
+ For questions or issues, please open an issue on the [HoneyBee GitHub repository](https://github.com/lab-rasool/HoneyBee).
179
+
180
+ ## Additional Resources
181
+
182
+ - **HoneyBee Framework**: [https://github.com/lab-rasool/HoneyBee](https://github.com/lab-rasool/HoneyBee)
183
+ - **Documentation**: [https://lab-rasool.github.io/HoneyBee](https://lab-rasool.github.io/HoneyBee)
184
+ - **Original Model Source**: [SliDL GitHub](https://github.com/markowetzlab/slidl)
185
+
186
+ ## Version History
187
+
188
+ - **v1.0** (2024): Initial release with DenseNet121 architecture
189
+ - PyTorch state dict format
190
+ - SafeTensors format for improved loading
191
+ - Integration with HuggingFace Hub
config.json ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "densenet",
3
+ "architecture": "densenet121",
4
+ "num_classes": 3,
5
+ "input_size": [224, 224],
6
+ "in_channels": 3,
7
+ "classifier_input_features": 1024,
8
+ "framework": "pytorch",
9
+ "task": "image-classification",
10
+ "domain": "histopathology",
11
+ "modality": "whole-slide-imaging",
12
+ "license": "gpl-3.0",
13
+ "tags": [
14
+ "histopathology",
15
+ "tissue-detection",
16
+ "whole-slide-imaging",
17
+ "pathology",
18
+ "medical-imaging",
19
+ "densenet",
20
+ "image-classification",
21
+ "computational-pathology",
22
+ "cancer-research"
23
+ ],
24
+ "preprocessing": {
25
+ "resize": 224,
26
+ "normalization": {
27
+ "mean": [0.485, 0.456, 0.406],
28
+ "std": [0.229, 0.224, 0.225]
29
+ }
30
+ },
31
+ "class_labels": {
32
+ "0": "background",
33
+ "1": "artifact",
34
+ "2": "tissue"
35
+ },
36
+ "recommended_threshold": {
37
+ "class": 2,
38
+ "probability": 0.8,
39
+ "description": "Accept patches where class 2 (tissue) probability >= 0.8"
40
+ },
41
+ "version": "1.0.0",
42
+ "release_date": "2024",
43
+ "authors": [
44
+ "Lab-Rasool",
45
+ "Markowetz Lab (original training)"
46
+ ],
47
+ "huggingface_repo": "Lab-Rasool/tissue-detector",
48
+ "related_frameworks": [
49
+ "HoneyBee"
50
+ ]
51
+ }
deep-tissue-detector_densenet_state-dict.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6098cd238e3fe46f19ed967decc1cc53a1f5d582f99718a5703b2a2742297445
3
+ size 28325919
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:afc524a4357333f01bc4ebe9b8118a20927da90e3ea3f995af77994771dc67ec
3
+ size 28246476
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ torch>=1.9.0
2
+ torchvision>=0.10.0
3
+ huggingface_hub>=0.16.0
4
+ pillow>=8.0.0
5
+ numpy>=1.19.0