Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid ImageSharpen node bug on macOS #3392

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions comfy_extras/nodes_post_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,13 @@ def INPUT_TYPES(s):

CATEGORY = "image/postprocessing"

def sharpen(self, image: torch.Tensor, sharpen_radius: int, sigma:float, alpha: float):
def sharpen(self, image: torch.Tensor, sharpen_radius: int, sigma: float, alpha: float):
if sharpen_radius == 0:
return (image,)

batch_size, height, width, channels = image.shape
image = image.to(comfy.model_management.get_torch_device())
if not comfy.model_management.mps_mode():
image = image.to(comfy.model_management.get_torch_device())

kernel_size = sharpen_radius * 2 + 1
kernel = gaussian_kernel(kernel_size, sigma, device=image.device) * -(alpha*10)
Expand All @@ -242,7 +243,7 @@ def sharpen(self, image: torch.Tensor, sharpen_radius: int, sigma:float, alpha:

result = torch.clamp(sharpened, 0, 1)

return (result.to(comfy.model_management.intermediate_device()),)
return (result,) if comfy.model_management.mps_mode() else (result.to(comfy.model_management.intermediate_device()),)
bigcat88 marked this conversation as resolved.
Show resolved Hide resolved

class ImageScaleToTotalPixels:
upscale_methods = ["nearest-exact", "bilinear", "area", "bicubic", "lanczos"]
Expand Down