-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnode_qwen.py
More file actions
55 lines (49 loc) · 1.98 KB
/
Copy pathnode_qwen.py
File metadata and controls
55 lines (49 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from comfy_api.latest import io
from .helpers import Resolution, ResolutionsList
from .node_utilities import ResolutionParam
# https://github.com/QwenLM/Qwen-Image/issues/7#issuecomment-3153364093
training_resolutions = sorted(
[
Resolution(1328, 1328),
Resolution(1664, 928),
Resolution(928, 1664),
Resolution(1472, 1104),
Resolution(1104, 1472),
Resolution(1584, 1056),
Resolution(1056, 1584),
],
key=lambda res: res.total_pixels(),
reverse=True,
)
class QwenImageNativesResolutions(io.ComfyNode):
@classmethod
def define_schema(cls) -> io.Schema:
return io.Schema(
node_id="IG1QwenImageNativesResolutions",
display_name="Qwen Image Natives Resolutions",
category="IG1 Tools",
description=f"""This node outputs the list of resolutions that were used in the training of the Qwen Image model. These are the resolutions that are most likely to produce the best results.""",
inputs=[
io.Combo.Input(
"native_resolution",
options=[str(res)
for res in training_resolutions],
default=str(training_resolutions[0]),
tooltip="The model you want to compute advises for. This will be used to get the patch length, min lengths and max size.",
)
],
outputs=[
ResolutionParam.Output(
"resolution",
display_name="RESOLUTION",
),
],
)
@classmethod
def execute(cls, native_resolution) -> io.NodeOutput:
# Compute the flux first pass generation resolution
# and the adjusted (if necessary) reference resolution.
for res in training_resolutions:
if str(res) == native_resolution:
return io.NodeOutput(res)
raise ValueError(f"Unhandled resolution: {native_resolution}")