Implementation:Datajuicer Data juicer VideoMotionScorePtlflowFilter
| Knowledge Sources | |
|---|---|
| Domains | Data_Quality, Filtering |
| Last Updated | 2026-02-14 16:00 GMT |
Overview
Concrete tool for filtering data samples based on video motion score (ptlflow) provided by Data-Juicer.
Description
VideoMotionScorePtlflowFilter is a filter operator that keeps samples where the video motion score computed using deep optical flow models from the ptlflow library falls within a specified range. It extends VideoMotionScoreFilter and replaces the OpenCV Farneback algorithm with deep learning optical flow models from ptlflow (default: dpflow with things checkpoint). Preprocesses frames with normalization and color channel flipping, runs the model to predict optical flow, and computes the mean flow magnitude. Supports configurable model selection, GPU acceleration, and all parent class features (FPS sampling, relative normalization, etc.). Provides higher-accuracy motion estimation at higher computational cost.
Usage
Import when filtering based on deep-learning video motion score using ptlflow. Configure in YAML or Python.
Code Reference
Source Location
- Repository: Datajuicer_Data_juicer
- File: data_juicer/ops/filter/video_motion_score_ptlflow_filter.py
Signature
@OPERATORS.register_module("video_motion_score_ptlflow_filter")
class VideoMotionScorePtlflowFilter(VideoMotionScoreFilter):
def __init__(self, min_score: float = 1.0, max_score: float = sys.float_info.max, frame_field: Optional[str] = None, model_name: str = "dpflow", ckpt_path: Optional[str] = "things", get_model_args: Optional[dict] = None, sampling_fps: PositiveFloat = 2, size: Union[PositiveInt, Tuple[PositiveInt], Tuple[PositiveInt, PositiveInt], None] = None, max_size: Optional[PositiveInt] = None, divisible: PositiveInt = 8, relative: bool = False, any_or_all: str = "any", if_output_optical_flow: bool = False, optical_flow_key: str = MetaKeys.video_optical_flow, *args, **kwargs):
Import
from data_juicer.ops.filter.video_motion_score_ptlflow_filter import VideoMotionScorePtlflowFilter
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| min_score | float | No | Minimum motion score (default: 1.0) |
| max_score | float | No | Maximum motion score (default: sys.float_info.max) |
| model_name | str | No | ptlflow model name (default: "dpflow") |
| ckpt_path | Optional[str] | No | Model checkpoint path (default: "things") |
| get_model_args | Optional[dict] | No | Additional model arguments (default: None) |
| sampling_fps | PositiveFloat | No | Sampling rate in frames per second (default: 2) |
| divisible | PositiveInt | No | Frame dimensions must be divisible by this (default: 8) |
| any_or_all | str | No | Keep strategy: "any" or "all" (default: "any") |
Outputs
| Name | Type | Description |
|---|---|---|
| samples | Dict | Filtered samples with video_motion_score stat computed |
Usage Examples
YAML Configuration
process:
- video_motion_score_ptlflow_filter:
min_score: 1.0
model_name: dpflow
sampling_fps: 2
Python API
from data_juicer.ops.filter.video_motion_score_ptlflow_filter import VideoMotionScorePtlflowFilter
op = VideoMotionScorePtlflowFilter(min_score=1.0, model_name="dpflow")