2

In Stable diffusion, what prompts are required in order to have a foreground object against a transparent background (or a plain one if transparent isn't possible), so that a user would not need to manually crop it out. Using the Stable diffusion engine.

For example, to draw a bonsai tree with a transparent background.

2 Answers 2

1

In Stable diffusion, what prompts are required in order to have a foreground object against a transparent background

It is not possible to have anything transparent in the output image using the pretrained Stable Diffusion models, because Stable Diffusion used RGB at training time, which has no alpha channel, unlike e.g. RGBA. One could, however, possibly retrain a Stable Diffusion model with a color model that allows transparency.

For example, to draw a bonsai tree with a transparent background.

One can use the prompt "bonsai tree with a solid background", then have some image editing program make the background transparent, e.g. with Photoshop's background removal feature (tutorial):

enter image description here


"bonsai tree with a solid background":

enter image description here

Disclaimer: I am member of Adobe Research.

1

Transparency doesn't exist in the AI graphics world (yet). There are apps and websites which will do a more-or-less tolerable job of stripping the background out for you. I use playgroundai.com on the web, which is a bit hefty if that is all you ever use it for. For apps, just search for background removal - there are some good ones available free.

Be aware that most formats will store in RGBA or similar format (for details, check the format you are saving in). That means there IS a full image background (the RGB component on every pixel), with a marker to make it transparent (it can be translucent). On loading the image into any rendering engine, if the engine doesn't display transparency, it will display the RGB image. So, have a thought to the default background you want in case transparency is ignored (probably white or black, NOT the cinematic cliched green screen).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.