ssitu / ComfyUI_UltimateSDUpscale

ComfyUI nodes for the Ultimate Stable Diffusion Upscale script by Coyote-A.
GNU General Public License v3.0
857 stars 58 forks source link

Error running USDU with Flux using Anywhere Nodes #105

Open gonzalu opened 1 month ago

gonzalu commented 1 month ago

Not sure if the problem is the use of the Anywhere nodes, but I keep getting this error:

Requested to load FluxClipModel_
Loading 1 new model
loaded completely 0.0 9319.23095703125 True
Canva size: 2080x3040
Image size: 832x1216
Scale factor: 3
Upscaling iteration 1 with scale factor 3
Tile size: 1040x1012
Tiles amount: 8
Grid: 4x2
Redraw enabled: True
Seams fix mode: NONE
!!! Exception during processing !!! too many values to unpack (expected 2)
Traceback (most recent call last):
  File "E:\ComfyUI\ComfyUI\execution.py", line 323, 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 "E:\ComfyUI\ComfyUI\execution.py", line 198, 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 "E:\ComfyUI\ComfyUI\execution.py", line 169, in _map_node_over_list
    process_inputs(input_dict, i)
  File "E:\ComfyUI\ComfyUI\execution.py", line 158, in process_inputs
    results.append(getattr(obj, func)(**inputs))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\ComfyUI\ComfyUI\custom_nodes\ComfyUI_UltimateSDUpscale\nodes.py", line 151, in upscale
    processed = script.run(p=self.sdprocessing, _=None, tile_width=self.tile_width, tile_height=self.tile_height,
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\ComfyUI\ComfyUI\custom_nodes\ComfyUI_UltimateSDUpscale\repositories\ultimate_sd_upscale\scripts\ultimate-upscale.py", line 565, in run
    upscaler.process()
  File "E:\ComfyUI\ComfyUI\custom_nodes\ComfyUI_UltimateSDUpscale\repositories\ultimate_sd_upscale\scripts\ultimate-upscale.py", line 138, in process
    self.image = self.redraw.start(self.p, self.image, self.rows, self.cols)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\ComfyUI\ComfyUI\custom_nodes\ComfyUI_UltimateSDUpscale\repositories\ultimate_sd_upscale\scripts\ultimate-upscale.py", line 245, in start
    return self.linear_process(p, image, rows, cols)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\ComfyUI\ComfyUI\custom_nodes\ComfyUI_UltimateSDUpscale\repositories\ultimate_sd_upscale\scripts\ultimate-upscale.py", line 180, in linear_process
    processed = processing.process_images(p)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\ComfyUI\ComfyUI\custom_nodes\ComfyUI_UltimateSDUpscale\modules\processing.py", line 165, in process_images
    positive_cropped = crop_cond(p.positive, crop_region, p.init_size, init_image.size, tile_size)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\ComfyUI\ComfyUI\custom_nodes\ComfyUI_UltimateSDUpscale\utils.py", line 452, in crop_cond
    for emb, x in cond:
        ^^^^^^
ValueError: too many values to unpack (expected 2)
gonzalu commented 1 month ago

image

gonzalu commented 1 month ago

If I set the mode to type to NONE it works fine. Linear and Chess will not go through

ssitu commented 1 month ago

NONE just skips the resampling process, so it will just upscale using the upscale model. Does it work without anywhere nodes? It might just be an issue with your positive conditioning, which I don't see in the picture.

gonzalu commented 1 month ago

NONE just skips the resampling process, so it will just upscale using the upscale model. Does it work without anywhere nodes? It might just be an issue with your positive conditioning, which I don't see in the picture.

Hmmm... let me take a look.

gonzalu commented 1 month ago

So, I connected it up without Anywhere nodes... and still got error... :(

image

image

!!! Exception during processing !!! too many values to unpack (expected 2)
Traceback (most recent call last):
  File "E:\ComfyUI\ComfyUI\execution.py", line 323, 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 "E:\ComfyUI\ComfyUI\execution.py", line 198, 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 "E:\ComfyUI\ComfyUI\execution.py", line 169, in _map_node_over_list
    process_inputs(input_dict, i)
  File "E:\ComfyUI\ComfyUI\execution.py", line 158, in process_inputs
    results.append(getattr(obj, func)(**inputs))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\ComfyUI\ComfyUI\custom_nodes\ComfyUI_UltimateSDUpscale\nodes.py", line 151, in upscale
    processed = script.run(p=self.sdprocessing, _=None, tile_width=self.tile_width, tile_height=self.tile_height,
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\ComfyUI\ComfyUI\custom_nodes\ComfyUI_UltimateSDUpscale\repositories\ultimate_sd_upscale\scripts\ultimate-upscale.py", line 565, in run
    upscaler.process()
  File "E:\ComfyUI\ComfyUI\custom_nodes\ComfyUI_UltimateSDUpscale\repositories\ultimate_sd_upscale\scripts\ultimate-upscale.py", line 138, in process
    self.image = self.redraw.start(self.p, self.image, self.rows, self.cols)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\ComfyUI\ComfyUI\custom_nodes\ComfyUI_UltimateSDUpscale\repositories\ultimate_sd_upscale\scripts\ultimate-upscale.py", line 245, in start
    return self.linear_process(p, image, rows, cols)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\ComfyUI\ComfyUI\custom_nodes\ComfyUI_UltimateSDUpscale\repositories\ultimate_sd_upscale\scripts\ultimate-upscale.py", line 180, in linear_process
    processed = processing.process_images(p)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\ComfyUI\ComfyUI\custom_nodes\ComfyUI_UltimateSDUpscale\modules\processing.py", line 165, in process_images
    positive_cropped = crop_cond(p.positive, crop_region, p.init_size, init_image.size, tile_size)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\ComfyUI\ComfyUI\custom_nodes\ComfyUI_UltimateSDUpscale\utils.py", line 452, in crop_cond
    for emb, x in cond:
        ^^^^^^
ValueError: too many values to unpack (expected 2)
gonzalu commented 1 month ago

Just in case it matters, I am using the official Flux.1 Dev model file from BFL diffusers repo on huggingface, not schnell and not one of the other quantized versions floating around

ssitu commented 1 month ago

So it's a model issue? 1.5 models still seem to work, correct me if I'm wrong. I don't think I can run the new flux models with my 4 gb gpu, so this will be hard to fix.

gonzalu commented 1 month ago

So sorry... perhaps that's the problem.

No worries and thank you so much for your help and for a great tool. I have used it for many many upscales :D

Yes, I am using the full 23GB Flux model.

Is your node using the same transformer and tensor code from the core comfyui nodes? Maybe that's why if they are different?

Looking forward to when it works again.

Cheers and Thank you!

ssitu commented 1 month ago

Hmmm you have a point. I can try fixing it if you are willing to test it for me. I can make a pull request with a potential fix for you or anyone else to clone and test.

gonzalu commented 1 month ago

Absolutely... More than happy to beta or alpha test :D

I wish I could contribute but I am not a coder :(

ssitu commented 1 month ago

Alright, I'll have a go at it. If you want to help, I am assuming you have git installed. If you are able to, open a terminal in the directory with this node (For example: C:/.../ComfyUI/custom_nodes/ComfyUI_UltimateSDUpscale)

Then execute the following command: git checkout fix-crop-conditioning-loop This will make it so that you have my potential fix. When you are done testing, then use this command to revert back to the main code: git checkout main

Try out my fix and let me know if it works with flux dev. It'd be nice if it works first try, but that might not happen.

gonzalu commented 1 month ago

Awesome. Testing now

Manny Gonzalez

On Fri, Oct 11, 2024 at 1:18 AM ssitu @.***> wrote:

Alright, I'll have a go at it. If you want to help, I am assuming you have git installed. If you are able to, open a terminal in the directory with this node (For example: C:/.../ComfyUI/custom_nodes/ComfyUI_UltimateSDUpscale)

Then execute the following command: git checkout fix-crop-conditioning-loop This will make it so that you have my potential fix. When you are done testing, then use this command to revert back to the main code: git checkout main

Try out my fix and let me know if it works with flux dev. It'd be nice if it works first try, but that might not happen.

— Reply to this email directly, view it on GitHub https://github.com/ssitu/ComfyUI_UltimateSDUpscale/issues/105#issuecomment-2406572084, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHWZVPVAIR23CJRIT47IQC3Z25NS3AVCNFSM6AAAAABO6FCFRSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMBWGU3TEMBYGQ . You are receiving this because you authored the thread.Message ID: @.***>

gonzalu commented 1 month ago

Oops... ran into trouble.

I am using ComfyUI Portable.

I get this error:

E:\ComfyUI\ComfyUI\custom_nodes\ComfyUI_UltimateSDUpscale>git checkout fix-crop-conditioning-loop
error: pathspec 'fix-crop-conditioning-loop' did not match any file(s) known to git
gonzalu commented 1 month ago

...and I installed it via ComfyUI manager ;)

gonzalu commented 1 month ago

OK I think I found a workaround. I downloaded the branch and just copied it over the existing install ... not sure if that was correct...

however, I got this error

Canva size: 2688x1536
Image size: 1344x768
Scale factor: 2
Upscaling iteration 1 with scale factor 2
Tile size: 1024x1024
Tiles amount: 6
Grid: 2x3
Redraw enabled: True
Seams fix mode: NONE
!!! Exception during processing !!! 'str' object has no attribute 'copy'
Traceback (most recent call last):
  File "E:\ComfyUI\ComfyUI\execution.py", line 323, 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 "E:\ComfyUI\ComfyUI\execution.py", line 198, 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 "E:\ComfyUI\ComfyUI\execution.py", line 169, in _map_node_over_list
    process_inputs(input_dict, i)
  File "E:\ComfyUI\ComfyUI\execution.py", line 158, in process_inputs
    results.append(getattr(obj, func)(**inputs))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\ComfyUI\ComfyUI\custom_nodes\USDU\nodes.py", line 151, in upscale
    processed = script.run(p=self.sdprocessing, _=None, tile_width=self.tile_width, tile_height=self.tile_height,
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\ComfyUI\ComfyUI\custom_nodes\USDU\repositories\ultimate_sd_upscale\scripts\ultimate-upscale.py", line 565, in run
    upscaler.process()
  File "E:\ComfyUI\ComfyUI\custom_nodes\USDU\repositories\ultimate_sd_upscale\scripts\ultimate-upscale.py", line 138, in process
    self.image = self.redraw.start(self.p, self.image, self.rows, self.cols)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\ComfyUI\ComfyUI\custom_nodes\USDU\repositories\ultimate_sd_upscale\scripts\ultimate-upscale.py", line 245, in start
    return self.linear_process(p, image, rows, cols)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\ComfyUI\ComfyUI\custom_nodes\USDU\repositories\ultimate_sd_upscale\scripts\ultimate-upscale.py", line 180, in linear_process
    processed = processing.process_images(p)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\ComfyUI\ComfyUI\custom_nodes\USDU\modules\processing.py", line 165, in process_images
    positive_cropped = crop_cond(p.positive, crop_region, p.init_size, init_image.size, tile_size)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\ComfyUI\ComfyUI\custom_nodes\USDU\utils.py", line 454, in crop_cond
    cond_dict = x.copy()
                ^^^^^^
AttributeError: 'str' object has no attribute 'copy'
gonzalu commented 1 month ago

image

ssitu commented 1 month ago

Thanks for the testing. Nice workaround, I thought you might have git installed but that works too. Strange error, I tried using the same code as some of the built-in nodes.

Could you try one of the following nodes? They should be already included in your comfy installation:

Conditioning (Combine) Conditioning (Average) Conditioning (Concat)

I haven't really used these before, but I think you can just take two text encodes, input them into one of these nodes, and take the output as the new positive conditioning. So something like this: text encode1 + text encode2 -> conditioning merger node -> KSampler I want you to use a regular KSampler or something similar that isn't broken, instead of USDU. Please let me know if you get an error or not using flux dev, and a picture of the relevant part of the workflow like how you did in your last comment.

gonzalu commented 1 month ago

Oh sure... I'll also share my workflow file :D

Currently, I use the diffusers model format, not the checkpoint (if it matters.)

I will create a fresh workflow just to make sure we have a clean simple workflow instead of my complex one which might be the problem.

Give me a few minutes.

gonzalu commented 1 month ago

Here is my PRODUCTION workflow which I was trying to include USDU into. I normally use McBoaty Upscaler nodes (as I helped in the beta testing :D) but it is very slow... I use USDU when I want to generate an upscale a bit faster. MG 069 McBoaty fp8 Smerge 2x Upscale Conditioning Switcher McBoaty Upscale Florence2 Inspire Prompts from File Matteo Nodes AI Random Prompts Ollama LoRA Flux.1 Dev workflow.json

ssitu commented 1 month ago

I don't think it's an issue with your complex workflow. Other people have the same issue, notably #107

gonzalu commented 1 month ago

Guess what? NO ERRORS!!!!

image

gonzalu commented 1 month ago

Still part of the complex workflow and still using Anything Everywhere nodes 😮

image

gonzalu commented 1 month ago

and it finished without problems image

image

ssitu commented 1 month ago

I'm not sure what's happening. Could you try removing the conditioning combine node now and see if that gives an error?

gonzalu commented 1 month ago

sure

gonzalu commented 1 month ago

OK, if I connect directly from my Conditioning Switch, I get an error

image

Let me try again connecting directly from the clip text encoder

gonzalu commented 1 month ago

Connecting directly from my primary Clip Text Encode node, I get error.

BUT BUT

I am NOT using the one from ComfyUI core... I am using the one from cubiq (Comfy Essentials Pack)

that HAS to be the problem :D

image

image

gonzalu commented 1 month ago

I think I found MY problem

ComfyUI Core Clip Text Encode works...

image

ComfyUI Essentials Custom node Clip Text Encode does NOT work

image

ssitu commented 1 month ago

Well that's interesting. So there's no problem with my node? I suppose I can look into supporting that extension if you'd like.

gonzalu commented 1 month ago

I guess... but why would it be any different than the regular clip text encode? Doesn't the KSampler or any sampler have to have the same exact code for it to work with the models?

Maybe I'll see if Matteo can look into why his node doesn't work with USDU :(

Thanks.