BlenderNeko / ComfyUI_TiledKSampler

Tiled samplers for ComfyUI
GNU General Public License v3.0
327 stars 18 forks source link

`KeyError: 1` with Area Mask conditioning. #36

Open zixaphir opened 8 months ago

zixaphir commented 8 months ago

I'm attempting to do some very simple regional conditioning with a mask, but I keep getting the error message KeyError: 1 whenever I try to run my prompt. I've attempted it with ComfyUI's regular ksampler and the mask conditioning works, but with tileksampler, it fails:

ERROR:root:!!! Exception during processing !!!
ERROR:root:Traceback (most recent call last):
  File "/home/####/comfy/ComfyUI/execution.py", line 155, in recursive_execute
    output_data, output_ui = get_output_data(obj, input_data_all)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/####/comfy/ComfyUI/execution.py", line 85, in get_output_data
    return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/####/comfy/ComfyUI/execution.py", line 78, in map_node_over_list
    results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/####/comfy/ComfyUI/custom_nodes/ComfyUI_TiledKSampler/nodes.py", line 320, in sample
    return sample_common(model, 'enable', seed, tile_width, tile_height, tiling_strategy, steps_total, cfg, sampler_name, scheduler, positive, negative, latent_image, steps_total-steps, steps_total, 'disable', denoise=1.0, preview=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/####/comfy/ComfyUI/custom_nodes/ComfyUI_TiledKSampler/nodes.py", line 265, in sample_common
    pos = [slice_cond(tile_h, tile_h_len, tile_w, tile_w_len, c, area) for c, area in zip(pos, spatial_conds_pos)]
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/####/comfy/ComfyUI/custom_nodes/ComfyUI_TiledKSampler/nodes.py", line 265, in <listcomp>
    pos = [slice_cond(tile_h, tile_h_len, tile_w, tile_w_len, c, area) for c, area in zip(pos, spatial_conds_pos)]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/####/comfy/ComfyUI/custom_nodes/ComfyUI_TiledKSampler/nodes.py", line 55, in slice_cond
    cond[1]['mask'] = new_mask
    ~~~~^^^
KeyError: 1

I've attached the workflow's JSON file: KeyError1.json

OliverCrosby commented 7 months ago

I have this problem too. I added a debugger node to the output on the conditioning, so this is what I'm inputting into the tiled ksampler.

Value: [[tensor([[[-3.4022, -2.8713, 4.8880, ..., -0.4495, 0.0850, 0.8562], [ 0.3152, -0.8825, 0.3133, ..., -0.6830, -0.0950, 0.6463], [-0.2601, -0.9210, 1.6797, ..., -0.3502, 0.5530, 0.9467], ..., [-0.3216, -0.2523, 0.3768, ..., -0.3395, 0.3019, 1.6423], [-0.3220, -0.2638, 0.3738, ..., -0.3886, 0.2058, 1.6485], [-0.3398, -0.2678, 0.3758, ..., -0.2533, 0.3068, 1.7122]]]), {'pooled_output': tensor([[ 0.5536, 0.3358, 0.0723, ..., -1.0710, 0.7483, 2.6900]]), 'mask': tensor([[[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]]]), 'set_area_to_bounds': False, 'mask_strength': 1.0}]]

But I'm not sure what data structure the tiled ksampler node is expecting or what is wrong with my input.

Note: I don't get this error when I use the same conditioning input for pixel-based tiled upscalers.