HoVerNet model References: Graham, Simon et al. Hover-net: Simultaneous segmentation and classification of nuclei in multi-tissue histology images, Medical Image Analysis 2019 https://github.com/vqdang/hover_net https://pytorch.org/vision/main/models/generated/tor
| 410 | |
| 411 | |
| 412 | class HoVerNet(nn.Module): |
| 413 | """HoVerNet model |
| 414 | |
| 415 | References: |
| 416 | Graham, Simon et al. Hover-net: Simultaneous segmentation |
| 417 | and classification of nuclei in multi-tissue histology images, |
| 418 | Medical Image Analysis 2019 |
| 419 | |
| 420 | https://github.com/vqdang/hover_net |
| 421 | https://pytorch.org/vision/main/models/generated/torchvision.models.resnet50.html |
| 422 | |
| 423 | This network is non-deterministic since it uses `torch.nn.Upsample` with ``UpsampleMode.NONTRAINABLE`` mode which |
| 424 | is implemented with torch.nn.functional.interpolate(). Please check the link below for more details: |
| 425 | https://pytorch.org/docs/stable/generated/torch.use_deterministic_algorithms.html#torch.use_deterministic_algorithms |
| 426 | |
| 427 | Args: |
| 428 | mode: use original implementation (`HoVerNetMODE.ORIGINAL` or "original") or |
| 429 | a faster implementation (`HoVerNetMODE.FAST` or "fast"). Defaults to `HoVerNetMODE.FAST`. |
| 430 | in_channels: number of the input channel. |
| 431 | np_out_channels: number of the output channel of the nucleus prediction branch. |
| 432 | out_classes: number of the nuclear type classes. |
| 433 | act: activation type and arguments. Defaults to relu. |
| 434 | norm: feature normalization type and arguments. Defaults to batch norm. |
| 435 | decoder_padding: whether to do padding on convolution layers in the decoders. In the conic branch |
| 436 | of the referred repository, the architecture is changed to do padding on convolution layers in order to |
| 437 | get the same output size as the input, and this changed version is used on CoNIC challenge. |
| 438 | Please note that to get consistent output size, `HoVerNetMode.FAST` mode should be employed. |
| 439 | dropout_prob: dropout rate after each dense layer. |
| 440 | pretrained_url: if specifying, will loaded the pretrained weights downloaded from the url. |
| 441 | There are two supported forms of weights: |
| 442 | 1. preact-resnet50 weights coming from the referred hover_net |
| 443 | repository, each user is responsible for checking the content of model/datasets and the applicable licenses |
| 444 | and determining if suitable for the intended use. please check the following link for more details: |
| 445 | https://github.com/vqdang/hover_net#data-format |
| 446 | 2. standard resnet50 weights of torchvision. Please check the following link for more details: |
| 447 | https://pytorch.org/vision/main/_modules/torchvision/models/resnet.html#ResNet50_Weights |
| 448 | adapt_standard_resnet: if the pretrained weights of the encoder follow the original format (preact-resnet50), this |
| 449 | value should be `False`. If using the pretrained weights that follow torchvision's standard resnet50 format, |
| 450 | this value should be `True`. |
| 451 | pretrained_state_dict_key: this arg is used when `pretrained_url` is provided and `adapt_standard_resnet` is True. |
| 452 | It is used to extract the expected state dict. |
| 453 | freeze_encoder: whether to freeze the encoder of the network. |
| 454 | """ |
| 455 | |
| 456 | Mode = HoVerNetMode |
| 457 | Branch = HoVerNetBranch |
| 458 | |
| 459 | def __init__( |
| 460 | self, |
| 461 | mode: HoVerNetMode | str = HoVerNetMode.FAST, |
| 462 | in_channels: int = 3, |
| 463 | np_out_channels: int = 2, |
| 464 | out_classes: int = 0, |
| 465 | act: str | tuple = ("relu", {"inplace": True}), |
| 466 | norm: str | tuple = "batch", |
| 467 | decoder_padding: bool = False, |
| 468 | dropout_prob: float = 0.0, |
| 469 | pretrained_url: str | None = None, |
no outgoing calls
searching dependent graphs…