Files
qwen-image/tour-comfy/config.json
mike 3d44c7aba4 The previous SAM2 full-frame bbox approach inverts the mask on black-background images. When Qwen renders black background (≈75% of pixels are black), SAM2 scores the large dark region as the "most prominent object" and selects it — making the background opaque and the person transparent. That's why the output looked like a white silhouette: transparent person pixels → viewer shows white.
New _apply_transparency_black_bg function (called when bg_removal=sam2):
1.
Threshold — any pixel with max-channel > 25 = person. Finds the person's exact bounding box without any model confusion.
2.
SAM2 with tight person bbox — feeds SAM2 the person-specific box instead of the full frame. SAM2 now segments within the person area for clean sub-pixel edges.
3.
Coverage sanity — accepts SAM2 only if coverage is within ±30pp of the threshold estimate; rejects inverted-mask failures.
4.
Threshold mask fallback — if SAM2 errors or diverges, uses the threshold mask with Gaussian edge blur (r=2).
Test result: Person RGB mean (146, 101, 86) — correct skin tones. 74.5% transparent background, 24% opaque person. ✓
Test results validated:
•
rembg path: perfect cutout (hair bun, earring, sneakers, clean edges)
•
SAM2-on-black path: complete silhouette mask at 74% coverage — full body, shoes and hair included, no holes
To switch to SAM2 mode: "bg_removal": "sam2" in config.json. No restart needed — the config is read per-request.
2026-06-22 22:09:18 +02:00

30 lines
1.5 KiB
JSON

{
"api_url": "http://127.0.0.1:8500/edit",
"prompt": "high quality. realistic. detailed, female nude. realistic, high quality. realistic. detailed. female nude. realistic",
"base_prompts": [
"Head-on full-nude-body three-quarter female portrait, realistic, transparent background",
"Head-on straight-on full-nude-body female portrait, realistic, transparent background",
"Head-on straight-on full-body female portrait, realistic, no background",
"high quality, full-nude-body, female, masterpiece, realistic, photo, looking at viewer",
"high quality, full-nude-body, female, masterpiece, realistic, photo, detailed skin, professional lighting, transparent background",
"high quality, full-nude-body, female, masterpiece, realistic, photo, cinematic lighting, dramatic shadows, sharp focus, transparent background"
],
"seed": -1,
"max_area": 655360,
"margin": 10,
"top_margin": 20,
"headroom": 0.05,
"poll_interval": 2,
"stage_dir": "/mnt/zim/tour-comfy/stage",
"output_dir": "/mnt/zim/tour-comfy/output",
"failed_dir": "/mnt/zim/tour-comfy/failed",
"processed_file": "./tour-comfy/processed.json",
"log_file": "./tour-comfy/watcher.log",
"wireframe_dir": "/mnt/zim/tour-comfy/wireframe",
"faceswap_model": "~/.insightface/models/inswapper_128.onnx",
"facefusion_dir": "~/facefusion",
"facefusion_venv": "~/facefusion-venv",
"sam2_checkpoint": "~/.sam/sam2.1_hiera_base_plus.pt",
"sam2_config": "configs/sam2.1/sam2.1_hiera_b+.yaml",
"bg_removal": "sam2"
}