Video quality scoring processor, rates sampled frames based on CLIP-IQA and aggregates them into a video quality score
Details | Caution and prerequisites |
|---|---|
Costs | Before calling an operator, you need to understand the model invocation costs associated with using the operator. For details, see Large model invocation billing. |
Authentication (API Key) | Before calling an operator, you need to generate an API Key for operator invocation. It is recommended to configure the API Key as an environment variable to ensure safer operator calls. For details, see Obtain and configure API Key. |
BaseURL | Before calling an operator, you need to determine the BaseURL for operator invocation based on the region where your current LAS service is deployed. This is used to configure the path parameter values for operator calls. |
Input column name | Note |
|---|---|
video_paths | Optional, column for video file paths (local, TOS, HTTP, and so on); mutually exclusive with video_binaries |
video_binaries | Optional, column for video binary data; mutually exclusive with video_paths |
video_formats | Optional, column for video format strings, used with video_binaries |
Array of floating-point values containing video quality scores; returns null if scoring is not possible
If a parameter does not have a default value, it is required
Parameter name | Type | Default value | Description |
|---|---|---|---|
model_path | str | /opt/las/models | Model file storage path |
clip_model_name | str | openai/clip-vit-large-patch14 | CLIP model name or path |
prompt | str | quality | Quality evaluation prompt |
device | str | cuda | Device type, supports CPU and GPU devices |
sample_mode | str | by_count_uniform | Sampling mode, see VideoFrameSampler |
start_time_sec | float | 0.0 | Sampling start time (seconds) |
end_time_sec | float or None | Sampling end time (seconds) | |
count_k | int or None | 8 | Number of uniformly sampled frames (used with by_count_uniform) |
interval_sec | float or None | Time interval (seconds, used with by_interval_time) | |
interval_frames | int or None | Decoded frame interval (used with by_interval_frames) | |
target_fps | float or None | Target sampling FPS (used with by_fps) | |
timestamps_sec | list[float] or None | List of sampling timestamps (seconds, used with by_timestamps) | |
max_frames | int or None | Maximum number of returned frames | |
reduce_mode | str | avg | Multi-frame aggregation strategy, optional "avg" |
default_video_format | str | mp4 | Video format for binary/BASE64 input |
The following code demonstrates how to use Daft (for distributed scenarios) to run the operator for video quality scoring. Since the input is in URL format, only the model path needs to be configured.
from __future__ import annotations import os import daft from daft import col from daft.las.functions.udf import las_udf from daft.las.functions.video import VideoQualityScore if __name__ == "__main__": TOS_TEST_DIR_URL = os.getenv("TOS_TEST_DIR_URL", "las-cn-beijing-public-online.tos-cn-beijing.volces.com") model_path = os.getenv("MODEL_PATH", "/opt/las/models") if os.getenv("DAFT_RUNNER", "native") == "ray": import logging import ray def configure_logging(): logging.basicConfig( level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", datefmt="%Y-%m-%d %H:%M:%S", ) logging.getLogger("tracing.span").setLevel(logging.WARNING) logging.getLogger("daft_io.stats").setLevel(logging.WARNING) logging.getLogger("DaftStatisticsManager").setLevel(logging.WARNING) logging.getLogger("DaftFlotillaScheduler").setLevel(logging.WARNING) logging.getLogger("DaftFlotillaDispatcher").setLevel(logging.WARNING) ray.init(dashboard_host="0.0.0.0", runtime_env={"worker_process_setup_hook": configure_logging}) daft.set_runner_ray() daft.set_execution_config(actor_udf_ready_timeout=600) daft.set_execution_config(min_cpu_per_task=0) samples = { "video_path": [f"https://{TOS_TEST_DIR_URL}/public/shared_video_dataset/sample.mp4"], } ds = daft.from_pydict(samples) constructor_kwargs = { "model_path": model_path, "clip_model_name": "openai/clip-vit-large-patch14", "prompt": "quality", "device": "cuda", "sample_mode": "by_count_uniform", "count_k": 4, "reduce_mode": "avg", } ds = ds.with_column( "quality_score", las_udf(VideoQualityScore, construct_args=constructor_kwargs, num_gpus=1, batch_size=1, concurrency=1)( col("video_path") ), ) ds.show() # ╭────────────────────────────────┬────────────────────╮ # │ video_path ┆ quality_score │ # │ --- ┆ --- │ # │ String ┆ Float64 │ # ╞════════════════════════════════╪════════════════════╡ # │ https://las-cn-beijing-publi-… ┆ 0.37 │ # ╰────────────────────────────────┴────────────────────╯