Skip to content

Commit b1111c2

Browse files
authored
convert nodes_mochi.py to V3 schema (#10069)
1 parent 05a258e commit b1111c2

File tree

1 file changed

+33
-16
lines changed

1 file changed

+33
-16
lines changed

comfy_extras/nodes_mochi.py

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,40 @@
1-
import nodes
1+
from typing_extensions import override
22
import torch
33
import comfy.model_management
4+
import nodes
5+
from comfy_api.latest import ComfyExtension, io
46

5-
class EmptyMochiLatentVideo:
6-
@classmethod
7-
def INPUT_TYPES(s):
8-
return {"required": { "width": ("INT", {"default": 848, "min": 16, "max": nodes.MAX_RESOLUTION, "step": 16}),
9-
"height": ("INT", {"default": 480, "min": 16, "max": nodes.MAX_RESOLUTION, "step": 16}),
10-
"length": ("INT", {"default": 25, "min": 7, "max": nodes.MAX_RESOLUTION, "step": 6}),
11-
"batch_size": ("INT", {"default": 1, "min": 1, "max": 4096})}}
12-
RETURN_TYPES = ("LATENT",)
13-
FUNCTION = "generate"
147

15-
CATEGORY = "latent/video"
8+
class EmptyMochiLatentVideo(io.ComfyNode):
9+
@classmethod
10+
def define_schema(cls):
11+
return io.Schema(
12+
node_id="EmptyMochiLatentVideo",
13+
category="latent/video",
14+
inputs=[
15+
io.Int.Input("width", default=848, min=16, max=nodes.MAX_RESOLUTION, step=16),
16+
io.Int.Input("height", default=480, min=16, max=nodes.MAX_RESOLUTION, step=16),
17+
io.Int.Input("length", default=25, min=7, max=nodes.MAX_RESOLUTION, step=6),
18+
io.Int.Input("batch_size", default=1, min=1, max=4096),
19+
],
20+
outputs=[
21+
io.Latent.Output(),
22+
],
23+
)
1624

17-
def generate(self, width, height, length, batch_size=1):
25+
@classmethod
26+
def execute(cls, width, height, length, batch_size=1) -> io.NodeOutput:
1827
latent = torch.zeros([batch_size, 12, ((length - 1) // 6) + 1, height // 8, width // 8], device=comfy.model_management.intermediate_device())
19-
return ({"samples":latent}, )
28+
return io.NodeOutput({"samples": latent})
29+
30+
31+
class MochiExtension(ComfyExtension):
32+
@override
33+
async def get_node_list(self) -> list[type[io.ComfyNode]]:
34+
return [
35+
EmptyMochiLatentVideo,
36+
]
37+
2038

21-
NODE_CLASS_MAPPINGS = {
22-
"EmptyMochiLatentVideo": EmptyMochiLatentVideo,
23-
}
39+
async def comfy_entrypoint() -> MochiExtension:
40+
return MochiExtension()

0 commit comments

Comments
 (0)