Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion tiatoolbox/models/architecture/kongnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,9 +862,14 @@ def infer_batch(
imgs = imgs.to(device=device, dtype=torch.float32)
imgs = imgs.permute(0, 3, 1, 2) # to NCHW

try:
target_channels = model.target_channels
except AttributeError:
target_channels = model.module.target_channels

Comment on lines +865 to +869
with torch.inference_mode():
logits = model(imgs)
target_logits = logits[:, model.target_channels, :, :]
target_logits = logits[:, target_channels, :, :]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not _get_model_attr?

Copy link
Copy Markdown
Collaborator Author

@gozdeg gozdeg Jun 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shaneahmed _get_model_attr() was defined in engineABC, I don't think we can reach it from here

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you try this?

if hasattr(model, "target_channels"):
  target_channels = model.target_channels
elif hasattr(model.module, "target_channels"):
  target_channels = model.module.target_channels
else:
  raise AttributeError:

Comment on lines +865 to +872
probs = torch.nn.functional.sigmoid(target_logits)
probs = probs.permute(0, 2, 3, 1) # to NHWC

Expand Down
4 changes: 2 additions & 2 deletions tiatoolbox/models/engine/nucleus_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,10 @@ def post_process_wsi(
# min_distance and postproc_tile_shape cannot be None here
min_distance = kwargs.get("min_distance")
if min_distance is None:
min_distance = self.model.min_distance
min_distance = self._get_model_attr("min_distance")
tile_shape = kwargs.get("tile_shape")
Comment on lines 431 to 435
if tile_shape is None:
tile_shape = self.model.tile_shape
tile_shape = self._get_model_attr("tile_shape")

# Add halo (overlap) around each block for post-processing
depth_h = min_distance
Expand Down
Loading