Save preview to temp dir like PreviewImage for proper ui.images
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
from PIL import Image
|
from PIL import Image
|
||||||
import folder_paths
|
import folder_paths
|
||||||
import os
|
import os
|
||||||
|
import random
|
||||||
import torch
|
import torch
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
@@ -164,7 +165,20 @@ class CompassImageLoader:
|
|||||||
tensors[0] if len(tensors) == 1 else torch.cat(tensors, dim=0)
|
tensors[0] if len(tensors) == 1 else torch.cat(tensors, dim=0)
|
||||||
)
|
)
|
||||||
|
|
||||||
return {"ui": {"images": [{"filename": os.path.basename(output_path), "subfolder": "", "type": "input"}]}, "result": (image_batch, output_path, resolved_direction, final_w, final_h, len(selected_files))}
|
temp_dir = folder_paths.get_temp_directory()
|
||||||
|
prefix = "_compass_" + "".join(random.choice("abcdefghijklmnopqrstupvxyz") for _ in range(5))
|
||||||
|
results = []
|
||||||
|
for batch_number, img_tensor in enumerate(image_batch):
|
||||||
|
i = 255.0 * img_tensor.cpu().numpy()
|
||||||
|
pil_img = Image.fromarray(np.clip(i, 0, 255).astype(np.uint8))
|
||||||
|
file = f"{prefix}_{batch_number:05}_.png"
|
||||||
|
pil_img.save(os.path.join(temp_dir, file), compress_level=1)
|
||||||
|
results.append({"filename": file, "subfolder": "", "type": "temp"})
|
||||||
|
|
||||||
|
return {
|
||||||
|
"ui": {"images": results},
|
||||||
|
"result": (image_batch, output_path, resolved_direction, final_w, final_h, len(selected_files)),
|
||||||
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def IS_CHANGED(
|
def IS_CHANGED(
|
||||||
|
|||||||
Reference in New Issue
Block a user