Background removal with U2Net is too strong

Question:

I am successfully using U2Net to remove the background of images using the terminal and I am also using the nice interface of this repo to do the same thing just in an easier way and validate the similarity of the results. However, my issue is that the background removal is too strong for images like this:

enter image description here

Where I get the following result (i.e. packaging is also removed):

enter image description here

If I upload the image in Foco clipping website and I select Type=='Graphic' I get exactly the same results. That means that the website is using the same algorithm to remove the background for Graphic-type images. Nevertheless, if I select Type=='Product', then the result is the following and is exactly what I want:

enter image description here

Does anyone have any idea on what to do to obtain the same result?

Asked By: azal

||

Answers:

  1. you should sharpen the image first (use strong sharpen)

Example

/* I've removed the code because I am not sure if it has some portion copied from other open-sourced codes, I am using it in my apps but I can't remember if it is quoted from other source, so I've removed it, also it could be auto-completed using github copilot */
  1. use U2Net to remove the background of the sharpened image

Example

  1. use the result from step (2) as mask

Example

  1. using the mask from step (3) extract wanted result from original picture

Example

note: this is very quick example, you could refine it more

Answered By: user16930239