Skip to content

Commit 9ed594f

Browse files
committed
image_processor: use bilinear+antialias interpolation for tensor/numpy resize
1 parent 7ca74e4 commit 9ed594f

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/diffusers/image_processor.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
from .configuration_utils import ConfigMixin, register_to_config
2525
from .utils import CONFIG_NAME, PIL_INTERPOLATION, deprecate
26+
from .utils.pil_utils import TORCH_INTERPOLATION
2627

2728

2829
PipelineImageInput = (
@@ -506,15 +507,21 @@ def resize(
506507
raise ValueError(f"resize_mode {resize_mode} is not supported")
507508

508509
elif isinstance(image, torch.Tensor):
510+
torch_mode, use_antialias = TORCH_INTERPOLATION[self.config.resample]
509511
image = torch.nn.functional.interpolate(
510512
image,
511513
size=(height, width),
514+
mode=torch_mode,
515+
antialias=use_antialias,
512516
)
513517
elif isinstance(image, np.ndarray):
518+
torch_mode, use_antialias = TORCH_INTERPOLATION[self.config.resample]
514519
image = self.numpy_to_pt(image)
515520
image = torch.nn.functional.interpolate(
516521
image,
517522
size=(height, width),
523+
mode=torch_mode,
524+
antialias=use_antialias,
518525
)
519526
image = self.pt_to_numpy(image)
520527

0 commit comments

Comments
 (0)