Image quality scoring processor, evaluates image visual quality based on CLIP-IQA
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 | Description |
|---|---|
image_inputs | Array containing input images |
Floating-point array containing quality scores, score range 0.0–1.0.
Images that cannot be decoded or processed return a null value
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 assessment prompt, defaults to "quality" |
device | str | cuda | Device type, supports CPU and GPU devices |
The following code demonstrates how to use Daft (for distributed scenarios) to run the operator for image quality scoring.
from __future__ import annotations import os import daft from daft import col from daft.las.functions.image import ImageQualityScore from daft.las.functions.udf import las_udf 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 = { "input_path": [f"https://{TOS_TEST_DIR_URL}/public/shared_image_dataset/forest.jpg"], } ds = daft.from_pydict(samples) constructor_kwargs = { "model_path": model_path, "clip_model_name": "openai/clip-vit-large-patch14", "prompt": "quality", } ds = ds.with_column( "quality_score", las_udf( ImageQualityScore, construct_args=constructor_kwargs, num_gpus=1, concurrency=1, batch_size=1, )(col("input_path")), ) ds.show() # ╭────────────────────────────────┬────────────────────╮ # │ input_path ┆ quality_score │ # │ --- ┆ --- │ # │ String ┆ Float64 │ # ╞════════════════════════════════╪════════════════════╡ # │ https://las-cn-beijing-publi-… ┆ 0.39 │ # ╰────────────────────────────────┴────────────────────╯