Skip to content

Commit

Permalink
Fix model shortcut bug (#100)
Browse files Browse the repository at this point in the history
Transforms occurring before shortcut test could give false negative that shortcut should be taken
  • Loading branch information
tayden authored Feb 9, 2024
1 parent f9f45ff commit 044a9c3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions kelp_o_matic/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ def __call__(self):
# Reorder bands
crop = crop[:, :, [b - 1 for b in self.band_order]]

if self.model.transform:
crop = self.model.transform(crop / self._max_value)

if torch.all(crop == 0):
if (crop == 0).all():
logits = self.model.shortcut(self.reader.crop_size)
else:
if self.model.transform:
crop = self.model.transform(crop / self._max_value)

# Zero pad to correct shape
_, h, w = crop.shape
crop = torch.nn.functional.pad(
Expand Down

0 comments on commit 044a9c3

Please sign in to comment.