Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Differential Diffusion #2876

Merged
merged 11 commits into from
Mar 3, 2024

Conversation

shiimizu
Copy link
Contributor

@shiimizu shiimizu commented Feb 23, 2024

The authors of the paper introduced a concept called a change map. For brevity, I will refer to it here as a mask.

The node _for_testing/Differential Diffusion is meant to be used alongside the InpaintModelConditioning node or the Set Latent Noise Mask node, and then the sampler does it automatically.

Implementation details

  • A full change of the mask is done, essentially $\fbox{mask >= threshold}$ instead of $\fbox{mask > threshold}$. This is important because the contents of the mask should be followed, and for latent inpainting/outpainting (where the mask becomes binary), the initial step should paint something.

General info/tips

  • Lighter areas get painted earlier, darker areas later.
    • Try adjusting the mask's blur, opacity, brightness, exposure, etc.
    • To get more of the original image, lower the mask's opacity/brightness or increase its blur.
  • The more steps, the finer it's applied (due to finer thresholds).
  • Lower your cfg if things look too noisy or fried.

Comparisons

These were made alongside the InpaintModelConditioning node without an inpainting model.

ComfyUI_temp_vytsl_00046_
Example comparison 2 Example comparison 3

Example workflow

Here's a simple workflow to get started. (Note: It uses some custom nodes).
Feel free to use another blur node.
Also, see the official inpaint examples.

Example workflow

Download this image to drag & drop it in ComfyUI.

Issues

  • The callback doesn't seem to get called for UniPC samplers.

Resolves #2851, resolves #2671

@comfyanonymous
Copy link
Owner

This should have fixed the uni_pc issue: 10847df

@didnhdj2
Copy link

could you plz give an example to show how to use this node ? thanks a lot !

@shiimizu
Copy link
Contributor Author

I updated the original post with an example workflow.

@shiimizu shiimizu marked this pull request as ready for review February 29, 2024 22:37
@comfyanonymous comfyanonymous merged commit 727021b into comfyanonymous:master Mar 3, 2024
1 check passed
@comfyanonymous
Copy link
Owner

I thought this was going to break at some point in the future so I simplified the code: 12c1080

Behaviour should be very close to identical as before at least on the normal scheduler, let me know if that's not the case.

@ethanfel
Copy link

ethanfel commented Mar 3, 2024

I thought this was going to break at some point in the future so I simplified the code: 12c1080

Behaviour should be very close to identical as before at least on the normal scheduler, let me know if that's not the case.

image

Hi, I just moved back from the shiimizu fork, removed the nodes and readded them and it return an error.

@comfyanonymous
Copy link
Owner

can I see your full stacktrace?

@shiimizu
Copy link
Contributor Author

shiimizu commented Mar 4, 2024

It's when batch_size > 1.

current_ts = model.inner_model.model_sampling.timestep(sigma)

In that line, I think sigma should be sigma[0]

@comfyanonymous
Copy link
Owner

Yes that should be fixed now.

@kadirnar
Copy link
Contributor

kadirnar commented Mar 4, 2024

Yes that should be fixed now.

'UNetModel' object has no attribute 'default_image_only_indicator'

File "D:\ComfyUI\ComfyUI\custom_nodes\FreeU_Advanced\nodes.py", line 159, in __temp__forward
image_only_indicator = kwargs.get("image_only_indicator", self.default_image_only_indicator)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\ComfyUI\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1688, in __getattr__
raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")

@ltdrdata
Copy link
Collaborator

ltdrdata commented Mar 4, 2024

Yes that should be fixed now.

'UNetModel' object has no attribute 'default_image_only_indicator'

File "D:\ComfyUI\ComfyUI\custom_nodes\FreeU_Advanced\nodes.py", line 159, in __temp__forward
image_only_indicator = kwargs.get("image_only_indicator", self.default_image_only_indicator)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\ComfyUI\python_embeded\Lib\site-packages\torch\nn\modules\module.py", line 1688, in __getattr__
raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")

disable FreeU_Advanced

@DENG-XC
Copy link

DENG-XC commented Apr 15, 2024

Hi, thanks you for your guys hard work. This is a great new inpainting node, but I have problem with this node currently. differential diffusion is not working with controlnet and IPAdapter? The output image get burn when I connect controlnet and differential diffusion together. (IPAdapter have the same problem)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants