Skip to content

Commit

Permalink
Speed up Sharpen node.
Browse files Browse the repository at this point in the history
  • Loading branch information
comfyanonymous committed Apr 21, 2024
1 parent 644a3ae commit 4ee9aad
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion comfy_extras/nodes_post_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ def sharpen(self, image: torch.Tensor, sharpen_radius: int, sigma:float, alpha:
return (image,)

batch_size, height, width, channels = image.shape
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 @@ -241,7 +242,7 @@ def sharpen(self, image: torch.Tensor, sharpen_radius: int, sigma:float, alpha:

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

return (result,)
return (result.to(comfy.model_management.intermediate_device()),)

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

0 comments on commit 4ee9aad

Please sign in to comment.