Skip to content

Commit 764d7aa

Browse files
committed
Add SeedVR2 node and sampler coverage
1 parent ab4153a commit 764d7aa

11 files changed

Lines changed: 2774 additions & 0 deletions
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import ast
2+
import inspect
3+
import textwrap
4+
5+
import torch
6+
7+
from comfy.cli_args import args as cli_args
8+
9+
if not torch.cuda.is_available():
10+
cli_args.cpu = True
11+
12+
from comfy_extras import nodes_seedvr # noqa: E402
13+
14+
15+
def _schema_ids(items):
16+
return [item.id for item in items]
17+
18+
19+
def test_resize_schemas_are_preprocess_only():
20+
simple = nodes_seedvr.SeedVR2Resize.define_schema()
21+
advanced = nodes_seedvr.SeedVR2ResizeAdvanced.define_schema()
22+
23+
assert _schema_ids(simple.inputs) == ["images", "multiplier"]
24+
assert _schema_ids(simple.outputs) == ["input_pixels", "original_image", "upscaled_shorter_edge"]
25+
assert simple.outputs[0].get_io_type() == "IMAGE"
26+
27+
assert _schema_ids(advanced.inputs) == ["images", "shorter_edge"]
28+
assert _schema_ids(advanced.outputs) == ["input_pixels", "original_image", "upscaled_shorter_edge"]
29+
assert advanced.outputs[0].get_io_type() == "IMAGE"
30+
31+
32+
def test_resize_nodes_do_not_call_encode_decode_or_color_transfer():
33+
source = "\n".join(
34+
[
35+
inspect.getsource(nodes_seedvr.SeedVR2Resize.execute),
36+
inspect.getsource(nodes_seedvr.SeedVR2ResizeAdvanced.execute),
37+
]
38+
)
39+
tree = ast.parse(textwrap.dedent(source))
40+
forbidden_names = {
41+
"encode",
42+
"encode_tiled",
43+
"decode",
44+
"decode_tiled",
45+
"tiled_vae",
46+
"lab_color_transfer",
47+
}
48+
49+
for node in ast.walk(tree):
50+
if isinstance(node, ast.Call):
51+
func = node.func
52+
if isinstance(func, ast.Name):
53+
name = func.id
54+
elif isinstance(func, ast.Attribute):
55+
name = func.attr
56+
else:
57+
continue
58+
assert name not in forbidden_names

0 commit comments

Comments
 (0)