LitDaliWrapperο
- class lightning_pose.data.dali.LitDaliWrapper[source]ο
Bases:
DALIGenericIteratorTyped wrapper around a DALI pipeline iterator for Lightning Pose models.
Converts the raw list-of-dicts that
DALIGenericIteratoryields intoUnlabeledBatchDictorMultiviewUnlabeledBatchDictinstances. When abbox_dfis provided, each batchβs frames are also cropped per-frame and resized to the modelβs input dimensions before being returned._frame_idxtracks the iteratorβs position in the video (by frame number) so that_apply_bbox_cropreads the correct rows frombbox_df. It advances byseq_lenfor base models (non-overlapping windows) and byseq_len - 4for context models, because the DALI reader for context prediction uses a step ofseq_len - 4so that consecutive 5-frame windows overlap by 4 frames.Testing without a GPUο
This class can be instantiated without a real DALI pipeline or GPU for unit tests that only exercise the PyTorch post-processing logic (e.g.
_apply_bbox_crop):wrapper = object.__new__(LitDaliWrapper) wrapper.do_context = False wrapper.bbox_df = my_df wrapper.resize_dims = [256, 256] wrapper._frame_idx = 0
- __init__(*args: Any, eval_mode: Literal['train', 'predict'], num_iters: int = 1, do_context: bool = False, bbox_df: DataFrame | None = None, resize_dims: list[int] | None = None, **kwargs: Any) None[source]ο
Wrapper around DALIGenericIterator to get batches for pl.
- Parameters:
eval_mode β
"train"or"predict".num_iters β number of enumerations of dataloader (should be computed outside for now; should be fixed by lightning/dali teams)
do_context β whether model/loader use 5-frame context or not
bbox_df β optional DataFrame with columns
["x", "y", "h", "w"], one row per frame. When provided, each batchβs frames are cropped per-frame and resized toresize_dimsbefore being returned, and thebboxfield of the batch dict is populated with the actual bbox coordinates.resize_dims β target
[height, width]for post-crop resize; required whenbbox_dfis not None.
- __new__(**kwargs)ο