Operator ID: daft.las.functions.video.video_sharpness.VideoSharpness
Video sharpness calculation processor that supports multiple sharpness evaluation methods and frame extraction strategies.
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 | Video file path column (local, TOS, HTTP, and so on), choose either video_paths or video_binaries |
video_binaries | Video binary data column, choose either video_binaries or video_paths |
video_formats | Video format string column, used together with video_binaries |
Array of structs containing sharpness results for all pooling methods. Each element includes:
If a parameter does not have a default value, it is required
Parameter name | Type | Default value | Description |
|---|---|---|---|
fps | float | 2.0 | Number of frames extracted per second. |
method | str | "laplacian" | Sharpness calculation method. |
max_frames | int | 100 | Maximum number of extracted frames. |
The following code demonstrates how to use Daft (for distributed scenarios) to run the operator for video sharpness calculation.
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.video_sharpness import VideoSharpness if __name__ == "__main__": 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) # Use environment variables to construct the URL tos_dir_url = os.getenv("TOS_DIR_URL", "las-cn-beijing-public-online.tos-cn-beijing.volces.com") samples = { "video_path": [ f"https://{tos_dir_url}/public/shared_video_dataset/sample.mp4" ] } ds = daft.from_pydict(samples) sharpness_calculator = las_udf( VideoSharpness, construct_args={ "fps": 2.0, "method": "laplacian", "max_frames": 100, }, num_gpus=1, concurrency=1, batch_size=1, ) # Use Daft for distributed processing ds = ds.with_column("video_sharpness", sharpness_calculator(col("video_path"))) ds.show() # ╭────────────────────────────────┬──────────────────────────────────╮ # │ video_path ┆ video_sharpness │ # │ --- ┆ --- │ # │ Utf8 ┆ Struct[mean: Float64, median: F… │ # ╞════════════════════════════════╪══════════════════════════════════╡ # │ https://las-cn-beijing-publi-… ┆ {mean: 1234.56, median: 1200.00… │ # ╰────────────────────────────────┴──────────────────────────────────╯