plemeri / transparent-background

This is a background removing tool powered by InSPyReNet (ACCV 2022)
MIT License
763 stars 83 forks source link

Image background information is still in the image file #69

Closed VINTX2 closed 2 weeks ago

VINTX2 commented 3 months ago

Hello,

while playing around with background-removed images in other AI img2img tools, I have noticed that the AI tools are recovering the removed background.

Let me give an example:

  1. This is the unchanged original image:

image

  1. Image after removing the background with: transparent-background --source TIMO_HAUS_Tiny_House_Adler_0013.jpg --dest ./test

image

  1. Now using InstuctPix2Pix. (It not only happens in this tool, but in other tools as well. For example, Stable Diffusion.)
    Link to the demo: https://huggingface.co/spaces/timbrooks/instruct-pix2pix

image

Why is this an issue? If you think that you removed something from a picture, but you do not know that it is recoverable, it could lead to privacy/security problems.

Temporary solutions:

  1. You can open the picture in GIMP, go to "File" and overwrite the image. This will remove the background information from the file. You will also see that the file size decreases.
  2. You can use the --type option to fill the background with a color.
  3. If you want to retain transparency, you can use this Image Magick command: convert input_image.png -background none -flatten output.png
plemeri commented 3 months ago

Hi @VINTX2, I didn't have any experience using InstructPix2Pix, but I'm quite sure that the reason is RGBA file format. RGBA format contains RGB information with additional Alpha channel, where it usually contains a transparency information. So, if you choose rgba option, then your output contains a full RGB information with additional transparency Alpha channel information which is generated by our tool.

In many cases, such as simple web browser image viewer does not support such format, so they rather just ignore the Alpha channel information and just regard the data as RGB data. So, the output is perfectly fine, just the viewer does not support the format.

If you want to explicitly fill the background with white or other color, use white or custom option with rgb value. More information can be found in https://github.com/plemeri/transparent-background?tab=readme-ov-file#computer-command-line

plemeri commented 2 weeks ago

Closing due to inactivity.