MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / forward

Method forward

monai/networks/nets/hovernet.py:582–609  ·  view source on GitHub ↗
(self, x: torch.Tensor)

Source from the content-addressed store, hash-verified

580 _load_pretrained_encoder(self, weights)
581
582 def forward(self, x: torch.Tensor) -> dict[str, torch.Tensor]:
583 if self.mode == HoVerNetMode.ORIGINAL.value:
584 if x.shape[-1] != 270 or x.shape[-2] != 270:
585 raise ValueError("Input size should be 270 x 270 when using HoVerNetMode.ORIGINAL")
586 else:
587 if x.shape[-1] != 256 or x.shape[-2] != 256:
588 raise ValueError("Input size should be 256 x 256 when using HoVerNetMode.FAST")
589
590 x = self.conv0(x)
591 short_cuts = []
592
593 for i, block in enumerate(self.res_blocks):
594 x = block.forward(x)
595
596 if i <= 2:
597 short_cuts.append(x)
598
599 x = self.bottleneck(x)
600 x = self.upsample(x)
601
602 output = {
603 HoVerNetBranch.NP.value: self.nucleus_prediction(x, short_cuts),
604 HoVerNetBranch.HV.value: self.horizontal_vertical(x, short_cuts),
605 }
606 if self.type_prediction is not None:
607 output[HoVerNetBranch.NC.value] = self.type_prediction(x, short_cuts)
608
609 return output
610
611
612def _load_pretrained_encoder(model: nn.Module, state_dict: OrderedDict | dict):

Callers 2

test_ill_input_shapeMethod · 0.95
forwardMethod · 0.45

Calls 1

appendMethod · 0.45

Tested by 1

test_ill_input_shapeMethod · 0.76