ComfyUI Node

Auto Mosaic

YOLO finds the bits you'd rather blur, so you don't have to

By sugarkwork·Created 7 months ago·Updated 2 months ago· 7
Auto Mosaic
  • image
  • IMAGE
  • MASK
save_psdfalse
filename_prefixAutoMosaic
confidence0.25
process_methodmosaic
factor100
target_classpussy,penis
model_namesensitive_detect_v07.pt
mask_expand0.0
video_modefalse
buffer_frames10
morph_methodsimple
model_name_2None

You've got a generated image - or a whole batch of them - and some regions need to not appear in the final version. Hand-masking each one with an inpainting or blur node is tedious as hell. AutoMosaic automates it: an Ultralytics YOLO segmentation model scans the image, finds the regions matching the classes you name, and slaps a mosaic, blur, white-fill, or nothing on exactly those pixels. It's the same family of trick as auto-masking tools like Adetailer, except pointed at "sensitive area detection" instead of faces. The default model is a purpose-built sensitive_detect_v07.pt and the default target_class is "pussy,penis" - so you can guess the crowd this is for. Don't overthink the packaging: it's a local YOLO node, no API, no key, no cloud anywhere.

How it works

Pick a YOLO segmentation checkpoint, and the node runs detection on your image (or every frame of a batch). The model returns masks and bounding boxes; AutoMosaic keeps only the classes listed in target_class, merges the masks, then processes each detected region per your chosen process_method and composites the result over the untouched background. Two models is a supported option too - model_name_2 loads a second checkpoint as a separate instance, runs both concurrently, and merges their detections before any processing. Belt and suspenders if one model misses stuff.

The factor input is where people get confused. It's not the mosaic block size in pixels; it's a divisor of the image's long edge. factor of 100 means each mosaic cell is about 1% of the long edge. So lower factor = bigger blocks = chunkier mosaic. The mask is also dilated outward automatically based on that same factor, so the effect covers the region instead of hugging the detected boundary.

Two bonus modes round it out. save_psd writes a layered PSD (base image plus one layer per processed region) to your output folder, which is genuinely handy if you need to hand-tune a frame later - you get a real Photoshop file with the processed layers intact. And video_mode turns a multi-frame batch into a video pass: it detects on every frame, then fills in undetected frames by interpolating masks between the detected ones (morph_method = simple) or by tracking the mask polygon with LK optical flow (optical_flow). Pick simple for slow-moving subjects, optical_flow when things actually move between frames.

The inputs that actually matter

The node has a lot of knobs, but you'll touch these:

  • target_class - comma-separated class names to process. Default "pussy,penis"; if your model has other classes, filter here.
  • confidence - YOLO detection threshold, default 0.25. Lower it if detections are being missed, but expect more false positives.
  • process_method - mosaic, blur, white, or raw (raw just gives you the detected mask region untouched). Default mosaic.
  • factor - mosaic/edge strength as described above. Default 100.
  • mask_expand - extra mask dilation on top of the automatic factor-based expansion, as a % of the long edge (max 20). Bump this when the effect is clipping the region.
  • model_name / model_name_2 - first and optional second YOLO model. Defaults to sensitive_detect_v07.pt.

Outputs are IMAGE (the composite, ready to wire into a Save Image / Preview node) and MASK (the combined detection mask, which you can route elsewhere - worth knowing it's there, the README undersells it).

Installing it

ComfyUI Manager is the easy path: search "comfyui-auto-mosaic" and install. Or clone it:

cd ComfyUI/custom_nodes
git clone https://github.com/sugarkwork/comfyui-auto-mosaic

then install dependencies into the same Python environment ComfyUI uses:

pip install -r comfyui-auto-mosaic/requirements.txt

requirements.txt pulls ultralytics, opencv-python-headless, gradio, torch, torchvision. Note the README also mentions psd-tools - the shipped code doesn't actually need it (it bundles its own minimal PSD writer), so don't chase that dependency if you see it referenced. The heavy lift is ultralytics; run the pip install in ComfyUI's venv so it reuses the torch you already have rather than trying to swap versions.

The model downloads itself on first run from HuggingFace (sugarknight/sensitive-detect) into ComfyUI/models/ultralytics (or models/yolo), so the first pass needs internet and takes a minute.

Common issues

  • Model won't load / download fails - drop sensitive_detect_v07.pt manually into ComfyUI/models/ultralytics and restart. The node scans both that folder and models/yolo.
  • The mosaic looks wrong / gaps at the edge - that's the mask being too tight. Raise mask_expand before blaming the model.
  • Detections all over the image - lower confidence found too much. Nudge confidence back up or tighten target_class.
  • Slow or memory-hungry batch runs - two models plus PSD export on high-res images adds up fast, and that's the one thing the author flags as a real limit.
  • Video mode doing nothing - it only activates when your batch is more than one frame, so a single image always takes the normal path.

For an "auto-censor the parts I didn't mean to show" utility, this is the most turnkey option in the pack - set target_class, hit run, done.

Categoryimage/process

Inputs (13)

NameTypeDefaultDescription
imageIMAGE
save_psdBOOLEANfalse
filename_prefixSTRINGAutoMosaic
confidenceFLOAT0.250.01–1
process_methodCOMBOmosaic4 options: raw, mosaic, white, blur
factorINT100
target_classSTRINGpussy,penis
model_nameCOMBOsensitive_detect_v07.pt1 options: sensitive_detect_v07.pt
mask_expandFLOAT0.00–20
video_modeBOOLEANfalse
buffer_framesINT101–120
morph_methodCOMBOsimple2 options: simple, optical_flow
model_name_2COMBONone2 options: None, sensitive_detect_v07.pt

Outputs (2)

NameTypeDescription
IMAGEIMAGE
MASKMASK