Meehai commited on
Commit
f4a9d56
1 Parent(s): 1ab474b
dronescapes_reader/dronescapes_representations.py CHANGED
@@ -19,7 +19,7 @@ class DepthRepresentation(NpzRepresentation):
19
  x = x.numpy()
20
  x = np.clip(x, self.min_depth, self.max_depth)
21
  x = np.nan_to_num((x - x.min()) / (x.max() - x.min()), 0)
22
- y = hot(x)[..., 0:3]
23
  y = np.uint8(y * 255)
24
  return y
25
 
@@ -27,7 +27,7 @@ class OpticalFlowRepresentation(NpzRepresentation):
27
  """OpticalFlowRepresentation. Implements depth task-specific stuff, like using flow_vis."""
28
  @overrides
29
  def plot_fn(self, x: tr.Tensor) -> np.ndarray:
30
- return flow_vis.flow_to_color(x.numpy())
31
 
32
  class SemanticRepresentation(NpzRepresentation):
33
  """SemanticRepresentation. Implements depth task-specific stuff, like using flow_vis."""
@@ -46,8 +46,8 @@ class SemanticRepresentation(NpzRepresentation):
46
 
47
  @overrides
48
  def plot_fn(self, x: tr.Tensor) -> np.ndarray:
 
49
  new_images = np.zeros((*x.shape, 3), dtype=np.uint8)
50
- x = x.numpy()
51
  for i in range(self.n_classes):
52
  new_images[x == i] = self.color_map[i]
53
  return new_images
 
19
  x = x.numpy()
20
  x = np.clip(x, self.min_depth, self.max_depth)
21
  x = np.nan_to_num((x - x.min()) / (x.max() - x.min()), 0)
22
+ y = hot(x.squeeze())[..., 0:3]
23
  y = np.uint8(y * 255)
24
  return y
25
 
 
27
  """OpticalFlowRepresentation. Implements depth task-specific stuff, like using flow_vis."""
28
  @overrides
29
  def plot_fn(self, x: tr.Tensor) -> np.ndarray:
30
+ return flow_vis.flow_to_color(x.squeeze().numpy())
31
 
32
  class SemanticRepresentation(NpzRepresentation):
33
  """SemanticRepresentation. Implements depth task-specific stuff, like using flow_vis."""
 
46
 
47
  @overrides
48
  def plot_fn(self, x: tr.Tensor) -> np.ndarray:
49
+ x = x.numpy().squeeze()
50
  new_images = np.zeros((*x.shape, 3), dtype=np.uint8)
 
51
  for i in range(self.n_classes):
52
  new_images[x == i] = self.color_map[i]
53
  return new_images