Skip to content

Commit a11f68d

Browse files
Fix canny node not working with fp16. (Comfy-Org#13085)
1 parent dc719cd commit a11f68d

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

comfy_extras/nodes_canny.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import comfy.model_management
55
from comfy_api.latest import ComfyExtension, io
6+
import torch
67

78

89
class Canny(io.ComfyNode):
@@ -29,8 +30,8 @@ def detect_edge(cls, image, low_threshold, high_threshold):
2930

3031
@classmethod
3132
def execute(cls, image, low_threshold, high_threshold) -> io.NodeOutput:
32-
output = canny(image.to(comfy.model_management.get_torch_device()).movedim(-1, 1), low_threshold, high_threshold)
33-
img_out = output[1].to(comfy.model_management.intermediate_device()).repeat(1, 3, 1, 1).movedim(1, -1)
33+
output = canny(image.to(device=comfy.model_management.get_torch_device(), dtype=torch.float32).movedim(-1, 1), low_threshold, high_threshold)
34+
img_out = output[1].to(device=comfy.model_management.intermediate_device(), dtype=comfy.model_management.intermediate_dtype()).repeat(1, 3, 1, 1).movedim(1, -1)
3435
return io.NodeOutput(img_out)
3536

3637

0 commit comments

Comments
 (0)