[data] use bicubic resampler (#7143)

Former-commit-id: bc298c60b7d3fdc4d116a79b535d7e9b11f4aa65
This commit is contained in:
hoshi-hiyouga 2025-03-04 00:17:06 +08:00 committed by GitHub
parent 392533e139
commit caef0a8937

View File

@ -125,12 +125,12 @@ class MMPluginMixin:
if (image.width * image.height) > image_max_pixels:
resize_factor = math.sqrt(image_max_pixels / (image.width * image.height))
width, height = int(image.width * resize_factor), int(image.height * resize_factor)
image = image.resize((width, height), resample=Image.Resampling.NEAREST)
image = image.resize((width, height))
if (image.width * image.height) < image_min_pixels:
resize_factor = math.sqrt(image_min_pixels / (image.width * image.height))
width, height = int(image.width * resize_factor), int(image.height * resize_factor)
image = image.resize((width, height), resample=Image.Resampling.NEAREST)
image = image.resize((width, height))
if image.mode != "RGB":
image = image.convert("RGB")