This API is used to remove the background of an image and place the product on a desired background. Background generation is done using Stable Diffusion models (https://huggingface.co/stabilityai/stable-diffusion-2-inpainting). The API is built using FastAPI and deployed using Docker.
- Docker
- Nvidia GPU (optional but recommended)
git clone https://github.com/arda-num/stable-diffusion.git
docker-compose up
pip install -r requirements.txt
uvicorn main:app --reload
curl -o download.png --location --request POST 'http://127.0.0.1:8000/inpaint' \
--form 'prompt="a bottle of perfume with confetti in the background, a digital rendering by Jeff Koons, cg society contest winner, new objectivity, vray tracing, dynamic composition, rendered in unreal engine"' \
--form 'image=@"path/to/image.png"'
curl -o download.png --location --request POST 'http://127.0.0.1:8000/removebackground' \
--form 'image=@"path/to/image.png"'
This is because the docker container is running out of memory. You can increase the memory limit of the container by going to Docker Desktop -> Settings -> Resources -> Advanced -> Memory and increasing the memory limit
OR
you can try changing the limits and reservations in docker-compose.yml file.
deploy:
resources:
limits:
memory: 500M
reservations:
memory: 128M