Skip to content

Commit 91bf6b6

Browse files
Add node to create empty latents for qwen image layered model. (#11460)
1 parent 807538f commit 91bf6b6

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

comfy_extras/nodes_qwen.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
import math
44
from typing_extensions import override
55
from comfy_api.latest import ComfyExtension, io
6-
6+
import comfy.model_management
7+
import torch
8+
import nodes
79

810
class TextEncodeQwenImageEdit(io.ComfyNode):
911
@classmethod
@@ -104,12 +106,37 @@ def execute(cls, clip, prompt, vae=None, image1=None, image2=None, image3=None)
104106
return io.NodeOutput(conditioning)
105107

106108

109+
class EmptyQwenImageLayeredLatentImage(io.ComfyNode):
110+
@classmethod
111+
def define_schema(cls):
112+
return io.Schema(
113+
node_id="EmptyQwenImageLayeredLatentImage",
114+
display_name="Empty Qwen Image Layered Latent",
115+
category="latent/qwen",
116+
inputs=[
117+
io.Int.Input("width", default=640, min=16, max=nodes.MAX_RESOLUTION, step=16),
118+
io.Int.Input("height", default=640, min=16, max=nodes.MAX_RESOLUTION, step=16),
119+
io.Int.Input("layers", default=3, min=0, max=nodes.MAX_RESOLUTION, step=1),
120+
io.Int.Input("batch_size", default=1, min=1, max=4096),
121+
],
122+
outputs=[
123+
io.Latent.Output(),
124+
],
125+
)
126+
127+
@classmethod
128+
def execute(cls, width, height, layers, batch_size=1) -> io.NodeOutput:
129+
latent = torch.zeros([batch_size, 16, layers + 1, height // 8, width // 8], device=comfy.model_management.intermediate_device())
130+
return io.NodeOutput({"samples": latent})
131+
132+
107133
class QwenExtension(ComfyExtension):
108134
@override
109135
async def get_node_list(self) -> list[type[io.ComfyNode]]:
110136
return [
111137
TextEncodeQwenImageEdit,
112138
TextEncodeQwenImageEditPlus,
139+
EmptyQwenImageLayeredLatentImage,
113140
]
114141

115142

0 commit comments

Comments
 (0)