mirror of
https://git.datalinker.icu/kijai/ComfyUI-KJNodes.git
synced 2025-12-18 09:14:33 +08:00
Merge pull request #375 from asaf92/fix-image-pad-outpaint-mask-scaling
Fix ImagePadForOutpaintTargetSize mask scaling bug
This commit is contained in:
commit
af20cb3333
@ -1128,16 +1128,17 @@ class ImagePadForOutpaintTargetSize:
|
|||||||
|
|
||||||
# Downscale the image
|
# Downscale the image
|
||||||
image_scaled = common_upscale(image, new_width, new_height, upscale_method, "disabled").movedim(1,-1)
|
image_scaled = common_upscale(image, new_width, new_height, upscale_method, "disabled").movedim(1,-1)
|
||||||
|
else:
|
||||||
|
# If downscaling is not needed, use the original image dimensions
|
||||||
|
image_scaled = image
|
||||||
|
|
||||||
|
# Ensure mask dimensions match image dimensions
|
||||||
if mask is not None:
|
if mask is not None:
|
||||||
mask_scaled = mask.unsqueeze(0) # Add an extra dimension for batch size
|
mask_scaled = mask.unsqueeze(0) # Add an extra dimension for batch size
|
||||||
mask_scaled = F.interpolate(mask_scaled, size=(new_height, new_width), mode="nearest")
|
mask_scaled = F.interpolate(mask_scaled, size=(new_height, new_width), mode="nearest")
|
||||||
mask_scaled = mask_scaled.squeeze(0) # Remove the extra dimension after interpolation
|
mask_scaled = mask_scaled.squeeze(0) # Remove the extra dimension after interpolation
|
||||||
else:
|
else:
|
||||||
mask_scaled = mask
|
mask_scaled = None
|
||||||
else:
|
|
||||||
# If downscaling is not needed, use the original image dimensions
|
|
||||||
image_scaled = image
|
|
||||||
mask_scaled = mask
|
|
||||||
|
|
||||||
# Calculate how much padding is needed to reach the target dimensions
|
# Calculate how much padding is needed to reach the target dimensions
|
||||||
pad_top = max(0, (target_height - new_height) // 2)
|
pad_top = max(0, (target_height - new_height) // 2)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user