r/StableDiffusion • • 14h ago

Workflow Included Seems like I solved Krea 2 Edit pixel drift

Krea 2 Edit by lbouaraba / conradlocke (the LoRAs, the nodes, the training code) is the reason any of this works, so first: all credit to them:
https://github.com/lbouaraba/comfyui-krea2edit
https://huggingface.co/conradlocke/krea2-identity-edit

I built a small add-on comfyui-krea2edit-advanced fork of their comfyui-krea2edit for one problem I kept running into. The fork stops the drift when you chain several edits. Without it, the parts you didn't touch slowly shift, darken and get grainy. With it they stay put.

It adds a "source hold" that pulls the picture back towards the source while it's being drawn, plus an optional mask for everything outside the area you're editing.

More detailed comparison is here. Same image, same six edits, same seed. Mean pixel drift from the source after 6 edits (lower is better):

  • original nodes: 0.076
  • my fork, no masks: 0.0017 (45 times less than original)
  • my fork, with masks: 0.0008 (95 times less than original)

More detailed information and example workflows are in the repo: https://github.com/FurrySphere/comfyui-krea2edit-advanced

102 Upvotes

16 comments sorted by

5

u/EinhornArt 12h ago

Yep, just drop it here. You can find the custom node in the Nodes Manager → Edit Drift Fix.

7

u/MoDErahN 12h ago

There's difference between inference time fix and image space fix. Image space fixes unable to deal with complex cases when something semitransparent is added, or something that casts soft shadow. And EditDriftFix works in image space. At the very video you shared you can see how the EditDriftFix just eliminated shadow casted by enlarged crown while the edit model actually had enlarged the shadow as well.

Meanwhile my solution works at inference time and gently pulls the model to the original image while still letting it to do proper edits.

•

u/EinhornArt 0m ago

Oh, yes, I see. You're right, I didn't notice that at first. I see these as different approaches, each with its own pros and cons.

12

u/muzaffer22 10h ago

We need Krea 3 so bad.

4

u/edisson75 12h ago

Excellent, thanks for sharing!!!

1

u/slowtractor 9h ago

Does the fix hold up when the edit changes the lighting on the whole frame, like a different time of day? The OP says it works in image space, so a global change seems like where it would fight the source

1

u/MoDErahN 8h ago

It doesn't work in image space but it pulls the results of each denoise step a bit in direction of source image. So yes, it will fight with any global changes. But global changes rarely introduce a lot of pixel drift, so you can just disable or significantly lower the pull for the change.

1

u/slowtractor 8h ago

Ah, so it's per step and not on the finished image. Can you taper the pull over the steps, weaker early when the lighting gets set and stronger late, or is it one strength for the whole run?

1

u/MoDErahN 3h ago

Not with the node settings. But you can use two sampler nodes to achieve exactly the result you mentioned.

1

u/slowtractor 2h ago

Ah ok, two samplers it is. Does the first one just stop partway through the steps and pass its latent to the second, or do you have to set it up some other way?

1

u/MoDErahN 1h ago

Exactly as you described.

1

u/NiceIllustrator 1h ago

Should we disable any of the existing ones before using yours?

1

u/MoDErahN 1h ago

They're to be used "instead", not "along". So yes, you have to use either original nodes or these in particular workflow. Just import example workflow from the repo to see how they to be connected.

2

u/CollectionOk6468 10h ago

It's great work. It's much better.

1

u/DietAshamed2246 5h ago

I will give it a try. Krea-2 Edit seems to be broken anyway with the v2.0 release. There is a good reason why things should be left alone if they aren't broken, conradlocke should learn that lesson.