imgly / background-removal-js

Remove backgrounds from images directly in the browser environment with ease and no additional costs or privacy concerns. Explore an interactive demo.
https://img.ly/showcases/cesdk/web/background-removal/web
GNU Affero General Public License v3.0
5.49k stars 339 forks source link

Background somewhere removed between hairs and somewhere else not #114

Open marcello-pietrobon opened 2 months ago

marcello-pietrobon commented 2 months ago

Hello, thank you for your software. It's definitely doing what I need.

Yet I see that in a picture I have it does remove the background but still leaves some of it between the hairs in some places while in others that are similar it doesn't.

The question is if this could be improved or not, or maybe in a near future. :-)

Here below I show what I mean.

This is the original picture: Persona1 org

Here the result with the medium model: Persona1 brj

Here the mask (which I extracted from the result picture here above using GIMP): Persona1 brj mask

BTW, I tried to get the mask directly from background-removal-js by using

    output: {
      quality: 0.8,
      format: 'image/png',
      type: 'foreground'
    }

in the example provided, but the output file looks exactly identical no matter if I use 'foreground' , 'background' or 'mask'.

Also the 'large' model doesn't seem to make any difference (this I did it by setting

    const config = {
      model: 'large'
    }

and hacking .\node_modules\@imgly\background-removal-node\dist\resources.json by adding in it the lines:

,
  "/models/large": {
    "chunks": [
      {
        "hash": "17b7466d93bb60b0e88affa2b0e8b3eee309c7de183d394ce4b956339ebd95e6",
        "offsets": [
          0,
          176173887
        ]
      }
    ],
    "size": 176173887,
    "mime": "application/octet-steam"
  }

(but probably it's not the right way, though it seems to work, ... I don't know yet how to manually compile the source and manually installed in the .\node_modules\ subirectory).

I'm using background-removal-js installed on windows 10 with the command npm install @imgly/background-removal-node.

Kindest regards, M