[Bug] BerniniConditioning fails when receiving an image batch (Tensor) instead of a dictionary
- Dominant language
- Python
- Stars
- 133k
- Forks
- 15.7k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 158
Description
### Custom Node Testing
- [x] I have tried disabling custom nodes and the issue persists (see [how to disable custom nodes](https://docs.comfy.org/troubleshooting/custom-node-issues#step-1%3A-test-with-all-custom-nodes-disabled) if you need help)
### Expected Behavior
Describe the bug
The BerniniConditioning node in comfy_extras/nodes_bernini.py throws a RuntimeError when a batch of images (PyTorch Tensor) is connected to the reference_images input. This is because the code expects a dictionary (from individual autogrow pins) and uses a non-explicit boolean check.
Error Message
RuntimeError: Boolean value of Tensor with more than one value is ambiguous
Location
File: comfy_extras/nodes_bernini.py
Lines: 85 and 86
The Cause
Line 85: if reference_images: tries to evaluate the truthiness of a Tensor containing multiple images, which is not allowed in PyTorch.
Line 86: for name in sorted(reference_images): fails because a Tensor cannot be sorted like a dictionary of keys.
Suggested Fix
The logic should explicitly check for None and handle both dict and torch.Tensor types.
`code Python:`
if reference_images is not None:
if isinstance(reference_images, dict):
for name in sorted(reference_images.keys()):
img_slot = reference_images[name]
for i in range(img_slot.shape[0]):
img = _resize_long_edge(img_slot[i:i+1], ref_max_size)
context.append(vae.encode(img[:, :, :, :3]))
elif torch.is_tensor(reference_images):
for i in range(reference_images.shape[0]):
img = _resize_long_edge(reference_images[i:i+1], ref_max_size)
context.append(vae.encode(img[:, :, :, :3]))
### Actual Behavior
When an image batch (Tensor) is connected to the reference_images input of the BerniniConditioning node, the execution crashes immediately during the processing phase. The system fails to evaluate the truthiness of the tensor at line 85 and fails to sort it at line 86, preventing the workflow from generating any output.
### Steps to Reproduce
1. Add a BerniniConditioning node to the workspace.
2. Create an image batch containing 2 or more images (e.g., using a Batch Images node or loading a multi-frame image).
3. Connect this image batch Tensor to the reference_images input of the BerniniConditioning node.
4. Click "Queue Prompt".
5. The execution will crash immediately with the RuntimeError: "Boolean value of Tensor with more than one value is ambiguous".
### Debug Logs
```powershell
[STDERR] [ERROR] !!! Exception during processing !!! Boolean value of Tensor with more than one value is ambiguous
[STDERR] [09/02 15:12:41][ERROR] !!! Exception during processing !!! Boolean value of Tensor with more than one value is ambiguous
[STDERR] [ERROR] Traceback (most recent call last):
[STDERR] File "C:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\execution.py", line 545, in execute
[STDERR] 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, v3_data=v3_data)
[STDERR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[STDERR] File "C:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\execution.py", line 344, in get_output_data
[STDERR] 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, v3_data=v3_data)
[STDERR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[STDERR] File "C:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\execution.py", line 318, in async_map_node_over_list
[STDERR] await process_inputs(input_dict, i)
[STDERR] File "C:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\execution.py", line 306, in process_inputs
[STDERR] result = f(**inputs)
[STDERR] ^^^^^^^^^^^
[STDERR] File "C:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\comfy_api\internal_init.py", line 149, in wrapped_func
[STDERR] return method(locked_class, **inputs)
[STDERR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[STDERR] File "C:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\comfy_api\latest_io.py", line 1990, in EXECUTE_NORMALIZED
[STDERR] to_return = cls.execute(*args, **kwargs)
[STDERR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[STDERR] File "C:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\comfy_extras\nodes_bernini.py", line 85, in execute
[STDERR] if reference_images:
[STDERR] ^^^^^^^^^^^^^^^^
[STDERR] RuntimeError: Boolean value of Tensor with more than one value is ambiguous
[STDERR]
[STDERR] [09/02 15:12:41][ERROR] Traceback (most recent call last):
[STDERR] File "C:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\execution.py", line 545, in execute
[STDERR] 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, v3_data=v3_data)
[STDERR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[STDERR] File "C:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\execution.py", line 344, in get_output_data
[STDERR] 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, v3_data=v3_data)
[STDERR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[STDERR] File "C:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\execution.py", line 318, in async_map_node_over_list
[STDERR] await process_inputs(input_dict, i)
[STDERR] File "C:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\execution.py", line 306, in process_inputs
[STDERR] result = f(**inputs)
[STDERR] ^^^^^^^^^^^
[STDERR] File "C:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\comfy_api\internal_init.py", line 149, in wrapped_func
[STDERR] return method(locked_class, **inputs)
[STDERR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[STDERR] File "C:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\comfy_api\latest_io.py", line 1990, in EXECUTE_NORMALIZED
[STDERR] to_return = cls.execute(*args, **kwargs)
[STDERR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[STDERR] File "C:\ComfyUI_windows_portable_nvidia\ComfyUI_windows_portable\ComfyUI\comfy_extras\nodes_bernini.py", line 85, in execute
[STDERR] if reference_images:
[STDERR] ^^^^^^^^^^^^^^^^
[STDERR] RuntimeError: Boolean value of Tensor with more than one value is ambiguous
```
### Other
_No response_
Contributor guide
Research direction
Start in comfy_extras/nodes_bernini.py at lines 85-86 and reproduce the failure with a multi-image Tensor connected to BerniniConditioning.reference_images. Verify handling for both dictionary inputs and image-batch tensors, then confirm the workflow completes without the ambiguous-tensor error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 86/100