Skip to content

Commit ce348e7

Browse files
🐛 Fix HoVer-Net Class Output Information in docs (TissueImageAnalytics#751)
- [X] Fix bug with HoVer-Net, where currently merging classes 0 and 1. This is resulting in the background class being omitted and merged with the first. - [x] Add the output nuclear classes for the nuclear instance segmentation models to the documentation. We have also added type dictionaries to the pretrained_yaml file. - [x] Update notebooks to show this correction. --------- Co-authored-by: Shan E Ahmed Raza <[email protected]>
1 parent 728494e commit ce348e7

File tree

5 files changed

+101
-16
lines changed

5 files changed

+101
-16
lines changed

docs/pretrained.rst

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,15 @@ The input output configuration is as follows:
185185

186186
- hovernet_fast-pannuke
187187

188+
.. collapse:: Output Nuclear Classes
189+
190+
- 0: Background
191+
- 1: Neoplastic
192+
- 2: Inflammatory
193+
- 3: Connective
194+
- 4: Dead
195+
- 5: Non-Neoplastic Epithelial
196+
188197
MoNuSAC Dataset
189198
---------------
190199

@@ -218,6 +227,14 @@ The input output configuration is as follows:
218227

219228
- hovernet_fast-monusac
220229

230+
.. collapse:: Output Nuclear Classes
231+
232+
- 0: Background
233+
- 1: Epithelial
234+
- 2: Lymphocyte
235+
- 3: Macrophage
236+
- 4: Neutrophil
237+
221238
CoNSeP Dataset
222239
--------------
223240

@@ -251,6 +268,14 @@ The input output configuration is as follows:
251268

252269
- hovernet_original-consep
253270

271+
.. collapse:: Output Nuclear Classes
272+
273+
- 0: Background
274+
- 1: Epithelial
275+
- 2: Inflammatory
276+
- 3: Spindle-Shaped
277+
- 4: Miscellaneous
278+
254279

255280
.. collapse:: Input Output Configuration Details
256281

@@ -275,11 +300,13 @@ The input output configuration is as follows:
275300

276301
- micronet_hovernet-consep
277302

303+
278304
Kumar Dataset
279305
-------------
280306

281307
We provide the following models trained using the `Kumar dataset <https://monuseg.grand-challenge.org/>`_.
282308
All model weights trained on Kumar are held under the `Creative Commons Attribution-NonCommercial-ShareAlike Version 4 (CC BY-NC-SA 4.0) License <https://creativecommons.org/licenses/by-nc-sa/4.0/>`_.
309+
The Kumar dataset does not contain nuclear class information, and so TIAToolbox pretrained models based on Kumar for nuclear segmentation, will only perform segmentation and not classification.
283310
The input output configuration is as follows:
284311

285312
.. collapse:: Input Output Configuration Details
@@ -428,3 +455,17 @@ The model uses the following input output configuration:
428455
.. collapse:: Model names
429456

430457
- hovernetplus-oed
458+
459+
.. collapse:: Output Nuclear Classes
460+
461+
- 0: Background
462+
- 1: Other
463+
- 2: Epithelial
464+
465+
.. collapse:: Output Region Classes
466+
467+
- 0: Background
468+
- 1: Other Tissue
469+
- 2: Basal Epithelium
470+
- 3: (Core) Epithelium
471+
- 4: Keratin

examples/08-nucleus-instance-segmentation.ipynb

Lines changed: 19 additions & 16 deletions
Large diffs are not rendered by default.

tiatoolbox/data/pretrained_model.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,14 @@ hovernet_fast-pannuke:
643643
kwargs:
644644
num_types: 6
645645
mode: "fast"
646+
nuc_type_dict: {
647+
0: "Background",
648+
1: "Neoplastic",
649+
2: "Inflammatory",
650+
3: "Connective",
651+
4: "Dead",
652+
5: "Non-Neoplastic Epithelial",
653+
}
646654
ioconfig:
647655
class: semantic_segmentor.IOSegmentorConfig
648656
kwargs:
@@ -666,6 +674,13 @@ hovernet_fast-monusac:
666674
kwargs:
667675
num_types: 5
668676
mode: "fast"
677+
nuc_type_dict: {
678+
0: "Background",
679+
1: "Epithelial",
680+
2: "Lymphocyte",
681+
3: "Macrophage",
682+
4: "Neutrophil",
683+
}
669684
ioconfig:
670685
class: semantic_segmentor.IOSegmentorConfig
671686
kwargs:
@@ -689,6 +704,13 @@ hovernet_original-consep:
689704
kwargs:
690705
num_types: 5
691706
mode: "original"
707+
nuc_type_dict: {
708+
0: "Background",
709+
1: "Epithelial",
710+
2: "Inflammatory",
711+
3: "Spindle-Shaped",
712+
4: "Miscellaneous",
713+
}
692714
ioconfig:
693715
class: semantic_segmentor.IOSegmentorConfig
694716
kwargs:
@@ -734,6 +756,18 @@ hovernetplus-oed:
734756
kwargs:
735757
num_types: 3
736758
num_layers: 5
759+
nuc_type_dict: {
760+
0: "Background",
761+
1: "Other",
762+
2: "Epithelial",
763+
}
764+
layer_type_dict: {
765+
0: "Background",
766+
1: "Other Tissue",
767+
2: "Basal Epithelium",
768+
3: "(Core) Epithelium",
769+
4: "Keratin",
770+
}
737771
ioconfig:
738772
class: semantic_segmentor.IOSegmentorConfig
739773
kwargs:

tiatoolbox/models/architecture/hovernet.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,11 +329,13 @@ def __init__(
329329
num_input_channels: int = 3,
330330
num_types: int | None = None,
331331
mode: str = "original",
332+
nuc_type_dict: dict | None = None,
332333
) -> None:
333334
"""Initialize :class:`HoVerNet`."""
334335
super().__init__()
335336
self.mode = mode
336337
self.num_types = num_types
338+
self.nuc_type_dict = nuc_type_dict
337339

338340
if mode not in ["original", "fast"]:
339341
msg = (
@@ -771,6 +773,7 @@ def postproc(raw_maps: list[np.ndarray]) -> tuple[np.ndarray, dict]:
771773
"""
772774
if len(raw_maps) == 3: # noqa: PLR2004
773775
np_map, hv_map, tp_map = raw_maps
776+
tp_map = np.around(tp_map).astype("uint8")
774777
else:
775778
tp_map = None
776779
np_map, hv_map = raw_maps

tiatoolbox/models/architecture/hovernetplus.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,16 @@ def __init__(
8585
num_input_channels: int = 3,
8686
num_types: int | None = None,
8787
num_layers: int | None = None,
88+
nuc_type_dict: dict | None = None,
89+
layer_type_dict: dict | None = None,
8890
) -> None:
8991
"""Initialize :class:`HoVerNetPlus`."""
9092
super().__init__(mode="fast")
9193
self.num_input_channels = num_input_channels
9294
self.num_types = num_types
9395
self.num_layers = num_layers
96+
self.nuc_type_dict = nuc_type_dict
97+
self.layer_type_dict = layer_type_dict
9498
ksize = 3
9599

96100
self.decoder = nn.ModuleDict(

0 commit comments

Comments
 (0)