Nodes/Pet Companion Nodes/Pet / Normalize Green First Frame
ComfyUI Node

Pet / Normalize Green First Frame

Your pet's video starts ugly. Make the first frame actually green.

By GuardSkill·Created 4 days ago·Updated 4 days ago· 0
Pet / Normalize Green First Frame
  • image
  • exact_green_image
key_color#00FF00
background_tolerance0.30
edge_feather1

If you've ever tried to turn a pet photo into a looping animated sticker, you know the pain this node exists to fix. You feed a photo into an image-to-video model hoping for a clean green screen, and the first frame comes back with a backdrop that isn't green, isn't even, and has weird negative space around separated legs. The keyer downstream then has nothing clean to key. Pet / Normalize Green First Frame is the "clean it up before the video model sees it" step. It's one of two nodes in the GuardSkill/ComfyUI-Pet-Companion-Nodes pack, and it does exactly one job: repaint the background with an exact chroma color.

How it works

The trick is in the name. Most naive "replace the green" filters recolor every pixel close to the target color - which eats dark fur, noses, and pupils that happen to be a similar shade. This node is smarter: it only touches background regions that are connected to the canvas boundary.

Under the hood it does the classic compositing dance. It infers the backdrop color from the median of the outer 8-pixel border, computes a per-pixel color distance from that, keeps every pixel within background_tolerance that's connected to the frame edge (via connected-component labeling), optionally dilates the selection by edge_feather, and paints those pixels the exact key_color. Interior blobs - the dark patch between separated legs, the shadow under the tail - aren't connected to the border, so they survive untouched. That's the whole point, and it's why it works on irregular generated backdrops instead of just flat green ones.

The inputs that matter

Only four, and two of them do the real work:

  • background_tolerance (0.02–0.75, default 0.30) - how far a pixel's color can drift from the inferred border color and still count as background. If your generated backdrop is only vaguely green, raise it; if it starts eating your dog's coat, drop it. This is the knob you'll tune most.
  • edge_feather (0–8, default 1) - grows the repainted region a bit so a stray pixel or two of model-generated green doesn't survive along the edge. 1 is usually fine.
  • key_color - six-digit hex only (#00FF00 default). Feed it a malformed value and the node raises a ValueError, so keep it well-formed.
  • image - a single IMAGE tensor.

The output, exact_green_image, is the same image with a perfectly uniform chroma background. Wire it into your image-to-video model's first-frame input.

Where it fits

The pack's own workflow is the recipe: pet photo → identity-preserving image edit on solid green → this node → image-to-video → the pack's other node (Pet / Chroma Key + Closed Loop WebP) keys and exports the loop. Get the first frame clean and the I2V model has a far easier job keeping the background consistent.

Install

ComfyUI Manager (search "ComfyUI-Pet-Companion-Nodes") or the manual route:

cd ComfyUI/custom_nodes
git clone https://github.com/GuardSkill/ComfyUI-Pet-Companion-Nodes.git

Restart ComfyUI and the nodes appear under Pet Companion/Green Screen. It's pure Python - numpy, opencv-python, Pillow - no model downloads, no API keys, no VRAM cost. That part is genuinely painless.

Gotchas

It's not a keyer. Don't expect transparency here; this node just makes the background keyable. And if your backdrop doesn't touch the frame edge (say, a generated vignette ring around the subject), nothing gets repainted - that's the boundary-connected rule biting you, and raising background_tolerance is the fix. As a new, single-version pack with basically no community chatter yet, treat it as a clean little utility: one honest job, done well.

CategoryPet Companion/Green Screen

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
key_colorSTRING#00FF00
background_toleranceFLOAT0.300.02–0.75
edge_featherINT10–8

Outputs (1)

NameTypeDescription
exact_green_imageIMAGE