How to generate white background images instead of colorful? #14813
Replies: 2 comments 1 reply
|
Your load_square() function does composite transparent inputs onto white, so BG_COLOR itself is not an inference-time background control. The result means the LoRA/text conditioning has not learned “white background” strongly enough to override SD 1.5’s background prior. I would debug it in this order:
A UNet attention LoRA is good at learning style/concepts but is not a pixel-level background guarantee. If production output must be exactly #FFFFFF, the reliable solution is segmentation/alpha extraction followed by compositing onto white (or an explicit conditioning/mask workflow). Use the LoRA for the asset style and enforce the final background deterministically in post-processing. |
|
Adding to what @TongyiDai said, from doing a lot of this in production: On how many images: 100 is fine for a style LoRA, so the count isn't your problem. You're asking an attention LoRA to guarantee a pixel-perfect white background, and that's the one thing it's weak at. It learns the postapo icon style well, but white background stays a soft hint that it will drop whenever the composition wants to. More images won't change that. If you need clean white every time, don't get it from the LoRA at all. Generate the asset, then remove the background with rembg or BiRefNet and paste it onto white. For flat-background game icons that's the normal pipeline, and it's the only way to get an exact result. If you want to stay single-pass, the things that actually help, in order:
Short version: LoRA for the style, background removal in post. Then you stop fighting the model. |

















Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi, I'm trying to train stable-diffusion-v1-5/stable-diffusion-v1-5 with custom data with LoraConfig to generate a type of 2D asset.
So I have a dataset of transparent PNG images, and I added to my prompt text for every image a white background after the caption
And in my script, I added BG_COLOR = (255, 255, 255)
and that's my code
But I got this image
thanks and regards
All reactions