Download comfy_extras/nodes_canny.py from fotographerai/Zen-Style-Shape: direct link, hf CLI and curl.
- Browser
- Download file 910 Bytes
-
https://huggingface.co/spaces/fotographerai/Zen-Style-Shape/resolve/a8e42f9c629cb3adc0232d23fc09d1e375af4f5b/comfy_extras/nodes_canny.py
- Command line
-
hf download hf://spaces/fotographerai/Zen-Style-Shape@a8e42f9c629cb3adc0232d23fc09d1e375af4f5b/comfy_extras/nodes_canny.py
-
curl -L -o nodes_canny.py https://huggingface.co/spaces/fotographerai/Zen-Style-Shape/resolve/a8e42f9c629cb3adc0232d23fc09d1e375af4f5b/comfy_extras/nodes_canny.py
910 Bytes
| from kornia.filters import canny | |
| import comfy.model_management | |
| class Canny: | |
| def INPUT_TYPES(s): | |
| return {"required": {"image": ("IMAGE",), | |
| "low_threshold": ("FLOAT", {"default": 0.4, "min": 0.01, "max": 0.99, "step": 0.01}), | |
| "high_threshold": ("FLOAT", {"default": 0.8, "min": 0.01, "max": 0.99, "step": 0.01}) | |
| }} | |
| RETURN_TYPES = ("IMAGE",) | |
| FUNCTION = "detect_edge" | |
| CATEGORY = "image/preprocessors" | |
| def detect_edge(self, image, low_threshold, high_threshold): | |
| output = canny(image.to(comfy.model_management.get_torch_device()).movedim(-1, 1), low_threshold, high_threshold) | |
| img_out = output[1].to(comfy.model_management.intermediate_device()).repeat(1, 3, 1, 1).movedim(1, -1) | |
| return (img_out,) | |
| NODE_CLASS_MAPPINGS = { | |
| "Canny": Canny, | |
| } | |