data_juicer.ops.filter.image_shape_filter module#
- class data_juicer.ops.filter.image_shape_filter.ImageShapeFilter(min_width: int = 1, max_width: int = 9223372036854775807, min_height: int = 1, max_height: int = 9223372036854775807, any_or_all: str = 'any', *args, **kwargs)[source]#
Bases:
FilterFilter to keep samples with image shape (w, h) within specific ranges.
- __init__(min_width: int = 1, max_width: int = 9223372036854775807, min_height: int = 1, max_height: int = 9223372036854775807, any_or_all: str = 'any', *args, **kwargs)[source]#
Initialization method.
- Parameters:
min_width โ The min width to keep samples.
max_width โ The max width to keep samples.
min_height โ The min height to keep samples.
max_height โ The max height to keep samples.
any_or_all โ keep this sample with โanyโ or โallโ strategy of all images. โanyโ: keep this sample if any images meet the condition. โallโ: keep this sample only if all images meet the condition.
args โ extra args
kwargs โ extra args
- compute_stats_single(sample, context=False)[source]#
Compute stats for the sample which is used as a metric to decide whether to filter this sample.
- Parameters:
sample โ input sample.
context โ whether to store context information of intermediate vars in the sample temporarily.
- Returns:
sample with computed stats