|
|
|
@ -1,9 +1,9 @@
|
|
|
|
|
import torch |
|
|
|
|
import torchvision |
|
|
|
|
import math |
|
|
|
|
import struct |
|
|
|
|
import comfy.checkpoint_pickle |
|
|
|
|
import safetensors.torch |
|
|
|
|
import numpy as np |
|
|
|
|
from PIL import Image |
|
|
|
|
|
|
|
|
|
def load_torch_file(ckpt, safe_load=False, device=None): |
|
|
|
@ -349,9 +349,9 @@ def bislerp(samples, width, height):
|
|
|
|
|
return result |
|
|
|
|
|
|
|
|
|
def lanczos(samples, width, height): |
|
|
|
|
images = [torchvision.transforms.functional.to_pil_image(image) for image in samples] |
|
|
|
|
images = [Image.fromarray(np.clip(255. * image.movedim(0, -1).cpu().numpy(), 0, 255).astype(np.uint8)) for image in samples] |
|
|
|
|
images = [image.resize((width, height), resample=Image.Resampling.LANCZOS) for image in images] |
|
|
|
|
images = [torchvision.transforms.functional.to_tensor(image) for image in images] |
|
|
|
|
images = [torch.from_numpy(np.array(image).astype(np.float32) / 255.0).movedim(-1, 0) for image in images] |
|
|
|
|
result = torch.stack(images) |
|
|
|
|
return result |
|
|
|
|
|
|
|
|
|