Skip to content

Commit 42f52a6

Browse files
committed
Always use default when a format widget is missing
1 parent 43ac76c commit 42f52a6

File tree

1 file changed

+11
-20
lines changed

1 file changed

+11
-20
lines changed

videohelpersuite/nodes.py

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -64,30 +64,22 @@ def get_video_formats():
6464
formats.append("video/" + format_name)
6565
return formats
6666

67-
def get_format_widget_defaults(format_name):
68-
video_format_path = folder_paths.get_full_path("VHS_video_formats", format_name + ".json")
69-
with open(video_format_path, 'r') as stream:
70-
video_format = json.load(stream)
71-
results = {}
72-
for w in gen_format_widgets(video_format):
73-
if len(w[0]) > 2 and 'default' in w[0][2]:
74-
default = w[0][2]['default']
75-
else:
76-
if type(w[0][1]) is list:
77-
default = w[0][1][0]
78-
else:
79-
#NOTE: This doesn't respect max/min, but should be good enough as a fallback to a fallback to a fallback
80-
default = {"BOOLEAN": False, "INT": 0, "FLOAT": 0, "STRING": ""}[w[0][1]]
81-
results[w[0][0]] = default
82-
return results
83-
84-
8567
def apply_format_widgets(format_name, kwargs):
8668
video_format_path = folder_paths.get_full_path("VHS_video_formats", format_name + ".json")
8769
with open(video_format_path, 'r') as stream:
8870
video_format = json.load(stream)
8971
for w in gen_format_widgets(video_format):
90-
assert(w[0][0] in kwargs)
72+
if w[0][0] not in kwargs:
73+
if len(w[0]) > 2 and 'default' in w[0][2]:
74+
default = w[0][2]['default']
75+
else:
76+
if type(w[0][1]) is list:
77+
default = w[0][1][0]
78+
else:
79+
#NOTE: This doesn't respect max/min, but should be good enough as a fallback to a fallback to a fallback
80+
default = {"BOOLEAN": False, "INT": 0, "FLOAT": 0, "STRING": ""}[w[0][1]]
81+
kwargs[w[0][0]] = default
82+
logger.warn(f"Missing input for {w[0][0]} has been set to {default}")
9183
if len(w[0]) > 3:
9284
w[0] = Template(w[0][3]).substitute(val=kwargs[w[0][0]])
9385
else:
@@ -395,7 +387,6 @@ def batched_encode(images, vae, frames_per_batch):
395387
else:
396388
manual_format_widgets = {}
397389
if kwargs is None:
398-
kwargs = get_format_widget_defaults(format_ext)
399390
missing = {}
400391
for k in kwargs.keys():
401392
if k in manual_format_widgets:

0 commit comments

Comments
 (0)