lightning_pose.utils

lightning_pose.utils.cropzoom Module

Tools for cropping labeled frames and videos to bounding-box regions of interest.

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.

get_keypoint_names([cfg, csv_file, header_rows])

Return keypoint names from a label CSV file or from the config.

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 [[sess0_view0.mp4, sess0_view1.mp4, ...], [sess1_view0.mp4, sess1_view1.mp4, ...], ...]

get_videos_in_dir()

Gather videos to process from a single directory.

check_video_paths()

Validate and normalise video paths, returning a flat or nested list of mp4 paths.

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 [[sess0_view0.mp4, sess0_view1.mp4, ...], [sess1_view0.mp4, sess1_view1.mp4, ...], ...]

lightning_pose.utils.pca Module

PCA class to assist with computing PCA losses.

Functions

convert_dict_values_to_tensors(param_dict, ...)

Convert all values in a parameter dictionary to float tensors on the given device.

format_multiview_data_for_pca(data_arr, ...)

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

Classes

ComponentChooser

Determine the number of PCA components to keep.

EmpiricalEpsilon

Find percentile value of a given loss tensor.

KeypointPCA

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

lightning_pose.utils.predictions Module

Functions for predicting keypoints on labeled datasets and unlabeled videos.

Functions

predict_dataset(model, data_module, preds_file)

Save predicted keypoints for a labeled dataset.

predict_video()

make_dlc_pandas_index(cfg, keypoint_names)

Create a DLC-style three-level pandas MultiIndex for prediction DataFrames.

generate_labeled_video(video_file, preds_df, ...)

Overlay keypoint markers on a video and write the result to disk.

Classes

PredictionHandler

Convert batches of model outputs into a prediction dataframe.