Skip to content

local variable 'H' referenced before assignment #390

@Garrettlynch

Description

@Garrettlynch
'🔥 - 11 Nodes not included in prompt but is activated'
CLIP/text encoder model load device: cuda:0, offload device: cpu, current: cpu, dtype: torch.float16
Requested to load SD3ClipModel_
loaded partially 1979.9816368103027 1965.693359375 0
loaded partially 3853.674996185303 3853.673828125 0
!!! Exception during processing !!! local variable 'H' referenced before assignment
Traceback (most recent call last):
  File "/home/garrett/AI/ComfyUI/execution.py", line 427, in execute
    output_data, output_ui, has_subgraph, has_pending_tasks = await get_output_data(prompt_id, unique_id, obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
  File "/home/garrett/AI/ComfyUI/execution.py", line 270, in get_output_data
    return_values = await _async_map_node_over_list(prompt_id, unique_id, obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
  File "/home/garrett/AI/ComfyUI/execution.py", line 244, in _async_map_node_over_list
    await process_inputs(input_dict, i)
  File "/home/garrett/AI/ComfyUI/execution.py", line 232, in process_inputs
    result = f(**inputs)
  File "/home/garrett/AI/ComfyUI/custom_nodes/comfyui-cogvideoxwrapper/nodes.py", line 662, in process
    height = H * 8
UnboundLocalError: local variable 'H' referenced before assignment

This issue is in "ComfyUI/custom_nodes/comfyui-cogvideoxwrapper/nodes.py". Changing:

if samples is not None:
    if len(samples["samples"].shape) == 5:
        B, T, C, H, W = samples["samples"].shape
        latents = samples["samples"]
    if len(samples["samples"].shape) == 4:
        B, C, H, W = samples["samples"].shape
        latents = None
if image_cond_latents is not None:
    B, T, C, H, W = image_cond_latents["samples"].shape
height = H * 8
width = W * 8

to:

if samples is not None:
    if len(samples["samples"].shape) == 5:
        B, T, C, H, W = samples["samples"].shape
        latents = samples["samples"]
    elif len(samples["samples"].shape) == 4: # change if to elif
        B, C, H, W = samples["samples"].shape
        latents = None
elif image_cond_latents is not None: # change if to elif
    B, T, C, H, W = image_cond_latents["samples"].shape
else: # add this else statement
    raise ValueError("Either 'samples' or 'image_cond_latents' must be provided to determine dimensions.")

height = H * 8
width = W * 8

resolves the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions