xpark.dataset.VideoAestheticScore#

class xpark.dataset.VideoAestheticScore(_local_model: str = 'shunk031/aesthetics-predictor-v2-sac-logos-ava1-l14-linearMSE', num_frames: int | None = None, fps: int | None = None, keyframes_only: bool = True, start_time: float = 0.0, end_time: float | None = None, reduce_mode: Literal['avg', 'max', 'min'] = 'avg', normalized: bool = False)#

Video aesthetic score processor based on LAION Aesthetic.

Extracts frames from video, scores each frame with CLIP-based aesthetic predictor, then aggregates frame scores into a single video-level score.

Parameters:
  • _local_model – The CLIP base aesthetic model name. default: “shunk031/aesthetics-predictor-v2-sac-logos-ava1-l14-linearMSE” available models: [‘shunk031/aesthetics-predictor-v2-sac-logos-ava1-l14-linearMSE’, ‘shunk031/aesthetics-predictor-v1-vit-large-patch14’]

  • num_frames – Number of frames to extract uniformly. Default 3 (when fps is also None).

  • fps – Extract frames at this frame rate, int type (mutually exclusive with num_frames).

  • keyframes_only – Only extract keyframes (I-frames). Default True. Keyframes are inherently representative of scene changes, providing the most discriminative frames with minimal decoding overhead.

  • start_time – Start time in seconds for frame extraction. Default 0.0.

  • end_time – End time in seconds for frame extraction. Default None (end of video).

  • reduce_mode – Aggregation method for frame scores (“avg”, “max”, “min”). Default “avg”.

  • normalized – Whether to normalize the score to [0, 1]. Default False (output 0-10).

Examples

from xpark.dataset.expressions import col
from xpark.dataset import VideoAestheticScore, from_items

ds = from_items([{"video": "/path/to/video.mp4"}])
ds = ds.with_column(
    "aesthetic_score",
    VideoAestheticScore(num_frames=5, reduce_mode="avg")
    .options(num_workers={"GPU": 1}, batch_size=2)
    .with_column(col("video")),
)
print(ds.take(1))

Methods

__call__(videos)

Call self as a function.

options(**kwargs)

with_column(videos)

__call__(videos: pa.ChunkedArray) pa.Array#

Call self as a function.

options(**kwargs: Unpack[ExprUDFOptions]) Self#
with_column(videos: pa.ChunkedArray) pa.Array#