forked from autonomousvision/sdfstudio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
39 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ imageio==2.16.1 | |
ipywidgets>=7.6 | ||
jupyterlab | ||
kaleido | ||
matplotlib | ||
mediapy | ||
plotly==5.7.0 | ||
pylint==2.13.4 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
""" Helper functions for visualizing outputs """ | ||
|
||
import torch | ||
from matplotlib import cm | ||
from torchtyping import TensorType | ||
|
||
|
||
def apply_colormap(image: TensorType[..., 1], cmap="viridis") -> TensorType[..., 3]: | ||
"""Convert single channel to a color image. | ||
Args: | ||
image (TensorType[..., 1]): Single channel image. | ||
cmap (str, optional): Colormap for image. Defaults to 'turbo'. | ||
Returns: | ||
TensorType[..., 3]: Colored image | ||
""" | ||
|
||
colormap = cm.get_cmap(cmap) | ||
colormap = torch.tensor(colormap.colors).to(image.device) | ||
|
||
image = (image * 255).long() | ||
|
||
return colormap[image] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters