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

Lake AI Service

Copy page
Download PDF
Image processing
Image aesthetic scoring
Copy page
Download PDF
Image aesthetic scoring

Operator introduction

Description

Image aesthetic scoring processor, intelligently evaluates the aesthetic quality and composition of images

Key features

  • Aesthetic scoring: Professional evaluation of the aesthetic quality of input images
  • Composition analysis: Analyzes image composition based on visual perception theory
  • Standardized output: Scores are normalized to the range 0–1 for easier subsequent processing
  • Batch processing: Supports efficient batch image scoring
  • Multi-format support: Compatible with multiple image input formats

Format support

  • Input: Supports multiple formats including image URLs, TOS addresses, and binary streams
  • Output: Floating-point aesthetic score (0.0–1.0); higher values indicate better aesthetic quality
  • Image formats: Mainstream formats such as JPG, PNG, WebP
  • Resolution: Automatically adapts to different image input resolutions

Scoring principles

  • Visual feature extraction: Uses advanced visual models to extract image features
  • Aesthetic modeling: Scoring model trained on large-scale aesthetic datasets
  • Multidimensional evaluation: Considers multiple aesthetic elements including color, composition, and contrast
  • Perceptual alignment: Scoring results are highly consistent with human aesthetic perception

Daft invocation

Operator parameters

Input

Input column name

Note

image_inputs

Array containing input images

Output

Floating-point array containing aesthetic scores, score range 0.0–1.0,
Images that cannot be decoded or fail to process return a null value

Parameters

If a parameter does not have a default value, it is required

Parameter name

Type

Default value

Description

batch_size

int

32

Batch size, controls the number of images processed per inference. Default value: 32

model_path

str

/data00/tiger/las/models

Model file storage path. Default value: '/data00/tiger/las/models'

clip_model_name

str

openai/clip-vit-large-patch14

CLIP visual model name. Default value: 'openai/clip-vit-large-patch14'

mlp_model_name

str

laion_aesthetic_v2/sac+logos+ava1-l14-linearMSE.pth

MLP scoring model name. Default value: 'laion_aesthetic_v2/sac+logos+ava1-l14-linearMSE.pth'

device

str

cpu

Device type, supports CPU and GPU devices. Default value: "cpu". Optional values: "cpu", "cuda", "cuda:0", "cuda:1", and so on

Examples

The following code demonstrates how to use Daft (for distributed environments) to run the operator and score the aesthetic quality of images.

from __future__ import annotations

import os

import daft
from daft import col
from daft.las.functions.image import ImageAestheticScore
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", "./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/archive/image_aesthetic_score/forest.jpg"],
    }
    ds = daft.from_pydict(samples)

    # Using Daft to calculate aesthetic scores for images
    constructor_kwargs = {
        "model_path": model_path,
        "image_src_type": "image_url",
        "batch_size": 1,
    }

    ds = ds.with_column(
        "aesthetic_score",
        las_udf(
            ImageAestheticScore,
            construct_args=constructor_kwargs,
            num_cpus=1,
            concurrency=1,
            batch_size=1,
        )(col("input_path")),
    )

    ds.show()
    # ╭────────────────────────────────┬────────────────────╮
    # │ input_path                     ┆ aesthetic_score    │
    # │ ---                            ┆ ---                │
    # │ Utf8                           ┆ Float64            │
    # ╞════════════════════════════════╪════════════════════╡
    # │ https://las-public-data-qa.to… ┆ 0.5603389739990234 │
    # ╰────────────────────────────────┴────────────────────╯
Last updated: 2026.05.12 19:06:36