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.
This commit is contained in:
mike
2026-06-23 21:52:59 +02:00
parent 3d44c7aba4
commit 188682b4c3
6 changed files with 446 additions and 81 deletions

View File

@@ -1,8 +1,3 @@
privacy feature not work when overlay
archive (anders dan delete)
delete action (closes screen?)
fix queen.mp
moet gegenereerd worden door de htmlbuilder, niet via de webserver
images.json
@@ -12,13 +7,8 @@ groups.json
config
videos
prompts should be viisible in studio view
copied artefacts should cary references
flag beta poses in ui
delete button gets disabled after a delete
extract a frame from a clip (scenery)
faceswap defaults nothing enabled, see jobs even when refresh
@@ -26,4 +16,13 @@ pose bestaat gewoon uit meerdere delen, camera, scenery + addition
focus op head + sam2.hyria seg + mesh
add photo to collection (zonder nieuwe groep)
zien van de geselecteerde images in de prompt in studio view
sam2 saifrail, connected pixels from mid? als invertor?
poses assignment bij de camera positie generaties
poses: hyper realistic, lighting, detailled skin etc.. see last generations for better results.
check 7b uncensored for automation
create disk 128gb 70b dolphin uncencored op server.