Replace the background of (almost) any image.
If anyone wants to experiment and include a better image editing model that would be really cool; DALL-E, as good as it is, isn't fantastic with real images and creates some fairly trippy results:
rebackground -i 'craig.jpg' -o 'craig_rainforest.png' -p 'Broadcasting from a rainforest'
-
Clone the repo
git clone [email protected]:king-millez/rebackground.git
cd rebackground
-
Set the remove.bg and OpenAI environment variables.
- To learn how to set environment variables on your OS, follow this guide. You may find better Windows-specific info here.
- Set
REMOVEBG_API_KEY
to the key obtained from following this guide (click the big "Get API Key" button). - Set
OPENAI_API_KEY
to the key obtained from this page. You need an OpenAI account, etc etc. - Note: you may need to log out and log back in for environment variable changes (especially on Windows) to work.
-
You can build the application or run it with
dotnet
. This app should work on Windows, MacOS, and Linux. If it doesn't, let me know and I'll fix it (open a GitHub issue, do not email me).
If you don't want to compile, just replace rebackground
with dotnet run --
You'll need to crop your input images to have a 1:1 ratio, e.g 512x512
, 1080x1080
, etc.
rebackground -i <input image> -o <output image (will be a PNG)> -p <DALL-E edit prompt>