LarryJane491 / Image-Captioning-in-ComfyUI

Custom nodes for ComfyUI that let the user load a bunch of images and save them with captions (ideal to prepare a database for LORA training)
43 stars 12 forks source link

Error when running LoRA Caption Load node #16

Open robertvoy opened 2 weeks ago

robertvoy commented 2 weeks ago

`!!! Exception during processing !!! cannot access local variable 'image1' where it is not associated with a value Traceback (most recent call last): File "C:\Users\Robert\Downloads\ComfyUI_windows_portable\ComfyUI\execution.py", line 317, in execute output_data, output_ui, has_subgraph = get_output_data(obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Robert\Downloads\ComfyUI_windows_portable\ComfyUI\execution.py", line 192, in get_output_data return_values = _map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Robert\Downloads\ComfyUI_windows_portable\ComfyUI\execution.py", line 169, in _map_node_over_list process_inputs(input_dict, i) File "C:\Users\Robert\Downloads\ComfyUI_windows_portable\ComfyUI\execution.py", line 158, in process_inputs results.append(getattr(obj, func)(**inputs)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Robert\Downloads\ComfyUI_windows_portable\ComfyUI\custom_nodes\Image-Captioning-in-ComfyUI\LoRAcaption.py", line 148, in captionload return text, path, image1, len(images) ^^^^^^ UnboundLocalError: cannot access local variable 'image1' where it is not associated with a value

Prompt executed in 0.00 seconds`

nerdenough commented 2 weeks ago

Doesn't really look like this repo is actively worked on. There's an indentation error in the last line of LoRAcaption.py. Update the last section to the following and it works (the final return was not inside the elif where it should have been):

        if len(images) == 1:
            return (images[0], 1)
        elif len(images) > 1:
            image1 = images[0]
            for image2 in images[1:]:
                if image1.shape[1:] != image2.shape[1:]:
                    image2 = comfy.utils.common_upscale(image2.movedim(-1, 1), image1.shape[2], image1.shape[1], "bilinear", "center").movedim(1, -1)
                image1 = torch.cat((image1, image2), dim=0)
            return text, path, image1, len(images)

(You can just update the code of the extension in the ComfyUI/custom_nodes folder, restart Comfy UI, and it should work)