mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-05-11 20:47:14 +08:00
Compare commits
2 Commits
v0.18.0
...
austin/bra
| Author | SHA1 | Date | |
|---|---|---|---|
| 3fbf3b421f | |||
| a11f68dd3b |
@ -3,6 +3,7 @@ from typing_extensions import override
|
||||
|
||||
import comfy.model_management
|
||||
from comfy_api.latest import ComfyExtension, io
|
||||
import torch
|
||||
|
||||
|
||||
class Canny(io.ComfyNode):
|
||||
@ -29,8 +30,8 @@ class Canny(io.ComfyNode):
|
||||
|
||||
@classmethod
|
||||
def execute(cls, image, low_threshold, high_threshold) -> io.NodeOutput:
|
||||
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)
|
||||
output = canny(image.to(device=comfy.model_management.get_torch_device(), dtype=torch.float32).movedim(-1, 1), low_threshold, high_threshold)
|
||||
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)
|
||||
return io.NodeOutput(img_out)
|
||||
|
||||
|
||||
|
||||
@ -8,6 +8,36 @@ from comfy_api.latest import _io
|
||||
MISSING = object()
|
||||
|
||||
|
||||
class BranchNode(io.ComfyNode):
|
||||
@classmethod
|
||||
def define_schema(cls):
|
||||
mtemplate = io.MatchType.Template("switch")
|
||||
minput = io.MatchType.Input("branch", template=mtemplate, lazy=True, optional=True)
|
||||
template = _io.Autogrow.TemplatePrefix(input=minput, prefix="branch", min=1, max=10)
|
||||
return io.Schema(
|
||||
node_id="BranchNode",
|
||||
display_name="Branch",
|
||||
category="logic",
|
||||
is_experimental=True,
|
||||
inputs=[
|
||||
io.Int.Input("branch"),
|
||||
_io.Autogrow.Input("autogrow", template=template)
|
||||
],
|
||||
outputs=[
|
||||
io.MatchType.Output(template=mtemplate, display_name="output"),
|
||||
],
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def check_lazy_status(cls, branch, autogrow):
|
||||
print('lazy', branch)
|
||||
return ['autogrow.' + list(autogrow.keys())[branch]]
|
||||
|
||||
@classmethod
|
||||
def execute(cls, branch, autogrow) -> io.NodeOutput:
|
||||
print(branch)
|
||||
return list(autogrow.values())[branch],
|
||||
|
||||
class SwitchNode(io.ComfyNode):
|
||||
@classmethod
|
||||
def define_schema(cls):
|
||||
@ -268,6 +298,7 @@ class LogicExtension(ComfyExtension):
|
||||
# AutogrowPrefixTestNode,
|
||||
# ComboOutputTestNode,
|
||||
# InvertBooleanNode,
|
||||
BranchNode,
|
||||
]
|
||||
|
||||
async def comfy_entrypoint() -> LogicExtension:
|
||||
|
||||
Reference in New Issue
Block a user