Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option to choose colormap for labelled videos #211

Merged
merged 2 commits into from
Nov 4, 2024
Merged
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
4 changes: 2 additions & 2 deletions lightning_pose/utils/predictions.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ def load_model_from_checkpoint(


@typechecked
def make_cmap(number_colors: int, cmap: str = "cool"):
def make_cmap(number_colors: int, cmap: str):
color_class = plt.cm.ScalarMappable(cmap=cmap)
C = color_class.to_rgba(np.linspace(0, 1, number_colors))
colors = (C[:, :3] * 255).astype(np.uint8)
Expand All @@ -750,7 +750,7 @@ def create_labeled_video(
ys_arr: np.ndarray,
mask_array: Optional[np.ndarray] = None,
dotsize: int = 4,
colormap: str = "cool",
colormap: Optional[str] = "cool",
fps: Optional[float] = None,
filename: str = "movie.mp4",
start_time: float = 0.0,
Expand Down
1 change: 1 addition & 0 deletions lightning_pose/utils/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,4 +756,5 @@ def export_predictions_and_labeled_video(
ys_arr=ys_arr,
mask_array=mask_array,
filename=labeled_mp4_file,
colormap=colormap=cfg.eval.get("colormap", "cool")
)
4 changes: 4 additions & 0 deletions scripts/configs/config_default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ eval:
# set to null to skip automatic video prediction from train_hydra.py script
# used in scripts/train_hydra.py and scripts/predict_new_vids.py
test_videos_directory: null
# matplotlib sequential or diverging colormap name for prediction visualization
# sequential options: viridis, plasma, magma, inferno, cool, etc.
# diverging options: RdBu, coolwarm, Spectral, etc.
colormap: "cool"
# confidence threshold for plotting a vid
confidence_thresh_for_vid: 0.90

Expand Down