roobee79 commited on
Commit
b4cfeaa
Β·
verified Β·
1 Parent(s): 1f28efb

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +94 -13
README.md CHANGED
@@ -33,11 +33,11 @@ It takes 256Γ—256 px patches as input and outputs per-cell contours, centroids,
33
  The full pipeline consists of three steps:
34
 
35
  ```
36
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
37
- β”‚ 1. Normalize β”‚ ──→ β”‚ 2. Patchify β”‚ ──→ β”‚ 3. Inference β”‚
38
- β”‚ (Reinhard) β”‚ β”‚(256px, 64ov) β”‚ β”‚(Cell Detection) β”‚
39
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
40
- SVS / TIF PNG patches Masks + Centroids
41
  ```
42
 
43
  ### Magnification
@@ -100,6 +100,81 @@ python inference.py \
100
 
101
  ---
102
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  ## Input / Output Details
104
 
105
  ### Input
@@ -141,7 +216,9 @@ y_global = y + y_offset
141
 
142
  ## Normalization Reference Image
143
 
144
- The pipeline uses Reinhard color normalization in LAB color space. You need a reference image (`standard-ilc.tif`) that represents your target stain appearance. Include this file alongside the model or provide your own.
 
 
145
 
146
  ---
147
 
@@ -149,13 +226,15 @@ The pipeline uses Reinhard color normalization in LAB color space. You need a re
149
 
150
  ```
151
  HNE2Cell/
152
- β”œβ”€β”€ README.md # This file
153
- β”œβ”€β”€ HNE2cell_all_patch73_jit.pt # TorchScript model
154
- β”œβ”€β”€ post_processing.py # Cell post-processing module
155
- β”œβ”€β”€ normalize.py # Step 1: Reinhard normalization
156
- β”œβ”€β”€ patchify.py # Step 2: Patch extraction
157
- β”œβ”€β”€ inference.py # Step 3: Model inference
158
- └── standard-ilc.tif # Reference image for normalization
 
 
159
  ```
160
 
161
  ---
@@ -172,3 +251,5 @@ If you use HNE2Cell in your research, please cite:
172
  }
173
  ```
174
 
 
 
 
33
  The full pipeline consists of three steps:
34
 
35
  ```
36
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
37
+ β”‚ 1. Normalize β”‚ ──→ β”‚ 2. Patchify β”‚ ──→ β”‚ 3. Inference β”‚
38
+ β”‚ (Reinhard) β”‚ β”‚ (256px, 64ov) β”‚ β”‚ (Cell Detection)β”‚
39
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
40
+ SVS / TIF PNG patches Masks + Centroids
41
  ```
42
 
43
  ### Magnification
 
100
 
101
  ---
102
 
103
+ ## Example: Reproducible Walkthrough
104
+
105
+ To verify your installation, run the pipeline on the example slide included in this repository
106
+ (`TCGA-56-8628-01Z-00-DX1`, LUSC, ~36 MB).
107
+
108
+ ### Download the model, example slide, and reference image
109
+
110
+ ```python
111
+ from huggingface_hub import hf_hub_download
112
+
113
+ REPO_ID = "roobee79/HNE2Cell"
114
+
115
+ model_path = hf_hub_download(
116
+ repo_id=REPO_ID,
117
+ filename="HNE2cell_all_patch73_jit.pt"
118
+ )
119
+
120
+ slide_path = hf_hub_download(
121
+ repo_id=REPO_ID,
122
+ filename="TCGA-56-8628-01Z-00-DX1.AAC57164-E0F9-4DF0-87EA-5C50FB201895.svs"
123
+ )
124
+
125
+ ref_path = hf_hub_download(
126
+ repo_id=REPO_ID,
127
+ filename="standard-ilc.tif"
128
+ )
129
+ ```
130
+
131
+ ### Run the pipeline
132
+
133
+ ```bash
134
+ # Place the downloaded slide in a working directory
135
+ mkdir -p example/slides
136
+ cp <slide_path> example/slides/
137
+
138
+ # Step 1: Normalize
139
+ python normalize.py \
140
+ --input_dir ./example/slides \
141
+ --target ./standard-ilc.tif
142
+
143
+ # Step 2: Patchify at 40x
144
+ python patchify.py \
145
+ --input_dir ./example/slides \
146
+ --magnification 40 \
147
+ --patch_size 256 \
148
+ --overlap 64 \
149
+ --workers 8
150
+
151
+ # Step 3: Inference
152
+ python inference.py \
153
+ --input_dir ./example/slides/TCGA-56-8628-01Z-00-DX1.../patches \
154
+ --output_dir ./example/results \
155
+ --model_path ./HNE2cell_all_patch73_jit.pt \
156
+ --magnification 40 \
157
+ --batch_size 32
158
+ ```
159
+
160
+ ### Expected output
161
+
162
+ ```
163
+ example/results/
164
+ β”œβ”€β”€ Aligned-hne.tif # Normalized full-resolution H&E
165
+ β”œβ”€β”€ Aligned-hne.jpg # 4Γ— preview
166
+ β”œβ”€β”€ patch_*_mask.png # Per-patch cell type masks
167
+ └── patch_*_centroid.csv # Cell centroids with type labels
168
+ ```
169
+
170
+ Approximate runtime on a single NVIDIA A100: **~20 min** for the full slide
171
+ (~XXX,XXX cells detected across 16 classes).
172
+
173
+ > The example slide is from **TCGA-LUSC** and is redistributed under the
174
+ > [NIH Genomic Data Sharing Policy](https://sharing.nih.gov/genomic-data-sharing-policy).
175
+
176
+ ---
177
+
178
  ## Input / Output Details
179
 
180
  ### Input
 
216
 
217
  ## Normalization Reference Image
218
 
219
+ The pipeline uses Reinhard color normalization in LAB color space. You need a reference image
220
+ (`standard-ilc.tif`) that represents your target stain appearance. The reference image is
221
+ included in this repository, or you can supply your own.
222
 
223
  ---
224
 
 
226
 
227
  ```
228
  HNE2Cell/
229
+ β”œβ”€β”€ README.md # This file
230
+ β”œβ”€β”€ HNE2cell_all_patch73_jit.pt # TorchScript model
231
+ β”œβ”€β”€ normalize.py # Step 1: Reinhard normalization
232
+ β”œβ”€β”€ patchify.py # Step 2: Patch extraction
233
+ β”œβ”€β”€ inference.py # Step 3: Model inference
234
+ β”œβ”€β”€ post_processing.py # Cell post-processing module
235
+ β”œβ”€β”€ tools.py # Utility functions
236
+ β”œβ”€β”€ standard-ilc.tif # Reference image for normalization
237
+ └── TCGA-56-8628-01Z-00-DX1.AAC57164-E0F9-4DF0-87EA-5C50FB201895.svs # Example slide (TCGA-LUSC)
238
  ```
239
 
240
  ---
 
251
  }
252
  ```
253
 
254
+ The example slide is derived from data generated by the TCGA Research Network:
255
+ <https://www.cancer.gov/tcga>.