From ad21dc703835d3a853cd885ba185e96e0b4441b9 Mon Sep 17 00:00:00 2001 From: comfyanonymous Date: Mon, 14 Aug 2023 21:08:45 -0400 Subject: [PATCH] Make Blur node use the image device for processing. --- README.md | 3 ++- comfy.lnk | Bin 0 -> 882 bytes comfy_extras/nodes_post_processing.py | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 comfy.lnk diff --git a/README.md b/README.md index b055325ed..c69350a9f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -ComfyUI + +pComfyUI ======= A powerful and modular stable diffusion GUI and backend. ----------- diff --git a/comfy.lnk b/comfy.lnk new file mode 100644 index 0000000000000000000000000000000000000000..65b3f8206192366a0936882725ca3e6ade762781 GIT binary patch literal 882 zcmeZaU|?VrVFHp23im?i085=?~n6>ZuSB7AQ5{5*EB!(P@R0ds! z6oyQOG$1TxC^n+~$w0Gmf#y~Mg++ka1BhjS800Dttqa5;;10xsKnybHpr?leC>R-l-VZKG zOv*{sP0374D=p5<&x?UL0;pe)ApxiasD42NNG%YQB<5u%LzrN)VZYOrpJAUodKljH zX?)0?@y|)L^pMp%!B(*ukySg-3KNp=20D@xXnrKnG{fM4;I{^QZ#gq`x-b86L3l}V znvyM0JOyNvJP?ZkF`*z;V9;Q2X0T$=1Ze_-9v}u8Z17Qa`+IjOfu$dr5_;ynULy+> z=K?7J84QX$Kzxu69w2rD#v&+Y6@X!%4`ihP*+oEc zkZwL82J42WOCUcHh(T^ymX)kwJN1&_)@uw0{BKHJa0QCX0WsKQDIg82lMSkwO9S7e$U>%Svf%qBn|@r DuRONA literal 0 HcmV?d00001 diff --git a/comfy_extras/nodes_post_processing.py b/comfy_extras/nodes_post_processing.py index 3be141dfe..a138b292e 100644 --- a/comfy_extras/nodes_post_processing.py +++ b/comfy_extras/nodes_post_processing.py @@ -59,8 +59,8 @@ class Blend: def g(self, x): return torch.where(x <= 0.25, ((16 * x - 12) * x + 4) * x, torch.sqrt(x)) -def gaussian_kernel(kernel_size: int, sigma: float): - x, y = torch.meshgrid(torch.linspace(-1, 1, kernel_size), torch.linspace(-1, 1, kernel_size), indexing="ij") +def gaussian_kernel(kernel_size: int, sigma: float, device=None): + x, y = torch.meshgrid(torch.linspace(-1, 1, kernel_size, device=device), torch.linspace(-1, 1, kernel_size, device=device), indexing="ij") d = torch.sqrt(x * x + y * y) g = torch.exp(-(d * d) / (2.0 * sigma * sigma)) return g / g.sum() @@ -101,7 +101,7 @@ class Blur: batch_size, height, width, channels = image.shape kernel_size = blur_radius * 2 + 1 - kernel = gaussian_kernel(kernel_size, sigma).repeat(channels, 1, 1).unsqueeze(1) + kernel = gaussian_kernel(kernel_size, sigma, device=image.device).repeat(channels, 1, 1).unsqueeze(1) image = image.permute(0, 3, 1, 2) # Torch wants (B, C, H, W) we use (B, H, W, C) padded_image = F.pad(image, (blur_radius,blur_radius,blur_radius,blur_radius), 'reflect')