Image quality scoring
Functions for composite quality scoring, NSFW detection, aesthetic scoring, and watermark detection.
The functions in this topic are provided by the Python multimodal function library (VVR 11.8+). Load the module at the beginning of the SQL job before use:
LOAD MODULE python;
USE MODULES python, core;
For complete examples and the IMAGE type, see Image function overview.
Function summary
|
Function |
Description |
|
Compute a composite quality score |
|
|
Assess NSFW content risk |
|
|
Assess the aesthetic quality of an image |
|
|
Assess the risk of watermark presence in an image |
IMAGE_QUALITY_SCORE
Computes a composite quality score that combines sharpness, contrast, and color richness.
IMAGE_QUALITY_SCORE(image_input)
Input type: IMAGE
Return type: DOUBLE, in the range [0, 1]. Higher is better.
The score is a weighted combination of sharpness, contrast, and color richness, with weights 0.5, 0.3, and 0.2 respectively. This function returns a normalized composite quality score, which is not equivalent to the raw sharpness value returned by IMAGE_SHARPNESS.
SELECT * FROM images
WHERE IMAGE_QUALITY_SCORE(img) > 0.3;
IMAGE_NSFW_SCORE
Uses a HuggingFace image classifier to assess the risk of NSFW content.
IMAGE_NSFW_SCORE(image_input [, hf_nsfw_model])
|
Parameter |
Type |
Default |
Description |
|
image_input |
|
Required |
The decoded image. |
|
hf_nsfw_model |
|
|
HuggingFace NSFW classification model ID. Note
Only the default model is currently supported. |
Return type: DOUBLE, in the range [0, 1]. Higher values indicate higher NSFW risk.
SELECT * FROM images
WHERE IMAGE_NSFW_SCORE(img) < 0.5;
IMAGE_AESTHETIC_SCORE
Uses a HuggingFace aesthetic predictor to score the aesthetic quality of the image.
IMAGE_AESTHETIC_SCORE(image_input [, hf_scorer_model])
|
Parameter |
Type |
Default |
Description |
|
image_input |
|
Required |
The decoded image. |
|
hf_scorer_model |
|
|
HuggingFace aesthetic scoring model ID. Note
Only the default model is currently supported. |
Return type: DOUBLE, in the range [0, 1]. Higher values indicate higher aesthetic quality.
SELECT IMAGE_AESTHETIC_SCORE(img) FROM images;
IMAGE_WATERMARK_SCORE
Uses a HuggingFace image classifier to assess the risk that an image contains a watermark.
IMAGE_WATERMARK_SCORE(image_input [, hf_watermark_model])
|
Parameter |
Type |
Default |
Description |
|
image_input |
|
Required |
The decoded image. |
|
hf_watermark_model |
|
|
HuggingFace watermark detection model ID. Note
Only the default model is currently supported. |
Return type: DOUBLE, in the range [0, 1]. Higher values indicate a higher likelihood of a watermark.
SELECT * FROM images
WHERE IMAGE_WATERMARK_SCORE(img) < 0.8;