xpark.dataset.ImageWatermarkDetect#
- class xpark.dataset.ImageWatermarkDetect(_local_model: str = 'finetrainers/laion-watermark-detection')#
Image watermark detection processor for CPU, GPU.
Runs the watermark classifier over each input image and returns the predicted probability that the image contains a watermark, in
[0, 1]. Higher scores mean the image is more likely to be watermarked.- Parameters:
_local_model – The watermark detection model name for CPU or GPU. default is “finetrainers/laion-watermark-detection”. available models: [‘finetrainers/laion-watermark-detection’]
Examples
from xpark.dataset.expressions import col from xpark.dataset import ImageWatermarkDetect, from_items import numpy as np ds = from_items([ {"image": np.random.randint(0, 255, (256, 256, 3)).astype(np.uint8), "path": "test.jpg"} ]) ds = ds.with_column( "image_watermark_prob", ImageWatermarkDetect().options(num_workers={"CPU": 4}, batch_size=32).with_column(col("image")), ) print(ds.take(1))
Methods
__call__(images)Call self as a function.
options(**kwargs)with_column(images)- __call__(images: pa.ChunkedArray) pa.Array#
Call self as a function.
- options(**kwargs: Unpack[ExprUDFOptions]) Self#
- with_column(images: pa.ChunkedArray) pa.Array#