Nodes/Lace Studio Refine/Lace Studio 精修 v0.1
ComfyUI Node

Lace Studio 精修 v0.1

This Node Fixes Lace Scans Without Ever Touching a Model

By lin-sein·Created 28 days ago·Updated 26 days ago· 0
Lace Studio 精修 v0.1
  • image
  • refined_image
  • foreground_mask
  • report_json
backgroundauto
repeat_reconstructionauto
edge_cleanup50

Most ComfyUI nodes exist to run a diffusion model. This one exists so you don't have to. LaceStudioRefineV01 - "Lace Studio 精修 v0.1" in the node picker, 精修 being Chinese for fine retouching - is a deterministic OpenCV pipeline that cleans up a scanned lace (or any regularly repeating fabric) image: scanner background stripped, pattern de-drifted and straightened, defects in the repeat repaired, and a soft foreground mask handed back. No FLUX, no checkpoint, no API key, no VRAM. It runs on CPU in seconds and can't invent new threads - which is exactly the point when you're digitizing fabric for production or vectorization.

It ships alone in the pack and targets a narrow, real job: flatbed scans where the lace doesn't fill the frame, the pattern drifts across repeats, a repeat caught scanner dust the others didn't, and the bed shows through as a warm tint.

Why a generic remover won't cut it here

BiRefNet and rembg are great at "find the salient object," but lace is semi-transparent, thin, and repetitive - a saliency model has no notion that the pattern should tile cleanly. This node exploits the periodicity itself, and that's what makes the outputs usable.

How it works

The node is a thin wrapper - the real work lives in a runtime script it loads at execution. The pipeline:

  1. Estimate background from the border rows, then classify polarity (light lace on dark bed vs. dark lace on light bed).
  2. Find the primary lace band by smoothing the row-density profile and taking the largest integrated foreground band - so it handles lace that only occupies part of the scan.
  3. Detect the repeat period via autocorrelation across a range of lags, and estimate the vertical drift between repeats with phase correlation.
  4. If confidence is high enough (≥ 0.55 with at least two full repeats), rebuild the repeat: shear-correct the drift, take the sharpest repeat as the base, phase-align the rest, and replace anomalies - the dust that only landed in one repeat - with median-consensus detail, then tile across the width. Otherwise the pixels pass through untouched.
  5. Remove the background with a per-column flat-field estimate, producing a soft alpha, then re-center the band vertically.

Nothing here samples a model, which puts it squarely in ComfyUI's deterministic post-processing layer - reach for the cheap operation instead of burning a diffusion pass. It also loops over the batch dimension, tagging each image's report with its batchIndex.

The inputs that matter

Four inputs, and two are fire-and-forget.

  • image - any IMAGE.
  • background - auto (default), white, or black. Sets the output background; auto picks by detected polarity, so light lace on a dark bed comes out on black and dark lace on a light bed comes out on white. Pick white when you're prepping for e-commerce transparency.
  • repeat_reconstruction - auto or off. auto rebuilds only when it finds a high-confidence repeat; off forces passthrough if the autocorrelation latches onto something that isn't actually periodic.
  • edge_cleanup - 0–100 slider, default 50. The one you'll actually touch. It tightens the boundary gate so scanner-bed shading at the top and bottom of each column doesn't get read as lace. Crank it when you see a faint bed-color fringe hugging the edges; back off if genuine scalloped detail is getting clipped.

Outputs

  • refined_image - the cleaned image at the same resolution as the input (output size is fixed; save as PNG).
  • foreground_mask - a soft MASK (fractional alpha, not a hard cutout). Save it for a transparent PNG, or feed it back in to constrain a masked FLUX repair inside the lace area.
  • report_json - a STRING report of what it detected: polarity, estimated background RGB, repeat period and drift, confidence, edge-cleanup settings. When a run does something surprising, this is how you find out why.

Install

Via ComfyUI Manager, search "Lace Studio Refine" (registry node ID lace-studio-refine) - no high-risk "Install via Git URL" toggle needed. Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/lin-sein/lace-studio-refine-comfyui
cd ..
pip install -r custom_nodes/lace-studio-refine-comfyui/requirements.txt

On Windows portable, run that pip line with ./python_embeded/python.exe -m pip install -r .... No model downloads - the requirements are just numpy, opencv-python-headless, and Pillow. Restart ComfyUI and verify with GET /object_info/LaceStudioRefineV01.

Troubleshooting

  • numpy.core.multiarray failed to import - the classic NumPy 2 vs. old OpenCV-wheel clash; v0.1.2 pins opencv-python-headless==4.13.0.92 to fix it. If it still fails, don't hand-mix multiple opencv-python* distributions in the same environment; reinstall the requirements into ComfyUI's Python env and restart.
  • Manager shows a dependency install failure - don't run the workflow; restart ComfyUI completely and keep the install log.
  • The README is Chinese-only, and v0.1 explicitly says to validate one test image before wiring it into batch jobs.

Honest verdict: this is a v0.1 from a single author, licensed "All rights reserved," with basically zero community footprint yet. If you don't digitize lace, there's nothing here for you. If you do, nothing else on the registry does this specific job - without once asking a model for permission.

CategoryLace Studio/Refine v0.1

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
backgroundCOMBOauto3 options: auto, white, black
repeat_reconstructionCOMBOauto2 options: auto, off
edge_cleanupINT500–100

Outputs (3)

NameTypeDescription
refined_imageIMAGE
foreground_maskMASK
report_jsonSTRING