Fix image handling: Remove dependency on comfy.utils.to_uint8

- Replaced comfy.utils.to_uint8() with standard np.array() for better compatibility
- Added missing numpy import in preset_creator_node.py
- Functions now work with all ComfyUI versions
- Maintained same tensor format [1,H,W,C] for ComfyUI compatibility
- Tested and verified working correctly
This commit is contained in:
NewLouwa
2025-10-19 03:15:05 +02:00
parent a5be26f608
commit 07c495feee
2 changed files with 3 additions and 2 deletions
+1 -1
View File
@@ -236,7 +236,7 @@ def _get_preview_info(model_id: str) -> Dict[str, Any]:
def _pil_to_image_tensor(pil: Image.Image) -> torch.Tensor:
"""Convert PIL Image to ComfyUI tensor format [1,H,W,C]"""
img = pil.convert("RGB")
arr = comfy.utils.to_uint8(img) # numpy array uint8
arr = np.array(img) # numpy array uint8
t = torch.from_numpy(arr).float() / 255.0
return t.unsqueeze(0) # batch = 1
+2 -1
View File
@@ -10,6 +10,7 @@ from datetime import datetime
from typing import Any, Dict, Optional
import torch
import numpy as np
from PIL import Image
import comfy.utils
@@ -20,7 +21,7 @@ import folder_paths
def _pil_to_image_tensor(pil: Image.Image) -> torch.Tensor:
"""Convert PIL Image to ComfyUI tensor format [1,H,W,C]"""
img = pil.convert("RGB")
arr = comfy.utils.to_uint8(img) # numpy array uint8
arr = np.array(img) # numpy array uint8
t = torch.from_numpy(arr).float() / 255.0
return t.unsqueeze(0) # batch = 1