You need to enable JavaScript to run this app.
Lake AI Service

Lake AI Service

Copy page
Download PDF
Image processing
Image quality scoring
Copy page
Download PDF
Image quality scoring

Operator introduction

Description

Image quality scoring processor, evaluates image visual quality based on CLIP-IQA

Key features:

  • Quality scoring: Outputs a score in the range of 0–1, with higher scores indicating better visual quality
  • Multi-source support: Supports input via URL, TOS, local path, binary stream, and more
  • Stable processing: Processes each image individually, suitable for multi-source image input
  • Configurable prompts: Supports custom prompts

Format support:

  • Input: Supports multiple formats such as image URL, TOS address, binary stream
  • Output: Floating-point quality score (0.0–1.0)
  • Image formats: Mainstream image formats such as JPG, PNG, WebP
  • Resolution: Automatically adapts to images of different resolutions

Scoring principle:

  • Visual feature extraction: Uses the CLIP model to extract image features
  • Prompt comparison: Calculates similarity between the image and the prompt
  • Probability output: Returns the probability that the image is closer to the positive prompt

Caution and prerequisites

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.
For details, see Obtain the Base URL. The Examples below are for reference only; when making actual calls, replace the path values with those corresponding to your region.

Daft invocation

Operator parameters

Input

Input column name

Description

image_inputs

Array containing input images

Output

Floating-point array containing quality scores, score range 0.0–1.0.
Images that cannot be decoded or processed return a null value

Parameters

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
Default value: "cuda"
Optional values: "cpu", "cuda", "cuda:0", "cuda:1", and so on

Examples

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               │
    # ╰────────────────────────────────┴────────────────────╯
Last updated: 2026.05.24 15:22:50