Background removal with U2Net is too strong
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:

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

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:

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


you should sharpen the image first  (use strong sharpen)


from PIL import Image
from PIL import ImageFilter
from PIL.ImageFilter import (UnsharpMask)
simg = Image.open('data/srcimg07.jpg')
dimg = simg.filter(UnsharpMask(radius=4.5, percent=200, threshold=0))
dimg.save(&quot;result/ImageFilter_UnsharpMask_2_150_3.jpg&quot;)


use U2Net to remove the background of the sharpened image



use the result from step (2) as mask



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


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