mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-03-30 05:23:37 +08:00
Fix: properly handle batched tensors to prevent data loss
This commit is contained in:
parent
2a141d9927
commit
3e4586ede7
@ -168,10 +168,15 @@ def save_images_to_folder(image_list, output_dir, prefix="image"):
|
||||
saved_files = []
|
||||
|
||||
if isinstance(image_list, torch.Tensor):
|
||||
if image_list.dim() == 4:
|
||||
image_list = [image_list[i] for i in range(image_list.shape[0])]
|
||||
image_list = [image_list]
|
||||
|
||||
normalized_images = []
|
||||
for img in image_list:
|
||||
if isinstance(img, torch.Tensor) and img.dim() == 4:
|
||||
normalized_images.extend([img[i] for i in range(img.shape[0])])
|
||||
else:
|
||||
image_list = [image_list]
|
||||
normalized_images.append(img)
|
||||
image_list = normalized_images
|
||||
|
||||
for idx, img_tensor in enumerate(image_list):
|
||||
# Handle different tensor shapes
|
||||
|
||||
Loading…
Reference in New Issue
Block a user