lightning_pose.utils

lightning_pose.utils.cropzoom Module

Functions

generate_cropped_labeled_frames(...)

Given model predictions, generates a bbox.csv, crops frames, and a cropped csv file.

generate_cropped_video(input_video_file, ...)

TODO make consistent with generate_cropped_labeled_frames

generate_cropped_csv_file(input_csv_file, ...)

Adjusts coordinates in the input CSV file either by adding or subtracting corresponding values from a bounding box CSV file.

lightning_pose.utils.io Module

Path handling functions.

Functions

ckpt_path_from_base_path(base_path, model_name)

Given a path to a hydra output with trained model, extract the model .ckpt file.

check_if_semi_supervised([losses_to_use])

Use config file to determine if model is semi-supervised.

get_keypoint_names([cfg, csv_file, header_rows])

return_absolute_path(possibly_relative_path)

Return absolute path from possibly relative path.

return_absolute_data_paths(data_cfg[, ...])

Generate absolute path for our example toy data.

extract_session_name_from_video(...)

Extract session name from video filename by removing the view name.

find_video_files_for_views(video_dir, view_names)

Search inside a folder to find a list of videos from different sessions and views, split them up and return a list of lists like [[session0_view0.mp4, session0_view1.mp4, ...], [session1_view0.mp4, session1_view1.mp4, ...], ...]

get_videos_in_dir(video_dir[, view_names, ...])

Gather videos to process from a single directory.

check_video_paths(video_paths[, view_names])

get_context_img_paths(center_img_path)

Given the path to a center image frame, return paths of 5 context frames (n-2, n-1, n, n+1, n+2).

split_video_files_by_view(video_paths, ...)

For a list of videos from different sessions and views, split them up and return a list of lists like [[session0_view0.mp4, session0_view1.mp4, ...], [session1_view0.mp4, session1_view1.mp4, ...], ...]

lightning_pose.utils.pca Module

PCA class to assist with computing PCA losses.

Functions

format_multiview_data_for_pca(data_arr, ...)

Reformat multiview data so each observation is a single body part across views.

Classes

KeypointPCA

Class to collect data from a dataloader and compute PCA params.

ComponentChooser

Determine the number of PCA components to keep.

lightning_pose.utils.predictions Module

Functions for predicting keypoints on labeled datasets and unlabeled videos.

Functions

predict_dataset(cfg, data_module, preds_file)

Save predicted keypoints for a labeled dataset.

predict_single_video(cfg_file, video_file, ...)

This function is deprecated.

make_dlc_pandas_index(cfg, keypoint_names)

get_model_class(map_type, semi_supervised)

[summary]

load_model_from_checkpoint(cfg, ckpt_file[, ...])

Load Lightning Pose model from checkpoint file.

create_labeled_video(clip, xs_arr, ys_arr[, ...])

Helper function for creating annotated videos. Args clip xs_arr: shape T x n_joints ys_arr: shape T x n_joints mask_array: shape T x n_joints; timepoints/joints with a False entry will not be plotted dotsize: size of marker dot on labeled video colormap: matplotlib color map for markers fps: None to default to fps of original video output_video_path: video file name start_time: time (in seconds) of video start.

export_predictions_and_labeled_video(...[, ...])

Deprecated, use predict_video and generate_labeled_video.

Classes

PredictionHandler

Convert batches of model outputs into a prediction dataframe.

lightning_pose.utils.scripts Module

Helper functions to build pipeline components from config dictionary.

Functions

get_imgaug_transform(cfg)

Create simple and flexible data transform pipeline that augments images and keypoints.

get_dataset(cfg, data_dir, imgaug_transform)

Create a dataset that contains labeled data.

get_data_module(cfg, dataset[, video_dir])

Create a data module that splits a dataset into train/val/test iterators.

get_loss_factories(cfg, data_module)

Create loss factory that orchestrates different losses during training.

get_model(cfg, data_module, loss_factories)

Create model: regression or heatmap based, supervised or semi-supervised.

get_callbacks(cfg[, early_stopping, ...])

calculate_steps_per_epoch(data_module)

compute_metrics(cfg, preds_file[, data_module])

Compute various metrics on predictions csv file, potentially for multiple views. Saves metrics to files next to predictions file, in the convention of: {prediction_file_stem}_{metric_name}.csv.