Nodes/ComfyUI_Diffree/Diffree_Sampler
ComfyUI Node

Diffree_Sampler

Add an object with a sentence, no mask required

By smthemex·Created 2 years ago·Updated about a year ago· 31
Diffree_Sampler
  • image
  • pipe
  • image
  • mask
  • rgb_mask
promptreflective sunglasses
randomize_seedfalse
seed100
steps20
randomize_cfgfalse
text_cfg7.5
img_cfg1.5
width512
height512
rgb_mode
batch_size1

This is the node where Diffree's trick actually happens. Feed it a photo and a sentence - "reflective sunglasses," the default - and it decides where the sunglasses go, paints them in, and hands you the result along with a mask showing exactly what it changed. No mask, no box, no inpainting by hand. You describe, it places.

How the "shape free" bit works

Diffree is a two-branch diffusion model: one branch reads your text plus the image, the other reads the image only. The sampler runs a modified k-diffusion Euler-ancestral loop over both latents at once - z_0 is denoised with classifier-free guidance between your prompt and an empty one, while z_1 reconstructs the photo with no text influence at all. Wherever those two paths disagree is where the model decided your object goes. That disagreement, thresholded, dilated, and Gaussian-blurred, becomes a soft mask, and only the edited patch is composited back over the original image.

That last part is the whole pitch. Because the untouched background is literally the original pixels, it doesn't drift, recolor, or restyle - you get "add exactly one object to this photo" with everything else bit-identical.

The inputs that matter

  • image - your photo, straight from a LoadImage node. The sampler resizes it to width/height before running, so what comes back may not match your input resolution.
  • pipe - from Diffree_Model_Loader. Non-negotiable; the pair is a single unit.
  • prompt - multiline text describing the object. Fun fact: an empty prompt silently falls back to "reflective sunglasses" (it's hardcoded in the source), so a blank field isn't an error, it's the author's demo.
  • text_cfg (7.5) and img_cfg (1.5) - the two classifier-free guidance strengths, one for text, one for image. randomize_cfg jitters both each run, text into 6–9 and image into 1.2–1.8, which is handy for exploring.
  • width / height - 512 default. Diffree was trained at 256, and the README recommends 512ish. This is an SD1.5-class model; cranking to 2048 won't buy you detail, it'll just buy you mush and VRAM.
  • rgb_mode - red/green/blue. This only tints the debug preview output, so don't overthink it.
  • seed / randomize_seed, steps (20), batch_size (1) - standard fare; batch_size > 1 stacks results into a batch.

The three outputs

Wire all three into SaveImage nodes, which is exactly what the pack's example workflow does.

  • image - the composite: your photo with the object added. This is the keeper.
  • mask - the soft grayscale mask of the edited region.
  • rgb_mask - the composite with the edited region tinted your chosen color. This is the debug view, and it's genuinely useful the first few runs, because it makes the model's placement decision obvious at a glance.

Should you reach for it?

Honest take: Diffree is a 2024 research model with essentially zero community footprint since its single launch thread. In 2026, for most "edit this photo" jobs, an instruction editor like Qwen-Image-Edit or Flux Kontext is more flexible and usually better. Diffree keeps exactly one edge: it only ever touches the region it decided to paint, so the untouched background is guaranteed original pixels - no drift across edits. If "add one plausible object to a photo and change nothing else" is your actual task, this is still one of the cleanest ways to do it.

Where people get burned

The object lands where the model wants, not where you want - there's no placement control, and that's the shape-free tradeoff. Rewrite the prompt to steer it; it's the first frustration everyone hits. Older CUDA cards can OOM because sampling runs under autocast("cuda"), and the README admits the wrapper never frees ~4GB of VRAM. Keep expectations at 512-class output and you'll be fine; push resolution and the SD1.5 roots show.

CategoryDiffree

Inputs (13)

NameTypeDefaultDescription
imageIMAGE
pipeDIFFREE_MODEL
promptSTRINGreflective sunglasses
randomize_seedBOOLEANfalse
seedINT1000–2147483647
stepsINT201–100
randomize_cfgBOOLEANfalse
text_cfgFLOAT7.50.1–10
img_cfgFLOAT1.50.1–10
widthINT512256–2048
heightINT512256–2048
rgb_modeCOMBO3 options: red, green, blue
batch_sizeINT11–100

Outputs (3)

NameTypeDescription
imageIMAGE
maskIMAGE
rgb_maskIMAGE