Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update core.py #632

Open
wants to merge 1 commit into
base: Main
Choose a base branch
from
Open

Update core.py #632

wants to merge 1 commit into from

Conversation

petercham
Copy link

@petercham petercham commented Jun 7, 2024

Optimize two bits of code and expect better performance, under the enhance_detail_for_animatediff function:

  1. for the noise_mask upscale process, use torch.stack instead of torch.cat;
  2. for the latent_frames process, use torch.cat instead of the displayed for loop.

Optimize two pieces of code, under the enhance_detail_for_animatediff function, use torch.stack instead of torch.cat for the upscale process of noise_mask, and use torch.cat instead of the displayed for loop for the latent_frames processing. For the latent_frames process, use torch.cat instead of the display for loop.
@ltdrdata
Copy link
Owner

ltdrdata commented Jun 7, 2024

!!! Exception during processing!!! too many indices for tensor of dimension 4
Traceback (most recent call last):
  File "/mnt/teratera/git/ComfyUI/execution.py", line 151, in recursive_execute
    output_data, output_ui = get_output_data(obj, input_data_all)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/teratera/git/ComfyUI/execution.py", line 81, in get_output_data
    return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/teratera/git/ComfyUI/custom_nodes/ComfyUI-0246/utils.py", line 381, in new_func
    res_value = old_func(*final_args, **kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/teratera/git/ComfyUI/execution.py", line 74, in map_node_over_list
    results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/teratera/git/ComfyUI/custom_nodes/ComfyUI-Impact-Pack/modules/impact/animatediff_nodes.py", line 109, in doit
    segs, cnet_images = SEGSDetailerForAnimateDiff.do_detail(image_frames, segs, guide_size, guide_size_for, max_size, seed, steps, cfg, sampler_name,
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/teratera/git/ComfyUI/custom_nodes/ComfyUI-Impact-Pack/modules/impact/animatediff_nodes.py", line 86, in do_detail
    enhanced_image_tensor, cnet_images = core.enhance_detail_for_animatediff(cropped_image_frames, model, clip, vae, guide_size, guide_size_for, max_size,
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/teratera/git/ComfyUI-Impact-Pack/modules/impact/core.py", line 427, in enhance_detail_for_animatediff
    latent_frames = torch.cat([to_latent_image(tensor_resize(torch.from_numpy(frame).unsqueeze(0), new_w, new_h)['samples']) for frame in image_frames], dim=0)
                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
IndexError: too many indices for tensor of dimension 4

Prompt executed in 32.71 seconds

You can reproduce above error from this workflow.
https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/workflow/detailer-for-animatediff.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants