Ctrl+K
Logo image Logo image

Site Navigation

  • API Reference
  • Examples

Site Navigation

  • API Reference
  • Examples

Section Navigation

  • PyFlink Table
  • PyFlink DataFrame
  • PyFlink Multimodal
    • Image
    • Video
    • Utilities
  • PyFlink DataStream
  • PyFlink Common

pyflink.multimodal.operators.image_aesthetic_score#

image_aesthetic_score(*columns, hf_scorer_model='shunk031/aesthetics-predictor-v2-sac-logos-ava1-l14-linearMSE', model_sharing=None, concurrency=None, batch_size=None, num_gpus=None, gpu_type=None)[source]#

Create an aesthetic quality scoring UDF (HuggingFace aesthetics predictor-based).

Requires pip install transformers torch. This is a pandas batch UDF that supports GPU acceleration via num_gpus / gpu_type. Set num_gpus to request GPU resources from the DataFrame UDF runtime.

The default scorer is a regression head, not a probability model. Its score is divided by 10 and clamped to [0, 1] because the default LAION aesthetic predictor is trained on AVA/SAC-style 1-10 targets. Custom scorer outputs are expected to already use a [0, 1] scale and are clamped defensively. Custom model IDs must provide local safetensors head weights matching the built-in head architecture projection_dim -> 1024 -> 128 -> 64 -> 16 -> 1; only the built-in default model may fall back to trust_remote_code=True when those weights are unavailable.

Parameters
  • *columns – Optional image column(s). When provided, the UDF is applied directly instead of returning a factory.

  • hf_scorer_model – HuggingFace model ID for aesthetic scoring. Default "shunk031/aesthetics-predictor-v2-sac-logos-ava1-l14-linearMSE".

  • model_sharing – Model sharing mode across parallel subtasks. None uses per-process caching.

  • concurrency – UDF concurrency. None uses the framework default.

  • batch_size – Pandas batch size. None uses the framework default.

  • num_gpus – Fractional GPU count per subtask, e.g. 0.5. None runs on CPU.

  • gpu_type – Required GPU type, e.g. "A10". None accepts any available GPU.

Returns

A UDF that returns a normalized float aesthetic quality score in [0, 1] or None for null inputs.

Example::
>>> # As a reusable variable
>>> aesthetic = image_aesthetic_score()
>>> df = df.with_column("aesthetic", aesthetic(col("img")))
>>> aesthetic_gpu = image_aesthetic_score(num_gpus=1.0)
>>> df = df.with_column("aesthetic", aesthetic_gpu(col("img")))
>>>
>>> # Inline
>>> df = df.with_column("aesthetic", image_aesthetic_score(col("img")))

previous

pyflink.multimodal.operators.image_nsfw_score

next

pyflink.multimodal.operators.image_quality_score

Show Source

Created using Sphinx 4.5.0.