Meehai commited on
Commit
6a58a50
·
1 Parent(s): 9fe8f32

no need to be argmaex

Browse files
dronescapes_reader/dronescapes_representations.py CHANGED
@@ -68,6 +68,9 @@ class SemanticRepresentation(NpzRepresentation):
68
  @overrides
69
  def load_from_disk(self, path: Path) -> tr.Tensor:
70
  res = super().load_from_disk(path)
 
 
 
71
  assert len(res.shape) == 2, f"Only argmaxed data supported, got: {res.shape}"
72
  res = F.one_hot(res.long(), num_classes=self.n_classes).float()
73
  return res
 
68
  @overrides
69
  def load_from_disk(self, path: Path) -> tr.Tensor:
70
  res = super().load_from_disk(path)
71
+ if len(res.shape) == 3:
72
+ assert res.shape[-1] == self.n_classes, f"Expected {self.n_classes} (HxWxC), got {res.shape[-1]}"
73
+ res = res.argmax(-1)
74
  assert len(res.shape) == 2, f"Only argmaxed data supported, got: {res.shape}"
75
  res = F.one_hot(res.long(), num_classes=self.n_classes).float()
76
  return res