Custom ksampler
#7650
Replies: 2 comments 1 reply
-
Also my utility functions def tensor2pil(image):
# Check if image has a specific shape pattern (like noise_mask)
if len(image.shape) == 3 and image.shape[0] == 1 and image.shape[1] == 1:
# Handle noise mask case (1, 1, width) shape
return PIL.Image.fromarray(np.clip(255. * image.cpu().numpy().squeeze(), 0, 255).astype(np.uint8))
# Check dimensions and handle accordingly
if len(image.shape) == 4:
# Handle batched images (B, C, H, W)
image = image.squeeze(0) # Remove batch dimension
# Convert tensor to numpy array, scale and convert to uint8
img_np = np.clip(255. * image.cpu().numpy().squeeze(), 0, 255).astype(np.uint8)
# If the result is a 3D array with first dimension of size 3 or 4, it's likely in CHW format
if len(img_np.shape) == 3 and img_np.shape[0] in [3, 4]:
# Convert from CHW to HWC format
img_np = np.transpose(img_np, (1, 2, 0))
return PIL.Image.fromarray(img_np)
def pil2tensor(image):
return torch.from_numpy(np.array(image).astype(np.float32) / 255.0).unsqueeze(0) |
Beta Was this translation helpful? Give feedback.
0 replies
-
Although you inherited from KSampler, you are not using KSampler's function, but instead using a completely different function called |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When i run this custom node ksampler finishes job in like 10 minutes etc. how can i fix that why it took soo long. im using Ksampler's default sample function. When i use normal ksampler for example text to image promt its fast but when i use ksampler class to generaete custom pipeline i got this slowness. Slowness sometimes took like 30 mins etc.
Beta Was this translation helpful? Give feedback.
All reactions